57

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?

Electra
  • 304
badjr
  • 1,116

2 Answers2

51

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

André Nicolas
  • 507,029
  • 13
    Thanks for the answer! I'm confused though. $x_0$ is a fixed point where your Taylor series is centered, and $x$ is a variable input to your function. How should I interpret replacing $x_0$ for $x$? To me, it seems reasonable to interchange $x_0$ with some other constant (I would interpret that as moving the center point of your Taylor series). But to interchange it with $x$ means centering your Taylor series "everywhere" which I have trouble reasoning through. – rjkaplan Feb 22 '17 at 03:53
  • 1
    @rjkaplan I think the resulting series is no longer a Taylor series; it is just a series obtained from Taylor expansion. – urtata Nov 24 '18 at 17:09
  • 1
    @urtata Was there ever any other discussion on this? What would you call this series now? – Connor Oct 21 '21 at 15:51
44

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

  • Thanks so much for breaking that down! – Chawn Neal Aug 27 '22 at 16:47
  • @Asad Mehasi Very nice answer, can you please be more specific about what $f'(x_0)$ is? In other words, is $f'(x_0)=\frac{df}{dh}\big\rvert_{h=x_0}$? – Electra Nov 16 '23 at 20:27
  • Hi Electra, you're almost right, but since $f$ is a function of $x$, then $f'(x_0)= \left. \frac{df}{dx} \right\rvert_{x=x_0}$ – Asad Mehasi Nov 18 '23 at 14:23
  • 2
    @AsadMehasi Thanks for your reply, this is where I fundamentally disagree as in your last eqn. for $f(x_0+h)$ the variable $x$ no longer exists as it has been 'swept away' by the substitution $x=x_0+h$. Since $f(x_0+h)$ is only a function of $x_0$ and $h$ how can $f'(x_0)$ be a derivative wrt $x$? Sorry, I just don't follow your logic as $x$ no longer seems to exist. Many thanks! – Electra Nov 18 '23 at 17:14
  • 1
    @Electra : The variables in the denominator of a differential quotient are not the current variables in the argument but place indicators. As $f$ is defined or used as function of $x$, $\frac{df}{dx}$ just indicates that it is indeed the first derivative. If there were a variable that is not in the definition of $f$ (as some point here one has to change the symbols to partial derivatives), then the result is $0$, as relative to that other variable, $f(x)$ represents a constant. Note that $f(x_0+h)$ is a composite function and strictly speaking you need to apply the chain rule. – Lutz Lehmann Nov 18 '23 at 21:07
  • 1
    @LutzLehmann Thanks for trying to explain, unfortunately I'm now more confused than ever and I may need to ask a separate question about this. Before I do so let me try one more comment; What is a "place indicator"? In your comment you also mention that $f(x_0+h)$ is a "composite function", which I think of as say $f(x_0+h)=(x_0+h)^2$ for example. Then as you also say we need to use the chain rule, but the problem is that $\frac{df(x_0+h)}{dx}=\frac{\partial f(x_0+h)}{\partial (x_0 +h)}\color{red}{\frac{\partial (x_0+h)}{\partial x}}$; using partial derivatives as you mentioned.... – Electra Nov 19 '23 at 03:52
  • 1
    ....., but how does one deal with the $\frac{\partial (x_0+h)}{\partial x}$ factor in red since $f(x_0+h)=(x_0+h)^2$ is not a function of $x$? So by my logic $\frac{df(x_0+h)}{dx}=0$, as will any derivative wrt $x$, since the function does not depend on $x$. – Electra Nov 19 '23 at 03:55
  • If you have a function $F(x,y,z,q)$, then $\frac{\partial F}{\partial q}$ means the derivative for the 4th variable, independent of what the contents at this 4th position actually is. // Composite in the sense that $f(x_0+h)=f(g(h))$ where $g(h)=x_0+h$. Then $\frac{d(f\circ g)}{dh}=\frac{df}{dx}(g(h))\frac{dg}{dh}(h)$. Note that the denominators contain the variable of the function definition, never the actual arguments. – Lutz Lehmann Nov 19 '23 at 08:51
  • There is some confusion when the derivative is put in a geometrical context and functions and variables are replaced by coordinates. Then the original and intuitive $\frac{dz}{dx}=\frac{dz}{dy}\frac{dy}{dz}$ occurs. With careful handling, as the old masters did, this is correct. But it also conceals much of the context, and if that changes this simple form can become misleading or wrong. – Lutz Lehmann Nov 19 '23 at 08:54
  • A more extended discussion with some explanation why folks will continue to use the "wrong" application of the (partial) differential quotients can be found in https://math.stackexchange.com/a/1091132/115115 – Lutz Lehmann Nov 19 '23 at 09:08