Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Numerical methods problem In class we discussed two methods of integration: the trapezoidal rule and Simpson's rule Here you will apply these formulas to the
Numerical methods problem
In class we discussed two methods of integration: the trapezoidal rule and Simpson's rule Here you will apply these formulas to the integration of a function and compare the two methods (a) Write a MATLAB script file to integrate a function contained in an m-file using the trapezoidal rule (b) Write a MATLAB script file to integrate a function contained in an m-file using Simpson's rule (c) Use your numerical integrators to evaluate e-* sin(2x) dx Clearly, you cannot integrate to infinity, but the integrand decays rapidly, so practically you may truncate the integral at some finite distance from the origin. Plot the integrand and hoose a practical upper limit for the numerical integration. (d) Compute the integral for several values of N, the number of integration points, ranging from 1 to 1000 using both the trapezoidal and Simpson's rules (pick a few N between 1 and 1000). How does your answer change with increasing N? (e) Use the MATLAB function integrate to integrate the function and report the result. How does it compare to the results from your numerical integrators? Make a table of the absolute error between the numerical integration (for the two different methods) and the "exact" value of the integral (obtained from integrate) at different numbers of integration points. Comment on the accuracy of the two different methods. (The table does not need to be generated by the MATLAB code - you can generate it 'by hand' or in excel.)
Step 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