2

The ODE I need to solve is

eqn1 = t x'[t] - (-x[t] + y[t]);
eqn2 = t y'[t] - (-5 t^2/x[t]^2 + x[t] - y[t]);
sol = NDSolve[{eqn1 == 0, eqn2 == 0, x[0] == y[0], x[1] == 1}, {x, y}, {t, 0,1},
Method -> {"Shooting", "StartingInitialConditions" -> 
                                 {x[1] == 1, y[1] == 2/100 + 91/16000}}];

Then I want to expand my solutions, say x'[t] around t=1. Then I encounter the same problem as described in this thread. But my method is shooting, I can not switch it to ExplicitRungeKutta. I do not find any options to change DifferenceOrder in shooting method.

so my question is how to increase the DifferenceOrder to get the correct series expansion.

3c.
  • 669
  • 1
  • 7
  • 13
  • What are you looking to do with the series expansion? NDSolve solves the equation numerically. It computes the value of x[t] at discrete points in time. It does not compute a function, just function values at certain discrete times. You can't get a Taylor expansion from this. If you are looking for a series expansion of the solution, why don't you try to get it symbolically instead of first solving the equation using a numerical method? http://math.stackexchange.com/q/200582/12384 – Szabolcs Mar 18 '15 at 19:16
  • @Szabolcs, thanks so much. this really works. I did not even know this smart way to get the approximated solution. Why do not you just paste your comment into the answer, so I can end the discussion. – 3c. Mar 18 '15 at 19:34

1 Answers1

2

If you'd checked the document of shooting method carefully, you would notice that a Method can be added inside Method:

eqn1 = t x'[t] - (-x[t] + y[t]);
eqn2 = t y'[t] - (-5 t^2/x[t]^2 + x[t] - y[t]);
sol = Quiet@
   NDSolve[{eqn1 == 0, eqn2 == 0, x[0] == y[0], x[1] == 1}, {x, y}, {t, 0, 1}, 
    Method -> {"Shooting", 
      Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 9}, 
      "StartingInitialConditions" -> {x[1] == 1, y[1] == 2/100 + 91/16000}},
        InterpolationOrder -> All];

xs[t_] = Normal@Series[x[t] /. sol, {t, 1, 9}][[1]]
1. + 0.974309 (-1 + t) - 1.03854 (-1 + t)^2 + 1.07247 (-1 + t)^3 - 
 1.52337 (-1 + t)^4 + 2.3813 (-1 + t)^5 - 4.0006 (-1 + t)^6 + 
 6.80946 (-1 + t)^7 - 10.1406 (-1 + t)^8 + 8.91923 (-1 + t)^9

Sadly, the Taylor expansion of the solution at $t=1$ seems not to converge:

Plot[{x[t] /. sol, xs[t]}, {t, 0.03, 1}]

enter image description here

xzczd
  • 65,995
  • 9
  • 163
  • 468