Question

Problem 6. Consider the definite integral fo, sin(VE) cos( dz. Use n-100 and n = 300 separately, to find the Riemann sum for please explain and do in matlab
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

close all
clear
clc

a = 0; b = pi; % integration limits

%% n = 100
n = 100;
func = @(x) sin(sqrt(x)) .* cos(sqrt(x)); % input function

h = (b - a)/n;
I = h*sum(func(a + h/2:h:b-h/2)); % Riemann sum using midpoint rule

fprintf('Riemann Sum (n = %4d): %.6f\n', n, I)

%% n = 300
n = 300;
func = @(x) sin(sqrt(x)) .* cos(sqrt(x)); % input function

h = (b - a)/n;
I = h*sum(func(a + h/2:h:b-h/2)); % Riemann sum using midpoint rule

fprintf('Riemann Sum (n = %4d): %.6f\n', n, I)

Output:

Riemann Sum (n = 100): 0.717351
Riemann Sum (n = 300): 0.717069

Add a comment
Know the answer?
Add Answer to:
please explain and do in matlab Problem 6. Consider the definite integral fo, sin(VE) cos( dz. Use n-100 and n = 300 separately, to find the Riemann sum for this integral. Keep at least four decim...
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