Question: I need the script to be an m. file in matlab. For this project, you are asked to Use Trapezoid rule and Simpson's rule to

I need the script to be an m. file in matlab.

I need the script to be an m. file in matlab. For

For this project, you are asked to Use Trapezoid rule and Simpson's rule to perform numerical integration for: f (x) = Squareroot sin^2 x + e^-(x/2)^2 I = integral^1_0 f (x) dx Make a plot of function f (x) in the range of [0, 1]. Write down a function to do Newton-Cotes trapezoid integration. There should be 4 inputs for the function you wrote, which are a) function name, b) beginning point, c) ending point, d) panel numbers. With a panel number = 5, Use the function you wrote to do trapezoid integration for the integration function given above. Write down a function to do Simpson's integration. There should be 4 inputs for the function you wrote, which are a) function name, b) beginning point, c) ending point, d) panel numbers. With a panel number = 100, Use the function you wrote to do Simpson's integration for the integration function given above. And assume the answer you calculated here is the exact integration result. Write a separate function that could be do both trapezoid integration and Simpson's integration up to user's choice. There should be at least five inputs for this function, which are: a) function name, b) beginning point, c) ending point, d) panel numbers, e) indicator of integration type (trapezoid or Simpson's). For example, this indicator could be '0' and '1'. '0' represent trapezoid integration and 'l' represent Simpson's integration. In this way, if the user calls your function in the following form: 1 = newtoncotes (functionA, 0, 1, 5, 1), the function will return Simpson's integration for 'functionA'. Use the code you wrote in step 6, do both trapezoid integration and Simpson's integration for given function. Increase the panel numbers one by one and show the behavior of the error (assume the exact integration is the answer in step 5. Print out an error table. The table should be in below form: Describe the error behavior for these two different methods and explain the reason for this

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!