>
 

>
 

> Rect:=proc(f,N,a,b)
local nbrect,i,S,x,n;
nbrect:=[seq(i,i=1..N)]:
S:=seq(student[leftbox](f(x),x=a..b,n),n=nbrect):
plots[display](S,insequence=true);
end:
 

>
 

> student[leftbox](cos(x),x=0..Pi,10);
 

Plot_2d
 

> Rect(x->x^2,100,0,1);
 

Plot_2d
 

> airerect:=proc(f,N,a,b)
local k:
Sum((b-a)/N*f(a+k*(b-a)/N),k=1..N)=evalf(sum((b-a)/N*f(a+k*(b-a)/N),k=1..N));
end:
 

> airerect(x->x^2,1000,0,1);
 

Sum(`+`(`*`(`/`(1, 1000000000), `*`(`^`(k, 2)))), k = 1 .. 1000) = .3338335000 (1)
 

> Trap:=proc(f,N,a,b)
 

> local TV,TR,k,av,ap,T,C;
 

> TV:=NULL: TR:=NULL:
 

> for k from 0 to N-1 do
 

> av:=a+k*(b-a)/N:
 

> ap:=a+(k+1)*(b-a)/N;
 

> T:=[[av,0],[av,f(av)],[ap,f(ap)],[ap,0]]:
 

> TV:=TV,plot(T,filled=true,color=wheat):
 

> TR:=TR,plot(T,color=black,thickness=2):
 

> od:
 

> C:=plot(f(x),x=a..b,thickness=3):
 

> plots[display](TV,TR,C);
 

> end:
 

>
 

> Trap(x->cos(x),10,0,Pi);
 

Plot_2d
 

> Trapanim:=proc(f,N,a,b)
 

> local nbtrap,i,S,n;
 

> nbtrap:=[seq(i,i=1..N)]:
 

> S:=seq(Trap(f,n,a,b),n=nbtrap):
 

> plots[display](S,insequence=true);
 

> end:
 

>
 

> Trapanim(x->cos(x),20,0,2*Pi);
 

Plot_2d
 

> Sims:=proc(f,a,b,dx)
local aa,S;
aa:=a;
S:=0;
while(evalf(aa)<evalf(b)) do
 S:=S+(f(aa)+4*f(aa+0.5*dx)+f(aa+dx))*dx/6.;
 aa:=aa+dx;
od;
S;
end:

 

>
 

> Sims(x->sin(x),0,Pi,0.0001);
 

1.999999999973015128606560761318298418192924673017057388160841117097355523846809544655922413037065226
1.999999999973015128606560761318298418192924673017057388160841117097355523846809544655922413037065226
(2)
 

>
 

> Riem:=proc(f,a,b)
 

> local k;
 

> Limit(Sum(((b-a)/n)*f(a+k*(b-a)/n),k=1..n),n=infinity)=limit(sum(((b-a)/n)*f(a+k*(b-a)/n),k=1..n),n=infinity);
 

> end:
 

>
 

> Riem(x->sin(x),0,Pi);
 

Limit(Sum(`/`(`*`(Pi, `*`(sin(`/`(`*`(k, `*`(Pi)), `*`(n))))), `*`(n)), k = 1 .. n), n = infinity) = 2 (3)
 

> airetrap:=proc(f,N,a,b)
 

> local k:
 

> (b-a)/N*((f(a)+f(b))/2+Sum(f(a+k*(b-a)/N),k=1..N-1))=evalf((b-a)/N*((f(a)+f(b))/2+Sum(f(a+k*(b-a)/N),k=1..N-1)));
 

> end:
 

>
 

> evalf(Pi);
 

3.141592654 (4)
 

> 4*airerect(x->sqrt(1-x^2),10000,0,1);
 

`+`(`*`(4, `*`(Sum(`+`(`*`(`/`(1, 100000000), `*`(`^`(`+`(100000000, `-`(`*`(`^`(k, 2)))), `/`(1, 2))))), k = 1 .. 10000)))) = 3.141391481 (5)
 

> 4*airetrap(x->sqrt(1-x^2),10000,0,1);
 

`+`(`/`(1, 5000), `*`(`/`(1, 2500), `*`(Sum(`+`(`*`(`/`(1, 10000), `*`(`^`(`+`(100000000, `-`(`*`(`^`(k, 2)))), `/`(1, 2))))), k = 1 .. 9999)))) = 3.141591478 (6)
 

> mini:=proc(u,p)
 

> local k;
 

> k:=0;
 

> while (evalf((u^(2*k+3))/(2*k+3)))>(10^(-p)) do  
 

> k:=k+1;
 

> od:
 

> end:
 

>
 

> greg:=proc(n,a,p)
 

> local S,k;
 

> S:=0;  
 

> for k from 0 to n+1/2 do  
 

> S:=S+evalf(((-1)^k*a^(2*k+1))/(2*k+1),p+1);
 

> od;
 

> S;
 

> end:
 

>
 

> mini(1/5,100);
 

69 (7)
 

> Digits:=100:
 

> 4*(4*greg(69,1/5,100)-greg(69,1/239,100));
 

>
 

3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117064
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117064
(8)
 

> 4*(4*greg(69,1/5,100)-greg(69,1/239,100))-evalf(Pi,100);
 

>
 

-0.4e-98 (9)
 

>