Maple
Son bon usage en mathématiques

Philippe Dumas, Xavier Gourdon

Springer-Verlag, 1997

Code Maple du Chapitre 4, Livre second.



# section 1, page 191.

f2:=(x^2-y^2)/(x^2+y^2):
plot3d(f2,x=-1..1,y=-1..1,axes=normal,orientation=[65,80]);

plot3d([rho*cos(theta),rho*sin(theta),cos(2*theta)],
        rho=0..1,theta=0..2*Pi,grid=[3,65],orientation=[65,80],
                                scaling=constrained,axes=normal);

f3:=(x*y)^2/((x*y)^2+(x-y)^2):
plot3d(f3,x=-1..1,y=-1..1,orientation=[60,80]);

g3:=collect(combine(normal(
          subs(x=rho*cos(theta),y=rho*sin(theta),f3)),trig),rho);

plot3d([rho*cos(theta),rho*sin(theta),g3],rho=0..1,theta=0..2*Pi,
                  grid=[10,100],orientation=[70,80],axes=normal);

plots[contourplot]([rho*cos(theta),rho*sin(theta),g3],
                   rho=0..1,theta=0..2*Pi,grid=[10,100],
                      contours=[seq(k/10,k=0..10)],labels=[x,y]);

solve(subs(rho^2=Rho,g3)=cos(alpha),Rho):
factor(");

series(1/sin(t)-1/t,t);

series(1/sin(t)-1/t,t,8);

series(x^sin(x),x);

asympt(Sum(1/k,k=1..n),n);

asympt(sum(1/k,k=1..n),n); 
asympt(Psi(n+1)+gamma,n);

readlib(eulermac)(1/k,k);

# section 2, page 200.

# exercice 4.7, page 201.
series(A/B,x,n);
# fin exercice 4.7.

# section 3, page 203.

# probleme page 203.
Digits:=12:
Pif:=evalf(Pi):
convert(Pif,confrac,red);

seq(red[i],i=1..5);

algtoconfrac((1+sqrt(5))/2,10);

algtoconfrac(sqrt(2)+sqrt(3),20);

algtoconfrac(sqrt(15),10);
# fin probleme.

# section 4, page 208.

# probleme page 209.
plot({tan(x),x},x=-0.5..5*Pi,scaling=constrained,
                                       view=[-0.5..5*Pi,-3..17]);

assume(n,integer):
equ[1]:=subs(x=(2*n+1)*Pi/2+u,tan(x)=x):
equ[2]:=convert(equ[1],sincos):
equ[3]:=expand(equ[2]):
Order:=10:
equ[4]:=map(series,equ[3],u);

da:=n*Pi+Pi/2+subs(t=1/n,solve(subs(n=1/t,equ[4]),u));
# fin probleme.

# section 5, page 212.

# exercice 4.1, page 212.
t:=y/x^2:
f4:=normal(t/(1+t^2)):
plot3d(f4,x=-1..1,y=-1..1,grid=[41,41],
                               axes=normal,orientation=[-10,80]);

f5:=exp(y*ln(x)):
plot3d(f5,x=0.05..1,y=-1..1,axes=normal,orientation=[170,80]);

plots[contourplot]([x,y,f5],x=0.05..1,y=-1..1,grid=[20,41],
    contours=[seq(k/10,k=1..20)],labels=[x,y],view=[0..1,-1..1]);

f6:=sin(x-y)*sin(x+y)/(x^2-y^2):
plot3d(f6,x=-Pi..Pi,y=-Pi..Pi,grid=[41,41],
                                axes=boxed,orientation=[-15,70]);

normal(subs(x=(X+Y)/sqrt(2),y=(X-Y)/sqrt(2),f6));

f7:=(1-x)*(1-y)/(1-x*y):
F:=solve(f7=lambda,y);

level[-1]:=plot(2-x,x=0..2,y=0..2):
for k from -10 to -3 do
  level[k/2]:=plot(subs(lambda=k/2,F),x=0..2,y=0..2)
od:
for k from -1 to 10 do
  level[k/2]:=plots[display]({
            plot(subs(lambda=k/2,F),x=0..1/(1+k/2)-0.01,y=0..2),
            plot(subs(lambda=k/2,F),x=1/(1+k/2)+0.01..2,y=0..2)})
od:
plots[display]({seq(level[k/2],k=-10..10)});
# fin exercice 4.1.

# exercice 4.2, page 214.
series(sin(x)*ln(tan(x)),x,12);

series(ln(1/x)^(1/ln(1/x)),x,10);
asympt(exp(ln(u)/u),u);
subs(u=ln(1/x),");
# fin exercice 4.2.

# exercice 4.3, page 214.
asympt(sum(k^(1/2),k=1..n),n);

sum(1/(k^2+1),k=0..n);

asympt(",n);

asympt(Sum(1/(k^2+1),k=0..n),n);

readlib(eulermac)(1/(k^2+1),k);

asympt(Sum(k*ln(k),k=2..n),n);
# fin exercice 4.3.

# exercice 4.4, page 216.
k:=2:
f:=sqrt(x*(1-x))*sin((1/x/(1-x))^k):
plot(f,x=0..1,numpoints=100,scaling=constrained);

k:=1:
l:=4:
f:=x^k*sin(1/x^l):
plot(f,x=-1..1,numpoints=200,scaling=constrained);
# fin exercice 4.4.

# exercice 4.5, page 216.
a:=1/k/(2*k+1):
u0:=subs(k=2*l,a):
u1:=subs(k=2*l+1,-a):
S1:=subs(l=0,u1)+sum(u0+u1,l=1..m):
da1:=asympt(S1,m);

S0:=S1+subs(k=2*m+1,a):
da0:=asympt(S0,m);

DA0:=subs(m=n/2,da0):
DA1:=subs(m=(n-1)/2,da1):
DA:=asympt((DA0+DA1)/2+(-1)^n*(DA0-DA1)/2,n);

evalf(subs(n=1000,remove(has,DA,O))-Sum((-1)^k*a,k=1..1000),25);

da1:=select(has,asympt(S1,m),m);
da0:=select(has,asympt(S0,m),m);
# fin exercice 4.5.

# exercice 4.6, page 218.
Sum(ln(1+1/k^4),k=1..n):
asympt(",n):
map(radnormal,");

select(has,",n):
asympt(exp("),n);

asympt(Sum(ln(1+k/n^2),k=1..n),n);

asympt(exp("),n);

sum(cos(k*x)/2^k,k=0..n);

readlib(eulermac)(k/ln(k),k);

subs(Lnk=ln(k),asympt(-Ei(1,-2*Lnk),Lnk));

combine(subs(k=n,"),exp);
# fin exercice 4.6.

# exercice 4.7, page 220.
squo:=proc(a,b,n::nonnegint,x::name,r::name)
  local A,B,ldegreeB,lcoeffB,ldegreeA,k,lcoeffA,term,l;
  B:=collect(b,x,Normalizer);
  if B=0 then 
    ERROR(`squo expects its second argument b to be a non-zero 
                                     polynomial, but received`,b)
  fi;
  ldegreeB:=ldegree(B,x);
  if ldegreeB=FAIL or ldegreeB>0 then 
    ERROR(`squo expects its second argument b to be a polynomial
                  with a non-zero constant term, but received`,b)
  fi;
  lcoeffB:=coeff(B,x,0);
  A:=collect(a,x,Normalizer);
  ldegreeA:=ldegree(A,x);
  for k while ldegreeA4 then r:=A fi;
  add(term[l],l=1..k-1)
end: # squo

squo(1,convert(series(cos(x),x,10),polynom),10,x);

Normalizer:=readlib(`combine/trig`):
squo(1-2*x*cos(theta)+x^2*cos(2*theta),
                                 (1-2*x*cos(theta)+x^2)^2,4,x,r);

inv:=proc(b,n,x)
  local B,y,k;
  if type(b,series) then 
    B:=convert(b,polynom)
  else
    B:=b
  fi;
  y:=1/coeff(B,x,0);
  readlib(ilog); 
  for k to ilog[2](n)+1 do
    y:=series((2-B*y)*y,x,2^k+2);
    y:=convert(y,polynom); 
  od;
  series(y,x,n+1)
end: # inv
inv(series(cos(x),x,101),101,x);
series(1/cos(x),x,101);
# fin exercice 4.7.