Maple
Son bon usage en mathématiques
Philippe Dumas, Xavier Gourdon
Springer-Verlag, 1997
Code Maple du Chapitre 8, Livre second.
# section 1, page 335. conic:=4*x^2+2*x*y+9*y^2+2*x-10*y-9: Disc:=discrim(conic,y); x0:=op(1,{solve(Disc,x)}); subs(x=x0,conic): y0:=op(1,{solve(",y)}); sys:={conic,y-y0=t*(x-x0)}; {solve(sys,{x,y})}: param:=op(select(has,",t)); trange:=-10..10: krange:=-5..5: window:=[-4..2,-3..3]: conicplot:=plot(subs(param,[x,y,t=trange]),color=red): linesetplot:=plot({seq([x0+lambda,y0+k/4*lambda,lambda=-5..5], k=krange)},view=window,color=blue): plots[display]({conicplot,linesetplot},scaling=constrained); f:=2*x^4+y^4-3*x^2*y-2*y^3+y^2: d:=degree(f,{x,y}): F:=collect(T^d*subs(x=X/T,y=Y/T,f),{X,Y,T},distributed): sys:={seq(diff(F,i),i={X,Y,T})}: solve(sys,{X,Y,T}); f1:=collect(subs(x=x1,y=1+y1,f),{x1,y1},distributed): seq(select(proc(expr) degree(expr,{x1,y1})=k end,f1),k=0..d); lemniscate:=(x^2+y^2)^2-a^2*(x^2-y^2): circle:=x^2+y^2-2*t*(x-y): solve({lemniscate,circle},{x,y}); Lemniscate:=numer(subs(x=X/T,y=Y/T,lemniscate)): Circle:=numer(subs(x=X/T,y=Y/T,circle)): solve({Lemniscate,Circle},{X,Y,T}); l:=1: line:=x*sin(phi)^2+y*cos(phi)^2-l*cos(phi)^2*sin(phi)^2: diffline:=diff(line,phi): sol:=combine(solve({line,diffline},{x,y}),trig): arc:=subs(sol,[x,y,phi=0..Pi/2]): paramline:=[arc[1]+t*cos(phi)^2,arc[2]-t*sin(phi)^2,t=-1..1]: arcplot:=plot(arc,colour=red,thickness=2): linesetplot:=plot({seq(subs(phi=k/20*Pi/2,paramline),k=0..20)}, view=[-0.2..1.2,-0.2..1.2],colour=blue): plots[display]({linesetplot,arcplot}); # exercice 8.5, page 348. p:=10+cos(3*phi): line:=x*cos(phi)+y*sin(phi)=p: diffline:=diff(line,phi): sol:=combine(solve({line,diffline},{x,y}),trig): envelope:=[op(2,op(select(has,sol,x))), op(2,op(select(has,sol,y))),phi=0..2*Pi]: plot(envelope,scaling=constrained,axes=NONE); # fin exercice 8.5. # section 2, page 350. # exercice 8.8, page 350. X:=(t+1)/(1+2*t+2*t^2): Y:=(t^2+1)/(1+2*t+2*t^2): sys:={numer(x-X),numer(y-Y)}; GB:=grobner[gbasis](sys,[t,x,y],plex); equ:=op(nops("),"); # fin exercice 8.8. # exercice 8.9, page 352. conic:=x^2+4*x*y-9*y^2+3*x-5*y-1: S:=[solve(select(proc(z) degree(z,{x,y})=2 end,conic),{x,y})]; # fin exercice 8.9. # section 4, page 354. # probleme page 354. P:=[(a+r*cos(v))*cos(u),(a+r*cos(v))*sin(u),r*sin(v)]; domain:=u=-Pi..Pi,v=-Pi..Pi; normalizer:=readlib(`combine/trig`): illustration:=a=2,r=1: PP:=subs(illustration,P): surface:=plot3d(PP,domain,scaling=constrained,color=blue): normalizer:=readlib(`combine/trig`): # sphere normalizer:=proc(expr) # pseudo-sphere normal(convert(expr,tan),expanded) end: normalizer:=proc(expr) # hyperbolic paraboloid collect(expr,{u,v},normal) end: normalizer:=proc(expr) # circular cone collect(expr,v,readlib(`combine/trig`)) end: # fin probleme. # section 5, page 358. # exercice 8.1, page 358. R:=1/(x^2+y): poly:=-3*x^2+10*x-3: yy:=poly^(1/2): RR:=subs(y=yy,R); conic:=y^2-poly: Disc:=discrim(conic,y): x0:=op(1,{solve(Disc,x)}): subs(x=x0,conic): y0:=op(1,{solve(",y)}): sys:={conic,y-y0=t*(x-x0)}: {solve(sys,{x,y})}: param:=op(select(has,",t)); student[changevar](op(select(has,param,x)),Int(RR,x),t): map(simplify,",radical,symbolic); # fin exercice 8.1. # exercice 8.2, page 359. eq:=x^2*y^2-x*y*(x+y)+x^2-y^2: Eq:=numer(subs(x=X/T,y=Y/T,eq)); singular:=[solve({seq(diff(Eq,i),i={X,Y,T})},{X,Y,T})]; conic:=A*x^2+2*B*x*y+C*y^2+2*D*x+2*E*y+F: Conic:=numer(subs(x=X/T,y=Y/T,conic)): sys:={seq(subs(i,Conic),i=singular)}: inc:={A,B,C,D,E,F}: subs(solve(sys,inc),Conic); hyperbola:=subs(T=1,X=x,Y=y,E=D,B=1/2,D=t/2,"): solve({eq,hyperbola},{x,y}); # fin exercice 360. # exercice 8.3, page 360. line:=collect((x+c-2*a*cos(t))^2+(y-2*a*sin(t))^2 -(x-c)^2-y^2,{x,y}): diffline:=diff(line,t): sol:=solve({line,diffline},{x,y}); solve(subs(cos(t)=C,sin(t)=S,sol),{C,S}); collect(numer(subs(",C^2+S^2-1)),{x,y},factor); aa:=1: cc:=2^(1/2): curve:=subs(sol,a=aa,c=cc,[x,y,t=0..2*Pi]): r:=-cc-2*aa..cc+2*aa: window:=[r,r]: kmax:=10: curveplot:=plot(curve,view=window,color=red): circleplot:=plot([-cc+2*aa*cos(t),2*aa*sin(t) ,t=0..2*Pi],view=window,color=blue): paramline:=subs(a=aa,c=cc,[curve[1]+coeff(line,y)*u, curve[2]-coeff(line,x)*u,u=-1..1]): lineplot:=plot({seq(subs(t=2*Pi*k/kmax,paramline),k=0..kmax)}, view=window,color=green): plots[display]({curveplot,circleplot,lineplot}, scaling=constrained); # fin exercice 8.3. # exercice 8.4, page 361. p:=cos(phi/3+Pi/3); phimin:=0: phimax:=3*Pi: kmax:=40: window:=[-2..2,-2..2]: line:=x*cos(phi)+y*sin(phi)-p; diffline:=diff(line,phi): sol:=combine(solve({line,diffline},{x,y}),trig); arc:=subs(sol,[x,y,phi=phimin..phimax]): paramline:=[arc[1]-t*sin(phi),arc[2]+t*cos(phi),t=-1..1]: arcplot:=plot(arc,color=red,thickness=2): linesetplot:=plot({seq(subs(phi=phimin+k/kmax*(phimax-phimin), paramline),k=0..kmax)},view=window,color=blue): plots[display]({linesetplot,arcplot},scaling=constrained); # fin exercice 8.4. # exercice 8.8, page 363. X:=(t^2+1)^2/(t^4+3*t^2+1): Y:=a*t*(t^2+1)/(t^4+3*t^2+1): Tau:=-(t^2+1)/t: sys:={numer(x-X),numer(y-Y),numer(tau-Tau)}: grobner[gbasis](sys,[t,tau,x,y],plex); XX:=3/4*cos(theta)+1/4*cos(3*theta): YY:=3/4*sin(theta)-1/4*sin(3*theta): X:=subs(tan(theta/2)=t,convert(expand(XX),tan)): Y:=subs(tan(theta/2)=t,convert(expand(YY),tan)): X,Y; XX:=3/4*cos(theta)+1/4*cos(3*theta): YY:=3/4*sin(theta)-1/4*sin(3*theta): X:=subs(cos(theta)=c,sin(theta)=s,expand(XX)): Y:=subs(cos(theta)=c,sin(theta)=s,expand(YY)): X,Y; sys:={numer(x-X),numer(y-Y),c^2+s^2-1}; GB:=grobner[gbasis](sys,[c,s,x,y],plex): equ:=op(nops(GB),GB); # fin exercice 8.8. # exercice 8.9, page 364. conic:=x^2+4*x*y-9*y^2+3*x-5*y-1: S:=[solve(select(proc(z) degree(z,{x,y})=2 end,conic),{x,y})]: s:=S[1]: s1:=map(proc(z) op(1,z)-op(2,z) end,s): s2:=select(has,s1,{x,y}): s3:=op(s2): sys:={conic,s3=t}; param:=solve(sys,{x,y}); conic:=3*x^2+3*x*y+y^2-2*x+6*y+1: S:=[solve(select(proc(z) degree(z,{x,y})=2 end,conic),{x,y})]: s:=S[1]: s1:=map(proc(z) op(1,z)-op(2,z) end,s): s2:=select(has,s1,{x,y}): s3:=op(s2): sys:={conic,s3=t}; param:=solve(sys,{x,y}); # fin exercice 8.9. # exercice 8.9, page 365. p:=r+a*cos(phi): a:=1: n:=3; plot([seq(subs(r=k/n,p),k=1..floor(2.5*n))],phi=0..2*Pi, thickness=map(proc(expr) if member(expr,{1,2}) then 3 else 0 fi end,[seq(k/n,k=1..floor(2.5*n))]), coords=polar,scaling=constrained); pic[deltoid]:=plot(envelope,title=cat(`p=`,convert(p,string)), scaling=constrained,thickness=2): pic[folium]:=plot(p,phi=0..2*Pi,coords=polar, scaling=constrained,thickness=0): plots[display]({pic[deltoid],pic[folium]}); # fin exercice 8.10. # exercice 8.11, page 366. eq[cone]:=x^2+y^2-tan(theta)^2*(z-h)^2: eq[plane]:=z*sin(phi)-x*cos(phi): coordchange:=x=sin(phi)*X-cos(phi)*Z, y=Y, z=cos(phi)*X+sin(phi)*Z: neweq[plane]:=collect(subs(coordchange,eq[plane]),{X,Y,Z}, readlib(`combine/trig`)); neweq[cone]:=collect(subs(coordchange,eq[cone]),{X,Y,Z}); neweq[conic]:=collect(subs(Z=0,neweq[cone]),{X,Y}); centersys:={diff(neweq[conic],X),diff(neweq[conic],Y)}; centersol:=solve(centersys,{X,Y}); center:=subs(centersol,{X0=X,Y0=Y}); newneweq[conic]:=collect(subs(subs(center,{X=X0+xi,Y=Y0+eta}), neweq[conic]),{xi,eta},normal); conesubs:={x=rho*cos(omega),y=rho*sin(omega),z=h+rho/tan(theta)}: param[cone]:=subs(conesubs,[x,y,z]): conicsubs:=solve({subs(conesubs,eq[plane])},rho); param[conic]:=subs(subs(conicsubs,conesubs),[x,y,z]): examplesubs:={phi=Pi/3,theta=Pi/4,h=1}: r:=-3..3: window:=[r,r,r]: picture[cone]:=plot3d(subs(examplesubs,param[cone]), rho=-2..1,omega=0..2*Pi,color=blue): picture[conic]:=plots[spacecurve](subs(examplesubs,param[conic]), omega=0..2*Pi,thickness=3,color=red,view=window): plots[display]({seq(picture[i],i={cone,conic})}, scaling=constrained,orientation=[150,80]); # fin exercice 8.11.