The estimation error is strangely obtained from Simpson’s 1/3 rule
Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error);Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error); Hello, I am looking for the estimation error of Simpson’s rule of thirds. When dx is 1.01, the integral value is 2908800 and the error is 0.01, but the estimation error is 5.5567e-09. Where did it go wrong?
clc; clear all; close all;
a = -1.93317553181561E-24;
b = 3.788630291530091e-21;
c = -2.3447910280083294e-18
d = -0.019531249999999518;
e = 18.74999999999999
fun = @(t) a.*t.^5 + b.*t.^4 + c.*t.^3 + d.*t.^2+e.*t
x = 0:0.1:960;
fx =fun(x);
n=960;
dx=1.01
int=0;
for i =1:n
plot(x, fx,’k’,’linewidth’,2);
mid=((i-1)+i)/2;
fx_mid = fun(mid);
fx_left = fun(i-1);
fx_right = fun(i);
area_temp = dx/6*(fx_left +4*fx_mid+fx_right);
int = int + area_temp;
x_segment = linspace(i-1, i,100);
Px = fx_left * ((x_segment-mid).*(x_segment-i))/((i-1-mid)*(i-1-i))…
+ fx_mid*((x_segment-i+1)).*(x_segment-i)/((mid-i+1)*(mid-i))…
+ fx_right * ((x_segment-i+1).*(x_segment-mid))/((i-i+1)*(i-mid));
area(x_segment,Px); hold on;
end
C=480;
E_a = -((960.^5)/(2880.*1.01.^4)).*(a.*120.*C+24.*b);%Is there a problem here?
disp(‘E_a’);
disp(E_a);
disp(int);
int_true = 2880000
rel_error=norm(int_true-int)/norm(int_true);
disp(‘rel_error’);
disp(rel_error); simpson’s 1/3 rule, estimation error MATLAB Answers — New Questions