f[x_]:=1./x; a=1;b=2;n=6;
m=n/2;h=((b-a)/n);
Print["Ilp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h]," Tochna ", Log[2.]]
Print["Idp ∼ ", h*(∑_(i=1)^n)f[a+i*h]," Tochna ", Log[2.]]
Print["Icp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h+(h/2)]," Tochna ", Log[2.]]
Print["Itr ∼ ", (h/2)*(f[a]+2(∑_(i=0)^(n-1))f[a+i*h]+f[b])," Tochna ", Log[2.]]
Print["ISimp ∼ ", (h/3)*(f[a]+4(∑_(i=0)^(m-1))f[a+(2i+1)*h]+2(∑_(i=1)^(m-1))f[a+2i*h]+f[b])," Tochna ", Log[2.]]

Проба с увеличаване на точките

f[x_]:=1./x; a=1;b=2;n=7;
m=n/2;h=((b-a)/n);
Print["Ilp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h]," Tochna ", Log[2.]]
Print["Idp ∼ ", h*(∑_(i=1)^n)f[a+i*h]," Tochna ", Log[2.]]
Print["Icp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h+(h/2)]," Tochna ", Log[2.]]
Print["Itr ∼ ", (h/2)*(f[a]+2(∑_(i=0)^(n-1))f[a+i*h]+f[b])," Tochna ", Log[2.]]
Print["ISimp ∼ ", (h/3)*(f[a]+4(∑_(i=0)^(m-1))f[a+(2i+1)*h]+2(∑_(i=1)^(m-1))f[a+2i*h]+f[b])," Tochna ", Log[2.]]

Извод: Симпсън се развали, защото n не е точно

Слагаме n - четно:

f[x_]:=1./x; a=1;b=2;n=8;
m=n/2;h=((b-a)/n);
Print["Ilp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h]," Tochna ", Log[2.]]
Print["Idp ∼ ", h*(∑_(i=1)^n)f[a+i*h]," Tochna ", Log[2.]]
Print["Icp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h+(h/2)]," Tochna ", Log[2.]]
Print["Itr ∼ ", (h/2)*(f[a]+2(∑_(i=0)^(n-1))f[a+i*h]+f[b])," Tochna ", Log[2.]]
Print["ISimp ∼ ", (h/3)*(f[a]+4(∑_(i=0)^(m-1))f[a+(2i+1)*h]+2(∑_(i=1)^(m-1))f[a+2i*h]+f[b])," Tochna ", Log[2.]]

eps=(10^(-10));
1./(2 eps)
(Sqrt[(2./(24 eps))])
(Sqrt[(2./(12 eps))])
((24./(180 eps))^(1/4))

f[x_]:=1./x; a=1;b=2;n=192;
m=n/2;h=((b-a)/n);
Print["Ilp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h]," Tochna ", Log[2.]]
Print["Idp ∼ ", h*(∑_(i=1)^n)f[a+i*h]," Tochna ", Log[2.]]
Print["Icp ∼ ", h*(∑_(i=0)^(n-1))f[a+i*h+(h/2)]," Tochna ", Log[2.]]
Print["Itr ∼ ", (h/2)*(f[a]+2(∑_(i=0)^(n-1))f[a+i*h]+f[b])," Tochna ", Log[2.]]
Print["ISimp ∼ ", (h/3)*(f[a]+4(∑_(i=0)^(m-1))f[a+(2i+1)*h]+2(∑_(i=1)^(m-1))f[a+2i*h]+f[b])," Tochna ", Log[2.]]

Можем да напишем кода за грешката и в по-общ вид:

eps=(10^(-10));
a=1.;b=2;M1=1;M2=2;M4=24;
((
(((b-a))^2)*M1)/(2 eps))
(Sqrt[(((((b-a))^3)M2)/(24 eps))])
(Sqrt[(((((b-a))^3)M2)/(12 eps))])
((((((b-a))^5)M4)/(180 eps))^(1/4))