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
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