Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In MATLAB only please a) Modify the rmlsum file to include a while-loop so that the program code terminates when an accuracy based on relative
In MATLAB only please
a) Modify the rmlsum file to include a while-loop so that the program code terminates when an accuracy based on relative approximate error is achieved. In each iteration of the while-loop, double the number of the intervals (i.e., the step size h is reduced by one half) in the numerical integration algorithm. The function structure should be: function [I,n] = rmlsumn(fun, a, b, maxtol) where, I is the approximate result of the integration and n is the number of intervals that would yield a result to satisfy the error tolerance criterion. Note that this output value of n is not necessarily the minimum number of intervals to achieve the error tolerance. Apply this numerical solver to the following integral using maxtol = le-5. 200 (1+0.4)3sdt 10 s.com One potential difficulty of the above approach is that it might take many iterations to achieve the error tolerance. In general, one would like to set a maximum number of iterations. b) Modify the above numerical solver so that the while-loop checks both the error tolerance and the maximum number of iterations. In other words, the loop terminates when either the error is sufficiently small or the maximum number of iterations is exceeded. The function structure should be: function [I,n] = rmlsumN1(fun, a,b,maxtol, maxitr) Test your program code on the same integral from part (a) using maxtol = le-5 and maxitr = 20. Note that because the number of intervals is doubled in each iteration, 20 iterations would result in n=2420= 1048576. function I=rmlsum (func, a, b,N) h=(b-a)/N; x=linspace (a,b, N+1); I=sum (func (x(1:N))) *h; endStep 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