Question: Write a Matlab code to integrate a function that is approximated using a uniformly spaced array of points. The function should have the form function

Write a Matlab code to integrate a function that is approximated usingWrite a Matlab code to integrate a function that is approximated using a uniformly spaced array of points. The function should have the form function [integral] = integrate(h,values) Use the Simpsons 1/3 rule for the integration. Again use a regularly spaced array of node locations with a node at both x = 0 and x = 1 generated using the linspace command as was done in the previous problem. For this assignment, you will again do this 4 times with N = 3, 5, 9, 17 so you can see how the approximation changes as the number of points increases (h decreasing by a factor of 2). Integrate the function sin(x) (not 2 this time). Calculate the absolute error in integral as a function of N. Make a loglog plot of the error versus N for N = 3, 5, 9, 17.

Write a Matlab code to integrate a function that is approximated using a uniformly spaced array of points. The function should have the form function [integral]-integrate (h,values) Use the Simpson's 1/3 rule for the integration. Again use a regularly spaced array of node locations with a node at both 2-0 and 1 generated using the problem. For this assignment, you will again do this 4 times with N- 3,5,9, 17 so you can see how the approximation changes as the number of points increases (h decreasing by a factor of 2). Integrate the function sin(TI) (not 2 this time). Calculate the absolute error in integral as a function of N. Make a loglog plot of the error versus N for N- 3,5,9, 17

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!