next up previous contents
Next: Constructions Up: Les procédures Previous: Les procédures

Syntaxe d'une procédure

proc(arg1:type1,arg2:type2,arg3:type3...)
local y1,y2;
global z1,z2,z3;
options opt1,opt2...;

CORPS DE LA PROCEDURE

RETURN(resultats);
	ou 
resultats:=

end:

Les options possibles dans une procédures sont : remember,builtin, system, operator, arrow, angle, trace et copyright.

exercice950

Correction:
> s:=proc(n:nonnegint)
> local x,a;
> a:=series(arctan(x),x=0,n);
> a:=convert(a,polynom);
> a:=16*subs(x=1/5,a)-4*subs(x=1/239,a);
> end;
>
> for i to 5 do
> evalf(s(10*i)-Pi,100);
> od;

exercice964

Correction:
> # 1) Solution:
> u:=proc(n:nonnegint)
> option remember;
> 2 - sqrt(4-u_(n-1));
> end;
> u(0):=3;
>
> v:=proc(n:nonnegint)
> option remember;
> 3 * 2^(n-1)*sqrt(v(n-1));
> end;
> # 2) Solution:
> for i to 5 do
> evalf(v(30)-Pi,i*10);
> od;



Jean-Philippe Chancelier
Mon Nov 25 13:38:07 MET 1996