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 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, 17Step 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