How is the Taylor expansion for $f(x + h)$ derived?

According to this Wikipedia article, the expansion for $f(x\pm h)$ is:

$$f(x \pm h) = f(x) \pm hf'(x) + \frac{h^2}{2}f''(x) \pm \frac{h^3}{6}f^{(3)}(x) + O(h^4)$$

I'm not understanding how you are left with $f(x)$ terms on the right hand side.

I tried working out, for example, the Taylor expansion for $f(x + h)$ (using $(x+h)$ as $x_0$) and got this:

$$ f(x + h) = f(x+h) + f'(x + h)(x-(x+h)) + \frac{f''(x+h)}{2!}(x-(x+h))^2 + \frac{f'''(x+h)}{3!} (x - (x + h))^3 + \cdots $$

$$ = f(x + h) - hf'(x+h) + \frac{h^2}{2!}f''(x + h) - \frac{h^3}{3!} f'''(x+h) + \cdots$$

Am I doing this correctly?


It looks as if the notation you are accustomed to for the Taylor expansion is something like $$f(x)\approx f(x_0)+f'(x_0)(x-x_0)+\frac{f''(x_0)}{2!}(x-x_0)^2+ \frac{f'''(x_0)}{3!}(x-x_0)^3+\cdots.$$

Now write $x$ instead of $x_0$, and $x\pm h$ instead of $x$.


This has already been answered, but I have seen some of the comments to the answer from Andre Nicolas and I thought I could make it clear with a step by step explanation.

Instead of just doing a substitution, as Andre mentioned, think about the meaning of it. Start with the standard Taylor series expansion, $$ f(x) \approx f(x_0)+f′(x_0)(x−x_0)+\frac{f′′(x_0)}{2!}(x−x_0)^2+\frac{f′′′(x_0)}{3!}(x−x_0)^3+⋯. \qquad (*)$$ Now what does $x-x_0$ mean? For convergence, we usually need this to be small, so we can call this $h$. Now substitute $x-x_0=h$ (and obviously $x=x_0+h$) into $(*)$ to get: $$ f(x_0+h) \approx f(x_0)+f′(x_0)h+\frac{f′′(x_0)}{2!}h^2+\frac{f′′′(x_0)}{3!}h^3+⋯.$$ This is in the required form but with $x_0$ instead of $x$ and since this is just a variable we can just substitute it for $x$.