Question

4. This question is about using the composite Simpsons Rule to estimate the integral 1 = (exp() dr to ten decimal places. (a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format long
n=2;
a=-2;
b=2;
while(1)
I=CompSR(a,b,n);
if(abs(I-2*exp(-1)*(exp(2) - 1))<0.5e-10)
break;
end
n=2*n;
end
fprintf('Approximation is %.10f\n',I);


function int=CompSR(a,b,n)
h=(b-a)/n;%step of integration
fa=f(a);%value of function at a
fb=f(b);%value of function at b
ff=0;%initialize ff to 0
for i=2:2:n%traversing on even numbers i
x=(a+(i-1)*h);%accessing even points in the intervals divided
fx=f(x);%value of function at x
ff=ff+4*fx;%add 4*fx to ff
end
for i=3:2:n%traversing on odd numbers i
x=(a+(i-1)*h);%accessing odd points in the intervals divided
fx=f(x);%value of function at x
ff=ff+2*fx;%add 4*fx to ff
end
int=(h/3)*(fa+fb+ff);%finally add first and last points tto all the sum and divide by 3
end
function y=f(x)
y=exp(x/2);
end

MATLAB R2018a X Pradeep EDITOR VIEW Search Documentation НOME PLOTS APPS PUBLISH Find Files fxF Insert Run Section Г Comment

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
4. This question is about using the composite Simpson's Rule to estimate the integral 1 =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT