Start with
H = q[t]^2 + p[t]^2 + q[t]^3
A = D[H, p[t]]
B = -D[H, q[t]]
NDSolve[{q'[t] == A, p'[t] == B, q[0] == p[0] == .2}, {q[t],
p[t]}, {t, 0, 5}] // First;
R = Evaluate[{q[t], p[t]} /. %]
This gives
>> {InterpolatingFunction[{{0., 5.}}, <>][t], InterpolatingFunction[{{0., 5.}}, <>][t]}
Which looks like
ParametricPlot[R, {t, 0, 4}, PlotStyle -> Red]
Now, take
Series[R, {t, 0, 10}] // Normal
which gives
{0.2 + 0.4 t - 2.08063 t^2 + 8477.23 t^3,
0.2 - 0.52 t - 2.5593 t^2 + 10427.5 t^3} .
Something is utterly wrong, here. This should be an infinite polynomial. I don't even have to plot it to know it won't, obviously, approximate my original interpolating function correctly.
Edit:
- Is there a maximum number of derivatives one can take from an interpolating function? Why the sudden truncation? - Answered in the comments.
- Is there a way to circumvent this?
InterpolatingFunction
interpolates between points precicely by using interpolating polynomials. The default order seems to be 3 (but I don't know if there are cases where Mathematica automatically uses a higher or lower order), explaining why yourSeries
truncate aftert^3
. $\endgroup$InterpolationOrder -> All
inNDSolve
will yield an interpolation with an order equal to the order of the step (which is variable with the default method). It still won't be of order 10. $\endgroup$Method -> "Extrapolation"
) in conjunction with Michael's advice should net you a few more coefficients, but maybe not as many as you'd like. $\endgroup$InterpolationOrder
is in the base documentation ofNDSolve[]
and such this question is at risk of closure. There have also been multiple votes not to close this question as the solution isn't as obvious as many others that get closed for this reason. $\endgroup$