Question

PLEASE use MATLAB only to write the code100 10 Assume -18.79829683678703 is the exact value of the integral. Estimate this integral by the composite trapezoid rule

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clear
clc

f = @(x) (100./x).*sin(10./x);

a = 1; b=3;
n3 = 3; n5 = 5; n7 = 7;

f_exact = -18.79829683678703;

step3 = (b-a)/n3;
step5 = (b-a)/n5;
step7 = (b-a)/n7;

% dx = step
% I = ((b-a)/2n)*(f(a)+ f(a+dx) + ... + f(b-dx)+ f(b) )

I3 = 0;
for j=a:step3:b % a:dx:b
I3 = I3 + ((b-a)/(2*n3))*f(j);
end


I5 = 0;
for j=a:step5:b
I5 = I5 + ((b-a)/(2*n5))*f(j);
end


I7 = 0;
for j=a:step7:b
I7 = I7 + ((b-a)/(2*n7))*f(j);
end

integration_n3 = I3
percent_err_n3 = 100*abs((f_exact - I3)/f_exact)

integration_n5 = I5
percent_err_n5 = 100*abs((f_exact - I5)/f_exact)

integration_n7 = I7
percent_err_n7 = 100*abs((f_exact - I7)/f_exact)

integration n3 -38. 8447 percent err n3 106.6396 integration n5- -22.6645 percenterrn5 = - - 20.5666 integration n7 = -17.138

COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
PLEASE PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
PLEASE use MATLAB only to write the code 100 10 Assume -18.79829683678703 is the "exact" value...
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