I am trying to work with Taylor series. What I am trying to do is to express $$ f(h) - f'(0) = f(h) - f'(h - h) $$ such that only derivatives of $f$ with the argument $h$ appear, for example $$ f(h) - f'(0) = f(h) - f'(h) + hf''(h) + \mathcal O(h^2) $$

I tried to do is this way:

f[h] - Series[f'[s - h], {h, 0, 2}] /. s -> h

Strangely, this gives me $$ \bigl(f(0) - f'(h)\bigr) - \bigl(f'(0) - f''(h)\bigr)h +\left(\frac{f''(0)}2 - \frac{f^{(3)}(h)}2\right)h^2 + \mathcal O(h^2) $$ which is not what I wanted. How can this behaviour be explained?

For the record, the correct answer can be obtained by

f[t] - Series[f'[s - h], {h, 0, 2}] /. {t -> h, s -> h}
  • $\begingroup$ I really don't understand your question. Are you just trying to compute $f(h)_\text{exact} - f(h)_\text{taylor}$? In that case you should be using f[h] - Series[f[h + δ], {δ, 0, 2}] $\endgroup$
    – QuantumDot
    Commented Apr 22, 2016 at 11:15
  • $\begingroup$ I fixed some typos and explained what I want to get. Although the calculation itself may not be useful, I am asking for an explanation of the seemingly strange behaviour. $\endgroup$
    – Wauzl
    Commented Apr 22, 2016 at 11:32

1 Answer 1


This is a bit tricky, but if you look in the docs under SeriesData, it says

When you apply certain mathematical operations to SeriesData objects, new SeriesData objects truncated to the appropriate order are produced.

That explains this interesting series of events:

Series[f[s + h], {h, 0, 2}]
g[h] - %
Series[g[h] - f[s + h], {h, 0, 2}]
Normal@% - Normal@%% // Expand

enter image description here

When I added g[h] to -Series[f[s + h], {h, 0, 2}] the system first converted g[h] to a SeriesData object with the same order and parameter.

You can do

f[h] - Normal@Series[f[s + h], {h, 0, 2}]
(* f[h] - f[s] - h Derivative[1][f][s] - 1/2 h^2 (f^′′)[s] *)

But that isn't really what you are looking for, since you still want the Big-O notation. Your method of working around this,

f[t] - Series[f'[s - h], {h, 0, 2}] /. {t -> h, s -> h}

(* (f(h)-f^′(h))+h f^′′(h)+1/2 h^2 (-f^(3)(h))+O(h^3) *)

works in the following way.

  1. First, Series[f'[s - h], {h, 0, 2}] is evaluated, giving a SeriesData object.
  2. Next, before f[t] can be added to -Series[f'[s - h], {h, 0, 2}], it is first converted to Series[f[t], {h, 0, 2}]
  3. Now the two SeriesData objects are combined into one
  4. The application of the replacement rule t->h occurs inside the SeriesData head, so there is not further application of Series
  • $\begingroup$ I don't really want to lose the Landau symbol. Are there any issues with using t instead of h and then replacing it /.t->h which may occur? $\endgroup$
    – Wauzl
    Commented Apr 22, 2016 at 11:34
  • $\begingroup$ No problem at all, I was just trying to help understand why you have to take that circuitous route to get there :-) $\endgroup$
    – Jason B.
    Commented Apr 22, 2016 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.