1
$\begingroup$

I'm trying to solve the equation below, but I get:

e = -0.02;
L = 4.0;

U[r_] := -1/r;
r0 = NSolve[U[r] + L^2/(2 r^2) == e, r, Reals]
r0 = Max[r /. r0]

NDSolve[
  {r'[t] == Sqrt[2 (e - U[r[t]]) - L^2/r[t]^2], ϕ'[t] == L/r[t]^2, 
   r[0] == r0, ϕ[0] == 0}, 
  {r, ϕ}, {t, 0, 100}]

During evaluation of In[86]:= NDSolve::mxst: Maximum number of 98930 steps reached at the point t == 0.05406112246188643`.

{{r -> InterpolatingFunction[{{0., 0.043953}}, <>], 
  ϕ -> InterpolatingFunction[{{0., 0.043953}}, <>]}}

How can I solve this?

$\endgroup$
  • 2
    $\begingroup$ Try to find the problem: zed={r[t],φ[t]} /. NDSolve[{r'[t]==Sqrt[2 (-0.02 + 1/r[t]) - 16./r[t]^2], φ'[t]==16./r[t]^2, r[0]==40., φ[0]==0}, {r[t],φ[t]}, {t,0,100}][[1]] followed by Table[zed, {t, 0, .04, .005}] and it appears your r goes to infinity. Are you sure you do not have a sign error? Or another error in the equation? $\endgroup$ – Bill Apr 25 '17 at 0:03
  • $\begingroup$ This is the equation of motion of a central force with potential given by U(r). I copied this from a Classical Mechanics book. I really don't know what is happening :/ $\endgroup$ – AVemado Apr 26 '17 at 18:05
  • $\begingroup$ @AVemado Any link to that book> $\endgroup$ – zhk Apr 27 '17 at 3:15
  • $\begingroup$ It's called Classical Dynamics of Particles and Systems - Marion, Thornton. $\endgroup$ – AVemado Apr 29 '17 at 17:21
  • 1
    $\begingroup$ To be more specific, the problem is caused by Sqrt, the 2 methods suggested in the post linked above are all applicable to your problem i.e. you can either add e.g. WorkingPrecision -> 16 to NDSolve or add a Re@ before Sqrt to resolve the problem. $\endgroup$ – xzczd May 4 '17 at 16:43
0
$\begingroup$

Comment

There are two ways I know which can help to avoid NDSolve::mxst: But the results may not be accurate.

Firstly,

sol1 = NDSolve[{r'[t] == Sqrt[2 (e - U[r[t]]) - L^2/r[t]^2], ϕ'[t] == L/r[t]^2, 
              r[0] == r0, ϕ[0] == 0}, {r, ϕ}, {t, 0, 100}, 
    Method -> {"FixedStep", Method -> "ExplicitEuler"}, StartingStepSize -> 0.01];

Secondly,

sol2 = NDSolve[{r'[t] == Sqrt[2 (e - U[r[t]]) - L^2/r[t]^2], ϕ'[t] == L/r[t]^2, 
   r[0] == r0, ϕ[0] == 0}, {r, ϕ}, {t, 0, 100}, 
  Method -> "BDF", PrecisionGoal -> 0, AccuracyGoal -> 0, MaxStepSize -> 1. 10^-2]

You can try your luck with other methods.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the answer, but it didn't work. I found another way to calculate this problem. :) $\endgroup$ – AVemado Apr 26 '17 at 22:26
  • $\begingroup$ @AVemado its works for me and fix the warring. $\endgroup$ – zhk Apr 27 '17 at 2:50

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