Exercice 3
| > | restart:Digits:=30:with(plots):with(plottools): |
| > | fI:=t->4/(1+t^2):aI:=0:bI:=1:NI:=20: |
| > | fJ:=t->exp(-t*t):aJ:=-10:bJ:=10:NJ:=20: |
| > |
Question a)
| > | Rectangle_d:=proc(f,a,b,N)
local i,S; S:=0; for i from 1 to N do S:=S+f(a+i*(b-a)/N); od; S:=S*(b-a)/N; end: |
| > |
| > | Question b) |
Calcul approché de I avec 20 Rectangles où
| > | I=Int(fI(t),t=aI..bI); |
| > | I_(approché):=evalf(Rectangle_d(fI,aI,bI,NI)); |
| > | erreur:=evalf(abs(I_(approché)-Pi)); |
| > |
Calcul approché de J avec 20 Rectangles où
| > | J=(Int(fJ(t),t=aJ..bJ))**2; |
| > | J_(approché):=evalf((Rectangle_d(fJ,aJ,bJ,NJ))**2); |
| > | erreur:=evalf(abs(J_(approché)-Pi)); |
| > |
| > | Question c) |
| > | Points_Rd:=proc(f,a,b,N)
local i,S; S:=NULL; for i from 1 to N do S:=S,[i/N,Rectangle_d(f,a,b,i)]; od; [S]; end; |
| > |
| > | plot(Points_Rg(fI,aI,bI,50)); Tracé des points obtenus pour le calcul approché de I |
![[Plot]](images/exo3_8.gif)
| > | plot(Points_Rg(fJ,aJ,bJ,50)); Tracé des points obtenus pour le calcul approché de J |
![[Plot]](images/exo3_9.gif)
| > |
| > | Question d) |
| > | Suite_Rd:=proc(f,a,b,N)
local i,S,suite,delta; delta:=(b-a)/N;S:=NULL; for i from 0 to N-1 do S:=S,polygon([[a+i*delta,0],[a+(i+1)*delta,0],[a+(i+1)*delta,f(a+(i+1)*delta)],[a+i*delta,f(a+(i+1)*delta)]],color=pink,thickness=2); od; S; end: |
| > |
Tracé des rectangels correspondant à l'intégrale I
| > | RdI:=Suite_Rd(fI,aI,bI,NI):GI:=plot(fI,aI..bI,color=black,thickness=3): |
| > | plots[display](RdI,GI); |
![[Plot]](images/exo3_10.gif)
Tracé des rectangels correspondant à l'intégrale J
| > | RdJ:=Suite_Rd(fJ,aJ,bJ,NJ):GJ:=plot(fJ,aJ..bJ,color=black,thickness=3): |
| > | plots[display](RdJ,GJ); |
![[Plot]](images/exo3_11.gif)
| > |
Une petite animation
| > |
| > | Anim_Rd:=proc(t) plots[display](GI,Suite_Rd(fI,aI,bI,trunc(t))); end: |
| > | animate(Anim_Rd,[t],t=1..NI, frames=50); |
![[Plot]](images/exo3_12.gif)
| > |
| > |