local L,rn,i,j,k,Res

> erathosthene:=proc(n)
local L,rn,i,j,k,Res;
Res:=[];
for i from 2 to n
do
L[i]:=true
end do;
rn:=floor(sqrt(n));
for i from 2 to rn
do
if L[i] then
for j from 2 to floor(n/i)
do
L[i*j]:=false
end do;
end if;
od;
for i from 2 to n
do
if L[i] then
Res:=[op(Res),i];
end if;
end do;
return Res;
end proc;
(1)
> erathosthene(100);
(2)
> escalier:=proc(a,b,c,d,n)
>
local L;
if n=0 then
L:=[a,b],[c,d]
else
L:=escalier(a,b,(2*a+c)/3,(b+d)/2,n-1),
escalier((2*a+c)/3,(b+d)/2,(a+2*c)/3,(b+d)/2,
n-1),
escalier((a+2*c)/3,(b+d)/2,c,d,n-1);
end if;
return L;
end proc;
(3)
> plot([escalier(0,0,1,1,3)]);
1
0
0
1
>
>
> with(plots);
(4)
> f:=(cos(t)+3)*cos(t/20);
g:=(cos(t)+3)*sin(t/20);
>
h:=sin(t);
(5)
> spacecurve([f,g,h],t=0..200,numpoints=2000,scaling=constrained);
> with(LinearAlgebra); with(plots);
(6)
> planete:=proc(x,y,z,R,c)
local f,g,h;
f:=x+R*cos(theta)*cos(phi);
g:=y+R*cos(theta)*sin(phi);
h:=z+R*sin(theta);
plot3d([f,g,h],phi=0..2*Pi,theta=-Pi/2..Pi/2,scaling=
constrained,color=c);
end proc;
(7)
(7)
> planete(0,0,0,1,red);
>
>
> terre:=proc(x,y,z)
local f,g,h,i,j,k,gamma,R;
R:=1;
gamma:=convert(23,units,degrees,radians);
f:=R*cos(theta)*cos(phi);
g:=R*cos(theta)*sin(phi);
h:=R*sin(theta);
i:=x+f;
j:=y+cos(gamma)*g-sin(gamma)*h;
k:=y+sin(gamma)*g+cos(gamma)*h;
plot3d([i,j,k],phi=0..2*Pi,theta=-Pi/2..Pi/2,scaling=
constrained,color=turquoise);
end proc;
(8)
> terre(0,0,0);
>
>
> eclairee:=proc(x,y,z)
local f,g,h,R;
R:=0.5;
f:=x+R*cos(theta)*cos(phi);
g:=y+R*cos(theta)*sin(phi);
h:=z+R*sin(theta);
plot3d([f,g,h],phi=0..Pi,theta=-Pi/2..Pi/2,scaling=
constrained,color=yellow);
end proc;
(9)
> sombre:=proc(x,y,z)
local f,g,h,R;
R:=0.5;
f:=x+R*cos(theta)*cos(phi);
g:=y+R*cos(theta)*sin(phi);
h:=z+R*sin(theta);
plot3d([f,g,h],phi=Pi..2*Pi,theta=-Pi/2..Pi/2,
scaling=constrained,color=black);
end proc;
(10)
> lune:=proc(x,y,z)
local e,s;
e:=eclairee(x,y,z);
s:=sombre(x,y,z);
display([e,s]);
end proc;
>
(11)
> lune(0,2,0);
>
>
> revolution:=proc()
local L, ter, lun, alpha, x,y,z,rayon,image;
rayon:=2;
L:=[];
ter:=terre(0,0,0);
for alpha from 0 to evalf(2*Pi) by 0.3
do
x:=rayon*cos(alpha);
y:=rayon*sin(alpha);
z:=0;
lun:=lune(x,y,z);
image:=display3d([ter,lun]);
L:=[op(L),image];
end do;
display3d(L,insequence=true,scaling=constrained);
end proc:
> revolution();
>
> revolution2:=proc()
local L, ter, lun, alpha, x,y,z,rayon,image,gamma,
ecl,a,b;
gamma:=convert(23,units,degrees,radians);
rayon:=2;
L:=[];
ter:=terre(0,0,0);
ecl:=plot3d([r,s,0],r=-3..3,s=-3..3,style=
patchnogrid,color=pink);
for alpha from 0 to evalf(2*Pi) by 0.3
do
a:=rayon*cos(alpha);
b:=rayon*sin(alpha);
x:=a;
y:=b*cos(gamma);
z:=b*sin(gamma);
lun:=lune(x,y,z);
image:=display3d([ter,lun,ecl]);
L:=[op(L),image];
end do;
display3d(L,insequence=true,scaling=constrained);
end proc:
> revolution2();