Kitonum

21465 Reputation

26 Badges

17 years, 48 days

MaplePrimes Activity


These are answers submitted by Kitonum


 

restart;

f:=(x,y)->x^4-3*x^2-2*y^3+3*y+1/2*x*y;

proc (x, y) options operator, arrow; x^4-3*x^2-2*y^3+3*y+(1/2)*x*y end proc

(1)

Find the critical points:  

 

CriticalPoints:= [solve( {diff(f(x,y),x)=0,diff(f(x,y),y)=0}, {x,y}, explicit)]:
evalf(%);

[{x = 0.5935572277e-1, y = .7105957432}, {x = 1.191117672, y = .77411872}, {x = 1.255942703, y = -.77760007}, {x = -0.5877159444e-1, y = -.7036351094}, {x = -1.197482099, y = -.63262139}, {x = -1.250162405, y = .62914212}]

(2)

Find the second partial derivatives:

A:=diff(f(x,y),x,x); B:=diff(f(x,y),x,y); C:=diff(f(x,y),y,y);

12*x^2-6

 

1/2

 

-12*y

(3)

 

In a loop, using the quadratic form  A*C-B^2, examine each of the 6 critical points:

for k from 1 to 6 do
S:=evalf(CriticalPoints[k]);
Q:=eval(A*C-B^2,S); A0:=eval(A,S); f0:=eval(f(x,y),S);
if Q>0 then if A0<0 then R[k]:=[Maximum,S,f0] else R[k]:=[Minimum,S,f0] fi;fi;
if Q<0 then R[k]:=[Saddle,S,f0] fi;
od:
Matrix([[Type_of_point,Point,Value_of_function],seq(R[k],k=1..6)]);

Matrix(7, 3, {(1, 1) = Type_of_point, (1, 2) = Point, (1, 3) = Value_of_function, (2, 1) = Maximum, (2, 2) = {x = 0.5935572277e-1, y = .7105957432}, (2, 3) = 1.424693902, (3, 1) = Saddle, (3, 2) = {x = 1.191117672, y = .77411872}, (3, 3) = -.3878073192, (4, 1) = Minimum, (4, 2) = {x = 1.255942703, y = -.77760007}, (4, 3) = -4.124751020, (5, 1) = Saddle, (5, 2) = {x = -0.5877159444e-1, y = -.7036351094}, (5, 3) = -1.403836003, (6, 1) = Minimum, (6, 2) = {x = -1.197482099, y = -.63262139}, (6, 3) = -3.258364349, (7, 1) = Saddle, (7, 2) = {x = -1.250162405, y = .62914212}, (7, 3) = -1.249935209})

(4)

Plotting:

P1:=plot3d(f(x,y),x=-2..2,y=-2..2, view=-6..6):
P2:=plots:-pointplot3d([seq(eval([x,y,z],[R[k][2][],z=R[k][3]]),k=1..6)],color=red, symbol=solidsphere, symbolsize=18):
plots:-display(P1,P2, orientation=[60,60]);

 

 


The plot clearly shows: one maximum, two minimums and three saddles

Download zadelpunten_procedure_new.mw

Use the  seq  command for this.
Example:

restart;
L:=[0, Pi/6, Pi/4, Pi/3, Pi/2];
[seq([p,sin(p)], p=L)];

                

restart;
P:=x^4 - x^2 + x - 1:
A:=PolynomialTools:-Split(P, x);
convert(A, radical);
simplify(expand(%));  # A check

1. For  isolve a system should be specified as a set (not a list).
2. You need to specify exactly what you mean by the smallest positive solution, because the solution will not be one number, but an ordered set of numbers (a list). For example, which is less: [2, 4] or [1, 5] ?

In the solution below, the solutions are sorted by the minimum sum of the squares of all coordinates.

restart;
sys:= {a[1] = 2 * a[5], a[1] = a[4], 4 * a[1] + 2 * a[3] = a[6] + 2 * a[7], 2 * a[2] + 2 * a[3] = 2 * a[6], a[2] = a[4] + a[5], 2 * a[2] -a[1] = 2 * a[4]};
indets(sys);
n:=nops(%);
isolve(sys);
assign(%);
solve({seq(a[i]>0, i=1..n)});
[seq(seq([seq(a[i],i=1..n)],_Z2=floor(5*_Z1/2)+1..10),_Z1=1..10)];
sort(%, key = (x->add(x[i]^2,i=1..n)));

        

I think this contradiction is just a rounding error. Maple uses 10 digits by default. Use precise arithmetic (or make  Digits  bigger):

convert(-24.*y^6*(y-1.)^7*(y+1.)^7*(4.+6.*y^8-22.*y^6+30.*y^4-18.*y^2)/(4.*y^18-28.*y^16+84.*y^14+4.-136.*y^12+116.*y^10-24.*y^8-52.*y^6+56.*y^4-24.*y^2)^2, fraction);
subs(y=1+1/100000, %);
evalf(%);

                                     

First, we find the equation of the normal at an arbitrary point  P(x1,x1^2)  on the parabola. This normal intersects the axis  Oy  at a point  Q(0,y0) . Imposing the condition that the distance  PQ  = 1, we first find x1, and then the point  Q (the center of desired circle).

restart;
f:=x->x^2:
g:=x->f(x1)-1/D(f)(x1)*(x-x1):
y0:=g(0):
P,Q:=[x1,f(x1)],[0,y0];
solve((P[1]-Q[1])^2+(P[2]-Q[2])^2=1);
x1:=%[1]:
Q;

# Visualization
A:=plot([f(x),[t,g(t),t=Q[1]..P[1]]], x=-2..2):
B:=plot([P,Q],style=point):
C:=plots:-textplot([[P[],"P"],[Q[],"Q"]], align=right, font=[TIMES,14]):
c:=plottools:-circle(Q,1):
plots:-display(A,B,C,c, scaling=constrained);

                             

 

 

Yesterday I answered the same question only asked in another post (this post disappeared for some reason). Here's my answer:
 

restart;
A__left:=1/C__AO-1/C__AA;
f:=1/C__AO;
A__right:=``(f)*(expand(A__left/f));
expand(A__right); # Check

                               

 

                              

restart;
A__left:=1/C__AO-1/C__AA;
f:=1/C__AO;
A__right:=``(f)*(expand(A__left/f));
expand(A__right); # Check

                                  

 

 

@jrive  For arbitrary real parameters the last line should be

Pabang := evalc(argument(Pab));

Returns 
                   


From help  "For real arguments x, y, the two-argument function arctan(y, x), computes the principal value of the argument of the complex number 
                            x + I y
, so 
           -Pi < arctan(y, x) and arctan(y, x) <= Pi"

The code below implements this process in Maple. As already pointed out by vv, on each new launch, the numbers  N  may be different.

restart;
randomize():
n:=2012:
S:={seq([i,i], i=1..n)}:
for step from 1 to n-2 do
t:=combinat:-randcomb(S, 2);
S:=(S minus t) union {[n+step,2*(t[1][2]+t[2][2])]};
od:
N:=S[1][2]+S[2][2];
N/1000;

 

The problem is that Maple does not implement work with piecewise-functions where the number of variables is greater than 1. For example, Maple cannot convert the sum of such functions into some new piecewise-function. Therefore, we have to do something manually. You have 2 variables  lambda[1]  and  lambda2 . Straight lines  (1 - alpha)*lambda[1] - lambda[2]=0  and  -(1 + alpha)*lambda[1] + lambda[2]=0  divide the entire plane  (lambda[1], lambda2)  into 4 regions  R1, R2, R3, R4. In your example,  alpha=0.01 is very small and therefore the regions  R1  and  R3  will be very narrow. Therefore, for better drawing, I took  alpha=0.3 .We define the functions  U1  and  U2  in terms of these regions, and we define the operations on the functions using procedures (for example for `-` sign we use the procedure  `p-`  below) :
 

restart;
alpha := 0.3;
e1:=(1 - alpha)*lambda[1] - lambda[2]:
e2:=-(1 + alpha)*lambda[1] + lambda[2]:
R1:=e1<=0 and e2<=0;
R2:=e1<=0 and e2>0;
R3:=e1>0 and e2>0;
R4:=e1>0 and e2<=0;
U1 := piecewise(R1,0,R2,0,R3,5,R4,5);
U2 := piecewise(R1,0,R2,5,R3,5,R4,0);
`p-`:=(U1,U2)->piecewise(seq(`if`(type(i,odd),op(i,U1),op(i,U1)-op(i,U2)),i=1..nops(U1)));
U:=`p-`(U1,U2);
A:=plots:-inequal([{e1<=0,e2<=0},{e1<=0,e2>0},{e1>0,e2>0},{e1>0,e2<=0}], lambda[1]=-3..3, lambda[2]=-3..3, optionsfeasible=[[color="Pink"],[color="LightBlue"],[color="LightGreen"],[color="Yellow"]],labels=[lambda[1], lambda[2]]):
B:=plots:-textplot([[2.3,2.3,"R1"],[-2,2,"R2"],[-2.3,-2.3,"R3"],[2,-2,"R4"]]):
plots:-display(A,B);
plot3d(U, lambda[1]=-3..3, lambda[2]=-3..3, numpoints=10000);
 

alpha := .3

 

R1 := `and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0)

 

R2 := .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2]

 

R3 := `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2])

 

R4 := -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2]

 

U1 := piecewise(`and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0), 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], 0, `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2]), 5, -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2], 5)

 

U2 := piecewise(`and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0), 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], 5, `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2]), 5, -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2], 0)

 

`p-` := proc (U1, U2) options operator, arrow; piecewise(seq(`if`(type(i, odd), op(i, U1), op(i, U1)-op(i, U2)), i = 1 .. nops(U1))) end proc

 

piecewise(.7*lambda[1]-lambda[2] <= 0 and -1.3*lambda[1]+lambda[2] <= 0, 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], -5, 0 < .7*lambda[1]-lambda[2] and 0 < -1.3*lambda[1]+lambda[2], 0, 0 < .7*lambda[1]-lambda[2] and -1.3*lambda[1]+lambda[2] <= 0, 5)

 

 

 

 


 

Download piecewise.mw

restart;
sol:=msolve(x^2=-1, 5);
map2(eval, x, [sol]);

                                    sol := {x = 2}, {x = 3}
                                              [2, 3]

restart;
A:=[seq(a||i,i=1..4)];
B:=[seq(b||i,i=1..4)];
Matrix(4,8, {seq((i,2*i-1)=A[i], i=1..4), seq((i,2*i)=B[i], i=1..4)});

                             

 

Use the continuous option:

restart;
F:=int( 1/(1+x^n), x=0..1, continuous);
convert(F, hypergeom);

                                

                              

First 27 28 29 30 31 32 33 Last Page 29 of 290