II Formules de quadrature et leur ordre
IV Etude de l'erreur d'une méthode de quadrature
V Exemples de calcul numérique de l'ordre
s | ordre | b1 | b2 | b3 | b4 | b5 | b6 | b7 | nom |
1 | 1 | 1 | rectangle | ||||||
1 | 2 | 1 | pt. milieu | ||||||
2 | 2 | trapèze | |||||||
3 | 4 | Simpson | |||||||
4 | 4 | Newton | |||||||
5 | 6 | Boole | |||||||
6 | 6 | Boole | |||||||
7 | 8 | Weddle |
%%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% Iexa = log(2); alpha = 1; beta = 2; N = 4; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Irg = 0.0; for i = 1:N Irg = Irg + h*f(x(i)); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Irg Erg = abs(Iexa - Irg) %%%%%%%%%%%%%%%%%%%%%%%%
Irg = 7.595238095e-01 Erg = 6.637662896e-02
%%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% Iexa = log(2); alpha = 1; beta = 2; N = 4; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Itr = 0.0; for i = 1:N Itr = Itr + h*(0.5*f(x(i)) + 0.5*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Itr Etr = abs(Iexa - Itr)
Itr = 6.970238095e-01 Etr = 3.876628964e-03
%%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% Iexa = log(2); alpha = 1; beta = 2; N = 4; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Isi = 0.0; for i = 1:N Isi = Isi+h*(1/6*f(x(i))+2/3*f((x(i)+x(i+1))/2)+1/6*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Isi Es = abs(Iexa - Isi)
Isi = 6.931545307e-01 Esi = 7.350094585e-06
clear all; Iexa = sin(2); alpha = 0; beta = 2; f = inline('cos(x)','x'); %-------------------------- %-------------------------- % Méthode des trapèzes %-------------------------- %-------------------------- s = 2; for j = 1:1:10 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; fetr(j) = log10(N*(s-1) +1); h = (beta - alpha)/N; x = [alpha:h:beta]; %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Itr=0.0; for i = 1:N Itr = Itr + h*(1/2*f(x(i)) + 1/2*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Etr(j) = log10(abs(Iexa - Itr)) ; end %-------------------------- %-------------------------- % Méthode de Simpson %-------------------------- %-------------------------- s = 3; for j=1:1:10 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; fesi(j) = log10(N*(s-1) +1); h = (beta - alpha)/N; x = [alpha:h:beta]; %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Isi = 0.0; for i = 1:N Isi = Isi+h*(1/6*f(x(i))+2/3*f((x(i)+x(i+1))/2)+1/6*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Esi(j) = log10(abs(Iexa - Isi)) ; end %-------------------------- %-------------------------- % Méthode de Boole (s=6) %-------------------------- %-------------------------- s = 6; for j = 1:1:8 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; febo(j) = log10(N*(s-1) +1); h = (beta - alpha)/N; x = [alpha:h:beta]; %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Ibo = 0.0; for i = 1:N Ibo = Ibo + h*(19/288*f(x(i)) + 75/288*f(x(i)+h/5) + 50/288*f(x(i)+(2*h/5)) + 50/288*f(x(i)+ (3*h/5)) + 75/288*f(x(i)+ (4*h/5)) + 19/288*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Ebo(j) = log10(abs(Iexa - Ibo)) ; plot(fetr, Etr, 'k-.', fesi, Esi, 'k-+', febo, Ebo, 'k-*') legend('Trapèzes', 'Simpson', 'Boole (s=6)') xlabel('log10(Erreur)'); ylabel('log10(fe)'); title('Le travail fe en fonction de l''erreur'); end
clear all; fid = 1; fmt = '%% %10d %20.9e %20.9e %20.9e %20.9e \n'; for j = 1:2:17 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; Iexa = log(2); alpha = 1; beta = 2; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Irg = 0.0; for i = 1:N Irg = Irg + h*f(x(i)); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% %Irg Erg = abs(Iexa - Irg) ; Erg1 = abs(Iexa - Irg)/h ; Erg2 = abs(Iexa - Irg)/h^2 ; %%%%%%%%%%%%%%%%%%%%%%%% fprintf(fid, fmt, j, Irg, Erg, Erg1, Erg2); end
j Irg Erg Erg/h Erg/h^2
1 8.333333333e-01 1.401861528e-01 2.803723055e-01 5.607446111e-01 3 7.253718504e-01 3.222466981e-02 2.577973585e-01 2.062378868e+00 5 7.010207083e-01 7.873527709e-03 2.519528867e-01 8.062492374e+00 7 6.951041202e-01 1.956939668e-03 2.504882775e-01 3.206249952e+01 9 6.936357002e-01 4.885196685e-04 2.501220703e-01 1.280625000e+02 11 6.932692658e-01 1.220852137e-04 2.500305176e-01 5.120625000e+02 13 6.931776991e-01 3.051850945e-05 2.500076294e-01 2.048062500e+03 15 6.931548100e-01 7.629452736e-06 2.500019072e-01 8.192062496e+03 17 6.931490879e-01 1.907352286e-06 2.500004788e-01 3.276806276e+04
clear all; fid = 1; fmt = '%% %10d %12.9e %12.9e %12.9e %12.9e %12.9e \n'; for j = 1:2:17 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; Iexa = log(2); alpha = 1; beta = 2; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Itr = 0.0; for i = 1:N Itr = Itr + h*(0.5*f(x(i)) + 0.5*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Etr = abs(Iexa - Itr) ; Etr1 = abs(Iexa - Itr)/h ; Etr2 = abs(Iexa - Itr)/h^2 ; Etr3 = abs(Iexa - Itr)/h^3 ; %%%%%%%%%%%%%%%%%%%%%%%% fprintf(fid, fmt, j, Itr, Etr, Etr1 , Etr2, Etr3); end
j Itr Etr Etr/h Etr/h^2 Etr/h^3
1 7.08333e-01 1.51862e-02 3.03723e-02 6.07446e-02 1.21489e-01 3 6.94122e-01 9.74670e-04 7.79736e-03 6.23789e-02 4.99031e-01 5 6.93208e-01 6.10277e-05 1.95289e-03 6.24924e-02 1.99976e+00 7 6.93151e-01 3.81467e-06 4.88278e-04 6.24995e-02 7.99994e+00 9 6.93147e-01 2.38418e-07 1.22070e-04 6.25000e-02 3.20000e+01 11 6.93147e-01 1.49012e-08 3.05176e-05 6.25000e-02 1.28000e+02 13 6.93147e-01 9.31321e-10 7.62938e-06 6.24999e-02 5.11999e+02 15 6.93147e-01 5.82108e-11 1.90745e-06 6.25033e-02 2.04811e+03 17 6.93147e-01 3.63654e-12 4.76648e-07 6.24752e-02 8.18875e+03
clear all; fid = 1; fmt = '%% %3d %12.5e %12.5e %12.5e %12.5e %12.5e \n'; for j = 1:1:10 %%%%%%%%%%%%%%%%%%%%%%%% % Donnees %%%%%%%%%%%%%%%%%%%%%%%% N = 2^j; Iexa = log(2); alpha = 1; beta = 2; h = (beta - alpha)/N; x = [alpha:h:beta]; f = inline('1/x','x'); %%%%%%%%%%%%%%%%%%%%%%%% % Corps du programme %%%%%%%%%%%%%%%%%%%%%%%% Isi = 0.0; for i = 1:N Isi = Isi + h*(1/6*f(x(i)) + 2/3*f((x(i) + x(i+1))/2) + 1/6*f(x(i+1))); end %%%%%%%%%%%%%%%%%%%%%%%%%% % Affichage des resultats %%%%%%%%%%%%%%%%%%%%%%%%%% Esi = abs(Iexa - Isi) ; Esi3 = abs(Iexa - Isi)/h^3 ; Esi4 = abs(Iexa - Isi)/h^4 ; Esi5 = abs(Iexa - Isi)/h^5 ; %%%%%%%%%%%%%%%%%%%%%%%% fprintf(fid, fmt, j, Isi, Esi, Esi3 , Esi4, Esi5); end
j Isi Esi Esi/h^3 Esi/h^4 Esi/h^5
1 6.93254e-01 1.06788e-04 8.54302e-04 1.70860e-03 3.41721e-03 2 6.93155e-01 7.35009e-06 4.70406e-04 1.88162e-03 7.52650e-03 3 6.93148e-01 4.72259e-07 2.41797e-04 1.93437e-03 1.54750e-02 4 6.93147e-01 2.97299e-08 1.21774e-04 1.94838e-03 3.11740e-02 5 6.93147e-01 1.86151e-09 6.09979e-05 1.95193e-03 6.24619e-02 6 6.93147e-01 1.16398e-10 3.05130e-05 1.95283e-03 1.24981e-01 7 6.93147e-01 7.27574e-12 1.52583e-05 1.95307e-03 2.49992e-01 8 6.93147e-01 4.54081e-13 7.61822e-06 1.95026e-03 4.99268e-01 9 6.93147e-01 2.80886e-14 3.76999e-06 1.93024e-03 9.88281e-01 10 6.93147e-01 2.66454e-15 2.86102e-06 2.92969e-03 3.00000e+00