Question: How to use the following MatLab Code for the following question: The arc length of the curve defined by y=f(x) from x=a to x=b is

How to use the following MatLab Code for the following question: The arc length of the curve defined by y=f(x) from x=a to x=b is given by the integral \int_{x=a}^{x=b} \sqrt{1+ f'(x)^{2}} dx. Use the composite of Simpson's Rule with m=32 panels to approximate the lengths of the curves: (a) y= x^{3} on [0,1] (b) y= tan x on [ 0, \frac{\pi}{4}}] (c) y= arctan x on [0,1] Code:

function a= simpson_comp(f,a,b,m)

% SIMPSON_COMP Composite Simpson's Method for numerical integration x= linspace(a,b,2*m+1); y=f(x); h=(b-a)/(2*m);

sum_odd=0; sum_even=0; for i=2:m sum_odd=sum_odd + y(2*i-1); end

for i=1:m sum_even = sum_even + y(2*i); end a= (h/3)*(y(1) +y(2*m+1) + 4*sum_even + 2*sum_odd); end QUESTION: How do I input the following functions to be used in the code. How do I call up the function in my solving of the solutions (a)(b)(c). Please help/ Explain. I can't get MatLab to work. ( I am using MatLab Live Editor)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!