COMPOSITE Simplons Rule Inputs are endpoints a and b and and

COMPOSITE Simplon\'s Rule. Inputs are endpoints a and b, and and even positive integer n. The Output is the approximation to the integration.

v1 + (cosz)2d.r COS

Solution

function integral = compsimp(a,b,n)
f= @(x) sqrt(1+(cos(x))^2);
h = (b-a)/n;
xi0 = f(a)+f(b);
xi1 = 0;
xi2 = 0;
for i = 1:n-1
x = a+i*h;
if mod(i,2) == 0
xi2 = xi2+f(x);
else
xi1 = xi1+f(x);
end
end
xi = h*(xi0+2*xi2+4*xi1)/3;
xi
end

COMPOSITE Simplon\'s Rule. Inputs are endpoints a and b, and and even positive integer n. The Output is the approximation to the integration. v1 + (cosz)2d.r CO

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site