Question

find trapezoidal rule and simpsons rule and error value for functions f(y)=y for yE[1,3] and f(y)=logy...

find trapezoidal rule and simpsons rule and error value for functions f(y)=y for yE[1,3] and f(y)=logy for yE[2,4]
also write python code or matlab code with output.
and plot graph.
can someone answer this question urgent
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
f=@(y) y;
disp('Trapezoid method for f(y)=y');
trapezoid(f,1,3,20)
disp('Trapezoid method for f(y)=log(y)');
trapezoid(f,2,4,20)
function I = trapezoid(func,a,b,n)

% I = trap(func,a,b,n):

% multiple-application trapezoidal rule.

% input:

% func = name of function to be integrated

% a, b = integration limits

% n = number of segments

% output:

% I = integral estimate

x = a;

h = (b - a)/n;

s = feval(func,a);

for i = 1 : n-1

x = x + h;

s = s + 2*feval(func,x);

end

s = s + feval(func,b);

I = (b - a) * s/(2*n);
end

Note: Brother According to HomeworkLib's policy we are only allowed to answer first part if there are many. So, I request you to post other part as separate posts

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
find trapezoidal rule and simpsons rule and error value for functions f(y)=y for yE[1,3] and f(y)=logy...
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