Suppose that I have the following equations $$\dot{x}(t) = p(t),$$ $$\dot{p}(t) = -V'(x(t)).$$ I am trying to compute the Taylor series of $p(t)$ at $t=0$.
Here are the codes I use:
x'[t_] := p[t]; p'[t_] := -V'[x[t]];
Series[p[t], {t, 0, 2}]
Then I get the result in Mathematica
p[0] - V'[x[0]] t + 1/2 p''[0] t^2 + O[t]^3
But p''
in the result isn't computed.
If I use
D[p[t], {t, 2}]
then I get what I want for $p''$: -p[t]V''[x[t]]
.
How could I get the Taylor series of any order which compute the higher order derivatives properly?
p''
to be anything. $\endgroup$FullForm
ofp''[t]
isDerivative[2][p][t]
. For it to work the way you expected,p
would have to be defined, not justp'[t]
, which defines a value only forDerivative[1][p][..]
. Or you would have to do some other work around. $\endgroup$Derivative
? $\endgroup$