Question: Writing an Adaptive Integration Routine adaptivesum.m The second m - file you will turn in will be a recursive function. For this function, you will
Writing an Adaptive Integration Routine adaptivesum.m
The second mfile you will turn in will be a recursive function. For this function, you will begin by evaluating the definite integral on then splitting this interval in two and checking the area for each half interval. Call riemannsum.mto determine the areas, and if the difference between the area of the entire interval and the sum of the areas for the two half intervals are within tol, you stop and return the first area. If not, then each half interval is itself split in half and the evaluation occurs independently in each half interval. The process repeats until the condition is satisfied or a maximum number of recursions have been completed.
Write adaptivesum.mwith the declaration
function area adaptivesumfabnmethod,tol,cvarargin
where all of the input variables have the same meaning as in riemannsum.mexcept for n The variable nin this program will be the maximum recursion depth. This is the total number of times the intervals are allowed to be halved. Keep in mind that this number allows for a maximum of iterations so nshould stay pretty small or at most
Be sure to check your function against carefully chosen examples which should require minimal or no recursion on particular subintervals. For example, a function like
should only require two partitions for Simpson's rule if integrated over
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
