Trying to do something simple: Taylor expand a generic function of t around a point t and substitute t0 + h for t. Here's my expression:

y1[t0_, h_] = Module[{t}, Series[y[t], {t, t0, 2}] /. t -> t0 + h]

This results the message

SeriesData::sdatv: First argument h + t0 is not a valid variable.

and it gives the result

y[t0] + y′[t0]((h + t0) - t0) + 1/2 y′′[t0] ((h + t0) - t0)^2 + O[(h + t0) - t0]^3

This is what I'm looking for, except all of the (h + t0) - t0 stuff. Why is this not simplifying to h? In fact, if I substitute 6 for t0, I get (h + 6) - 6. So there is enough information there to know that when it substitutes for t0, it substitutes for all t0, but it still treats one of the t0's as different from the other for purposes of simplification.

I sense that I'm missing something basic.


Change the argument of y to t0 + h

y1[t0_, h_] = Module[{t}, Series[y[h + t0], {h, 0, 2}]]

(* SeriesData[h, 0, {y[t0], Derivative[1][y][t0], Derivative[2][y][t0]/2}, 0, 3, 1] *)
  • 1
    $\begingroup$ Why not just y1[t0_, h_] = Series[y[h + t0], {h, 0, 2}] $\endgroup$ – m_goldberg Feb 14 '15 at 2:56
  • $\begingroup$ @m_goldberg left the expression enclosed in the Module, in case the OP had some reason to have it there. You are correct that it does nothing in this toy problem. $\endgroup$ – bbgodfrey Feb 14 '15 at 2:59
  • $\begingroup$ The Module construct was there because the variable t is local and gets replaced by the substitution. Not needed any more. Thanks! $\endgroup$ – Jamie Lawson Feb 14 '15 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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