Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use MATLAB to solve The aim of this lab is to implement the Composite Simpson's Rule in Algorithm 4.1. Your function should use the same

Use MATLAB to solve

image text in transcribed

image text in transcribed

The aim of this lab is to implement the Composite Simpson's Rule in Algorithm 4.1. Your function should use the same order of input below. Hint: use the built-in mod function to test if an integer is even or odd. function X1 = simpson (f, a, b,n) % f function handle to be integrated % a,b-: the integral endpoints % n number of subintervals, must be an even integer % your implementation below end Use your function to approximate S dx using 100 subintervals, Your function should return -05274. 5 cos x More examples: x2 +3x -1 dx ~ 17.3333 1 10 0 10 dx1.3734 4 + x2 -10 log(1 + x) dx 1.2958 0 Composite Simpson's Rule To approximate the integral-r f(x) dx: INPUT endpoints a, b; even positive integer n OUTPUT approximation XI to I Step 1 Set h(b a) Step 2 Set X10 f (a) f(b) ALGORITHM 4.1 X1 0 Summation of f (x2-.) X12 0. Summaion of f (x2i).) Step 3 Fori.. , 1 do Steps 4 and 5. Step 4 Set Xa+ih Step 5 If i is even then set X12 = X12 + f(X) else set XII XI1 f(X) Step 6 Set X 1 h (X10 + 2 . X 12 + 4 . X 1 1)/3. Step 7 OUTPUT (XID STOP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Does it have at least one-inch margins?

Answered: 1 week ago

Question

Does it highlight your accomplishments rather than your duties?

Answered: 1 week ago