Question: Matlab 3 Numerical Differentiation Consider three different methods to numerically approximate the derivative of a function f(x) at a point z Approximation 1 (called forward):
3 Numerical Differentiation Consider three different methods to numerically approximate the derivative of a function f(x) at a point z Approximation 1 (called "forward"): ~fath-fal Approximation 2 (called "backward"): f() f(o)-f(-h Approximation 3 (ealled "center): )+h (8) Write a function createFDD which cont tains anonymous function handles for the three approximation formulas, given a function handle to the function f() and a step-size h. The function createFDD should have the following header function [df.f,df.b,df.c] createFDD (f,h) where . f is a function handle . h is the step-size and the outputs df f, df.b, df.c are function handles to anonymous functions that compute the derivative of function f using forward, backward, and center approxi- mation and step size h You can test your function with f(x) sin(2*x); [dff,df b,df-c] = createFDD(f, .05); x = linspace (o,pi,200); plot (x , df.f(x),'r,,x,df.b(x), ,g',x,df-c (x),'k'.x,2.cos (2.x),'c'); Another way to calculate derivative of a function is to fit a polynomial to a set of function points and then use that polynomial to calculate the derivative. Write a function createPolyDer that inputs a function handle f, a double array of points X and polynomial degree N. This function first fits a degree N polynomial to the points (x, t (x)). Using coefficients of the fitted polynomial, it then calculates derivative of the function and outputs an anonymous function handle to the derivative function. The header of this function is function df.poly createPolyDer (f,x,N)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
