Question: use the script genrated by above to solve: Matlab Ix dx Using the switch statement, write a program that prompts the user to select an


Ix dx Using the switch statement, write a program that prompts the user to select an integral approximation method (Midpoint, Trapezoidal, or Simpson's). The program then calculates and retums: the selected integral approximation value, the actual integral value, and the approximation error. Use four subintervals (n = 4) on the closed interval from x = 0 to x = 2 for each approximation. HINT: Use the built-in function int with a symbolic variable to find the actual integral value. Below is an example of running the program and selecting the midpoint approximation: Integral Approximation of (1/2)^(x^2) from (0.2] with n = 4 Approximation Methods: 1. Midpoint 2. Trapezoidal 3. Simpson's Please select a method: 1 The midpoint approximation is 7.2428 The actual value is 8.2263 The error is 0.9835 Prompt the user for the integral endpoints 'a' and 'b'. Prompt the user for the number of subintervals 'n'. Display an error to the user if they attempt to use Simpson's rule with an odd number of subintervals. Below are two examples of running the program and selecting the Simpson's approximation: Integral Approximation of (1/2)^(x^2) on the interval [a,b] Approximation Methods: 1. Midpoint 2. Trapezoidal 3. Simpson's Please select a method: 3 Specify endpoint 'a': 0.25 Specify endpoint 'b': 1.75 Specify number of subintervals 'n': 10 The Simpson's approx. is 3.7167 The actual value is 3.7149 The error is 0.0018 Integral Approximation of (1/2)e^(x^2) on the interval [a, b] Approximation Methods: 1. Midpoint 2. Trapezoidal 3. Simpson's Please select a method: 3 Specify endpoint 'a': .25 Specify endpoint 'b': 1.75 Specify number of subintervals 'n': 11 Error using 'Script File Name Simpson's Method requires 'n' to be an even integer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
