Question

Problem(2): Write an M-file to program the Simpsons 3/8 rule for integration. Use your saved file to integrate the following
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The m-file for simpson 3/8 rule is given below.

function I= Simpson38(f,a,b)
%find integral of function f on the interval [a,b]
%f must be defined as an inline function
h=(b-a)/3
x0=a;
x1=x0+h;
x2=x0+2*h;
x3=b;
S1= feval(f,a);
S2=3*feval(f,x1);
S3=3*feval(f,x2);
S4=feval(f,b);
S=S1+S2+S3+S4;
I=S*h*3/8;
end

In command window we have to write

>> f=@(x)8+4*cos(x);
>> a=0;
>> b=pi/2;
>> I=Simpson38(f,a,b)

And the result is

h =

0.5236


I =

16.5704

Add a comment
Know the answer?
Add Answer to:
Problem(2): Write an M-file to program the Simpson's 3/8 rule for integration. Use your saved file...
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
  • Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func:...

    Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func: the function/equation that you are required to integrate -a, b: the integration limits n: the number of points to be used for the integration I:Integral estimate a) Write a function capable of performing numerical integration of h(x) using the composite trapezoidal rule. Use your function to integration the equation with 9 points. Write a function capable of performing numerical integration of h(x) using the...

  • 1. Simpson's rule. Simpson's rule is a different formula for numerical integration of lºf (d.x which...

    1. Simpson's rule. Simpson's rule is a different formula for numerical integration of lºf (d.x which is based on approximating f(2) with a piecewise quadratic function. We will now derive Simpson's rule and relate it to Romberg integration: a. Suppose that (2) is a quadratic polynomial so that q(-h) = f(-h), q0) = f(0) and q(h) = f(h). Prove that 92 f(-h) + 4f(0) + f(h)). -h b. Suppose that the interval [a, b] is divided by a = 20,...

  • Approximating With Simpson's Rule 6) Now we want to use Simpson's Rule to find the volume of the machine pa...

    Approximating With Simpson's Rule 6) Now we want to use Simpson's Rule to find the volume of the machine part. Remember that Simp- son's Rule approximates integrals, not just areas. Since we don't just want the area under the radius function, we can't just apply Simpson's Rule to the radius function. If we let f(x) be the radius of the machine part at the point x, write down the integral that gives the volume of the machine part (with an...

  • Consider the integral 8. eT dx Use Simpson's Rule with n = 6 to estimate the value of the integra...

    Consider the integral 8. eT dx Use Simpson's Rule with n = 6 to estimate the value of the integral. (a) (b) Your friend chose instead to estimate the integral above using the Midpoint Rule with n = 6, Noting that the second derivative: 4x2-4r +3)e z5/2 is an increasing function over the interval [1, 4], determine the maximum possible error in your friend's estimate Consider the integral 8. eT dx Use Simpson's Rule with n = 6 to estimate...

  • Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with...

    Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with the specified value of n. (Round your answers to six decimal places.) 5 3 cos(6x) n = 8 dx, X 1 (a) the Trapezoidal Rule (b) the Midpoint Rule (c) Simpson's Rule

  • 3 11 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate...

    3 11 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate dx. 1 + x2 The approximate value of the integral from Simpson's rule is (Round the final answer to two decimal places as needed. Round all intermediate values to four decimal places as needed.) 5 Use Simpson's rule with n=4 (so there are 2n = 8 subintervals) to approximate OX dx and use the fundamental theorem of calculus to find the exact value of...

  • 1. Please derive the formula of Simpson's rule. What is needed is a step-by-step derivation, with...

    1. Please derive the formula of Simpson's rule. What is needed is a step-by-step derivation, with explanation why the next step can be taken. 2. Use the Midpoint Rule (see the book) and Simpson's Rule to compute the following integral: 1 + (cos x) dx Make a table of your calculation, in the form like this: No Value of Value of weight Value of function value of weight function Value of integral You are free to choose the value of...

  • Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with...

    Use the Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule to approximate the given integral with the specified value of n. (Round your answers to six decimal places.) 4 In(1 + ex) dx, n = 8 Jo (a) the Trapezoidal Rule X (b) the Midpoint Rule (c) Simpson's Rule 8.804229

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

  • 7 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate 8...

    7 Use Simpson's rule with n=1 (so there are 2n = 2 subintervals) to approximate 8 dx. The approximate value of the integral from Simpson's rule is (Round the final answer to two decimal places as needed. Round all intermediate values to four decimal places as needed.)

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