Question: . Finite difference formulas. Write a Matlab function that constructs finite difference formulas for a given stencil and derivative order. That is, given points x0,

. Finite difference formulas. Write a Matlab function that constructs finite difference formulas for a given stencil and derivative order. That is, given points x0, x1, . . . , xn and a positive integer d, your code should compute c0, c1, . . . , cn such that

f (d) (x) Xn i=0 cif(x + xi).

The function signature should be

function C = fdcoeff(X, d)

where X is a numeric array containing the (distinct) stencil points, d is the desired derivative order, and C is an array of stencil coefficients. For example, fdcoeff([-1, 0, 1], 1) should return [-0.5, 0, 0.5] (the 3-point midpoint formula). Note that the textbook does not give you a formula: you will have to research it. Hint: You will need to construct and solve a linear system. You are encouraged to follow the example at http://web.media.mit.edu/~crtaylor/calculator.html.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!