Answered step by step
Verified Expert Solution
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
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 STOPStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started