Question: Using MATLAB: Create a script (int.m) that accepts a function f(x) and stepsize h then calculates the integral using the Midpoint rule, Trapezoid rule and

Using MATLAB: Create a script (int.m) that accepts a function f(x) and stepsize h then calculates the integral using the Midpoint rule, Trapezoid rule and Simpsons rule. Run this script for h = 1, 0.1, 0.01, 0.001 and write this data to a file (int.txt).

The data file should have the following header values:

Using MATLAB: Create a script (int.m) that accepts a function f(x) and

*Here is the midpoint, trapezoid, and simpson's rule

stepsize h then calculates the integral using the Midpoint rule, Trapezoid rule

Please solve using only MATLAB. Thanks!

f method (x) midpoint cos(x) -3 trapezoid cos(x) 3 Simpson (x) 0.1 0.01 0.001 theoretical int (f) %error

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!