# Thread: Matlab 2nd order methods

1. ## Matlab 2nd order methods

This is the question I have

Let f(x) be a given function which can be evaluated at any point. In the following question, h refers to the step size or the distance between the equally spaced points used in the approximation.
Find a 2nd order method (i.e., truncation error O(h2)) approximating
f′′′(x0).
Give the formula as well as an expression for the truncation error. Hint: You may want to consider the Taylor expansions of f(x0 ±h) then f(x0 ±2h). It is easier to consider each of these cases separately, then combine the results.

I'm just looking for a start or some sort of M-file to get me going on the rest of the stuff. I know the taylor expansions for f(x+h),f(x-h),f(x+2h),f(x-2h) but im not sure how to comebine them to make this work. I know I have to get this and then plug different h's in to see the difference in error.

Thank you very much.

2. I expanded the functions in the taylor and got

y(x+h) = y(x) + hy'(x) + h^2/2*y"(x) + h^3/6y"'(x) + h^4/12*O(h^4)

y(x+h) = y(x) - hy'(x) + h^2/2*y"(x) - h^3/6y"'(x) + h^4/12*O(h^4)

y(x+2h) = y(x) + 2hy'(x) + h^2*y"(x) + h^3/3y"'(x) + h^4/6*O(h^4)

y(x+2h) = y(x) - 2hy'(x) + h^2*y"(x) - h^3/3y"'(x) + h^4/6*O(h^4)