Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. You are given a function f(x 2r3r 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 2r3r 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, fi, at each point zi, 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 r, 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 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 f(i) is the true value of derivative at the given point Run your program with the number of intervals N equal to 8, 16, 32, 64 and document the E and 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 ELa versus N, in log-log plot, for both the O(h) and O(h2) derivatives (on the same plot, but different from ELerrors). 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
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