Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me with this matlab problem. Thank you. Problem 1: Construction of functions (numerical solvers) for numerical computations The trapezoidal or midpoint rule is
Please help me with this matlab problem. Thank you.
Problem 1: Construction of functions (numerical solvers) for numerical computations The trapezoidal or midpoint rule is often used to approximate the integral of a given function since it is the average of the left and right Riemann sums and generally provides a more accurate solution. The algorithm for the trapezoidal rule is given as follows: [f(x) + f(xk+1)] a) Based on what is learned in class about the left-Riemann sum and right-Riemann sum algorithms, create a user-defined MATLAB function that performs numerical integration using the trapezoidal rule. The numerical solver should have the following input/output structure: function I = trapf(fun, a, b,N) b) Using the trapf function created in part (a), evaluate the integral of the curve f(x) = -2x3 + 6x2 + 3 over the interval [0,3] using 10 subintervals. Calculate the percent error by using the results from the built-in function integral. c) Repeat part (b) with 5 subintervals and 20 subintervals. What can you conclude about the correlation between the number of subintervals and the relative percent error
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