Question: Create two vectors with entries evenly spaced between 0 and pi. One vector should be of length 100 and the other should be of length
- Create two vectors with entries evenly spaced between 0 and pi. One vector should be of length 100 and the other should be of length 1000. Then apply these vectors to the function sin(2x).
- Now use cumsum and cumtrapz to approximate the integral of sin(2x). Do this for both lengths as before.
- Subtract 0.5 from every element of each integral vector to center their graphs at 0. Then compare the computed vectors with the analytic antiderivative as before. Return the magnitude of the max error for each of the four cases.
- Plot the best approximation for the integral. Add a title to the plot
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
