Question: 3. You are given a function f(x)-2x1+ 3x3 on the interval [-2.2] and you want to calculate the first derivative of this function at the

3. You are given a function f(x)-2x1+ 3x3 on the interval [-2.2] and you want to calculate the first derivative of this function at the points on this interval. Write a MATLAB program that (a) Given the number N of subintervals, calculates the first derivative of the function, f, at each point i, including the boundary points, with the first-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (b) Given the number N of subintervals, calculates the first derivative of the function, f at each point ri, including the boundary points, with the second-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h2) of your choice. (c) Calculates two measures of error defined as N +1 The first error is called the error in infinity norm (max, stands for the maximum value among all the points), and the second error is called the error in L2 norm. Here ftrue(i is the true value of derivative at the given point r, Run your program with the number of intervals N equal to 8, 16, 32, 64 and document the ELand EL errors for each run. Plot EL versus N, in log-log plot, for both the O(h) and O(h2) derivatives on the same plot. Also, plot EL versus N, in log-log plot, for both the O(h) and O(h2) derivatives (on the same plot, but different from Ei errors). Estimate the order of accuracy for each derivative from the two plots. Discuss if you obtain the expected order of convergence, for both error measures. 3. You are given a function f(x)-2x1+ 3x3 on the interval [-2.2] and you want to calculate the first derivative of this function at the points on this interval. Write a MATLAB program that (a) Given the number N of subintervals, calculates the first derivative of the function, f, at each point i, including the boundary points, with the first-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (b) Given the number N of subintervals, calculates the first derivative of the function, f at each point ri, including the boundary points, with the second-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h2) of your choice. (c) Calculates two measures of error defined as N +1 The first error is called the error in infinity norm (max, stands for the maximum value among all the points), and the second error is called the error in L2 norm. Here ftrue(i is the true value of derivative at the given point r, Run your program with the number of intervals N equal to 8, 16, 32, 64 and document the ELand EL errors for each run. Plot EL versus N, in log-log plot, for both the O(h) and O(h2) derivatives on the same plot. Also, plot EL versus N, in log-log plot, for both the O(h) and O(h2) derivatives (on the same plot, but different from Ei errors). Estimate the order of accuracy for each derivative from the two plots. Discuss if you obtain the expected order of convergence, for both error measures
Step by Step Solution
There are 3 Steps involved in it
To solve this problem well implement a MATLAB program that calculates the numerical derivative of fx 2x4 3x3 on the interval 2 2 using both firstorder ... View full answer
Get step-by-step solutions from verified subject matter experts
