I am trying to solve a geodesic equation on Mathematica and would like to get a precise result, using DSolve would be a good start for me. My problem is the following: I have a squared expression for my DE and manage to get a solution with NDSolve for my equation using the Method -> {"EquationSimplification" -> "Residual"} option but cannot find anything similar using DSolve. Is there a way to ask Mathematica to find an analytical solution for this? I think the problem comes from the fact that two solutions are possible with this equation: the one with r[x] increasing or the one with r[x] decreasing and then increasing again, I have solved this with the "r'[0] == -10" term with NDSolve.

Thanks in advance!

Here is the code:

eqr = 0 == -(r'[x])^2 + En^2 - L^2*(1 - 2 mass/r[x])/r[x]^2
Rxn = NDSolve[{eqr, r[0] == 10000, r'[0] == -10, r'[0] == -10} /. {En -> 10, L -> 100, 
     mass -> 1}, r, {x, 0, 10000}, 
   Method -> {"EquationSimplification" -> "Residual"}][[1, 1, 2]]
Rxa = DSolve[{eqr, r[0] == 10000} /. {En -> 10, L -> 100, mass -> 1}, r, 

The DSolve returns the error "DSolve::bvimp: General solution contains implicit solutions. In the boundary value problem, these solutions will be ignored, so some of the solutions will be lost"

  • 1
    $\begingroup$ lots of errors running your code. what is eqr[x] = 0 ==.... supposed to be? Did you mean to define a function here? any way, V 12.1 gives errors running your NDSolve. Did not try the rest. Please make sure your code at least runs before posting it. $\endgroup$
    – Nasser
    Apr 29, 2020 at 18:38
  • $\begingroup$ Sorry about that, changed a bit my code for the post and didn't checked it twice, I edited the original code on the post. $\endgroup$
    – user72371
    Apr 29, 2020 at 22:30
  • $\begingroup$ Your code still does not run. Please check the code you just updated in your notebook, and make sure you are using clean kernel to see the error. $\endgroup$
    – Nasser
    Apr 29, 2020 at 22:37
  • $\begingroup$ Forget the R0... It compiles now on V12! $\endgroup$
    – user72371
    Apr 29, 2020 at 22:41
  • $\begingroup$ What is the surface where this curves are geodesics? Why are your equations of the first order, while geodesics are second order differential equations? I'm sure your question can be answered in a more satisfactory manner than that one below. $\endgroup$
    – Artes
    Apr 30, 2020 at 12:03

1 Answer 1


There is no explicit analytical solution only an implicit which can't be solved analytically for $r(x)$.

ode = -(r'[x])^2 + En^2 - L^2*(1 - 2 mass/r[x])/r[x]^2 == 0

Mathematica graphics

First@DSolve[ode /. {En -> 10, L -> 100, mass -> 1}, r[x], x]

Mathematica graphics

And Mathematica can't solve this for $r(x)$. Giving one BC shows this

 DSolve[{ode, r[0] == 10000}, r[x], x]
 (* {} *)

DSolve::bvimp: General solution contains implicit solutions. In the boundary value problem, these solutions will be ignored, so some of the solutions will be lost.

Maple also gives an implicit solution, which is simpler, still the integral it gives can't be solved analytically

ode:= En^2- L^2*(1- (2*mass)/r(x))/r(x)^2 - diff(r(x),x)^2=0;
En:=10; L:=100; mass:=1;

$$ -x+\int_{{\it \_b}}^{r \left( x \right) }\!-{\frac {{{\it \_a}}^{2}}{ 10}{\frac {1}{\sqrt {{\it \_a}\, \left( {{\it \_a}}^{3}-100\,{\it \_a} +200 \right) }}}}\,{\rm d}{\it \_a}+{\it \_C1}=0 $$

Notice the upper limit is the solution. So it is implicit.

  Integrate[ - a^2/(10 Sqrt[a (a^3 - 100 a + 200)]), a] // InputForm

Mathematica graphics

This is helpless to try to continue along this route.


AsymptoticDSolveValue[{ode /. {En -> 10, L -> 100, mass -> 1}, 
  r[0] == 10000, r'[0] == -10}, r[x], {x, 0, 4}]

But it could not solve it even using Asymptotic methods.

I would suggest to stick to numerical solver for such complicated nonlinear ODE's. May be someone else have other ideas.

  • $\begingroup$ Thank you for the answer! $\endgroup$
    – user72371
    Apr 29, 2020 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.