# How can I get DSolve to solve my ODE?

I evaluated

DSolve[{x[t] x''[t] + x'[t]^2 - g x[t] == 0, x[0] == 0, x'[0] == 0}, x, t]


and the output was {}. But this ODE actually has solutions x[t] = 0 or x[t] = 1/6*g*t^2

I was able to solve this ODE with Maple 14

How can I get the same solutions from Mathematica?

• Mathematica does return something for DSolve[{x[t] x''[t] + x'[t]^2 - g x[t] == 0}, x[t], t]. But I believe it's wrong – Dr. belisarius Sep 3 '14 at 14:03
• This is another good example of how to solve a problem in close cooperation between man (user) and machine (=MMA): Look for the solution of v(x) first, observing the initial conditions you will find v(x) = Sqrt(3 x/2). Then you calculate t(x) to be Sqrt(6 x) from which the solution follows. – Dr. Wolfgang Hintze Sep 3 '14 at 14:23
• Related: 24594, 47550, 57910 – Michael E2 Sep 3 '14 at 14:30

The basic problem is a singularity at the initial condition and what Artes explained as the genericity of solution in his answer to DSolve not finding solution I expected.

DSolve will find a general solution. It returns an expression in terms of InverseFunction that is long and difficult to evaluate. But it has trouble with the IVP at the singularity because one of the initial conditions ends up in a denominator (and perhaps for other reasons, too). This is the genericity problem: the solution works for almost all initial values (i.e. generically) but not the OP's.

The textbook method of reduction of order when the independent variable is missing from the differential equation can be carried out with the substitutions

{x'[t] -> v[x], x''[t] -> v'[x] v[x], x[t] -> x}


The result differential equation is integrated and the solution is equated to x'[t]; this new equation can then be integrated. The default DSolve command results in an equivalent general solution. The two methods below give equivalent general solutions. The results are long and have been omitted.

xde = x[t] x''[t] + x'[t]^2 - g x[t] == 0;

gensol = DSolve[{x[t] x''[t] + x'[t]^2 - g x[t] == 0}, x, t]

DSolve[xde /. {x'[t] -> v[x], x''[t] -> v'[x] v[x], x[t] -> x}, v, x]
gensol2 = DSolve[x'[t] == v[x[t]] /. #, x, t] & /@ %


One can insert the initial condition into the second method, which is how I interpret Dr. Wolfgang Hintze's comment. The result is nontrivial desired solution.

DSolve[{xde /. {x'[t] -> v[x], x''[t] -> v'[x] v[x], x[t] -> x}, v[0] == 0}, v, x]
DSolve[{x'[t] == v[x[t]] /. #, x[0] == 0}, x, t] & /@ %


Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>

Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>

(*
{{v -> Function[{x}, -((Sqrt[2/3] Sqrt[g x^3])/x)]},
{v -> Function[{x},   (Sqrt[2/3] Sqrt[g x^3])/x]}}

{{{x -> Function[{t}, (g t^2)/6]}}, {{x -> Function[{t}, (g t^2)/6]}}}
*)


Assuming DSolve is in fact applying this reduction of order method, it perhaps waits until the full general solution is obtained before applying the initial condition. But if the initial condition were to be incorporated at each integration, the solution would be found.

The singularity

Originally, I looked into the singularity for fun to see if I could find a way to trick DSolve into finding the solution. The above one seemed simplest in the end. But the graphics below are neat, and someone might like to see how to do it.

The differential equation defines a surface in the space with coordinates {x, p, q} == {x[t], x'[t], x''[t]}. It also defines a flow on the surface. These are pictured below.

Block[{x, g = 1, p, q, plot},
x[t] = x; x'[t] = p; x''[t] = q;
plot = ContourPlot3D @@ List[xde, {x, -2, 2}, {p, -1, 1}, {q, -1, 3},
Mesh -> None, ContourStyle -> Opacity[0.5],
AxesLabel -> HoldForm /@ {x, p, q},
PlotLabel -> HoldForm @@ {xde}];
x'[t] =.; x''[t] =.;
xdevf = StreamPlot[{p, (x - p^2)/x}, {x, -2, 2}, {p, -1, 1}];
xdeplot =
Show[plot,
Graphics3D[
xdevf[[1]] /. a_Arrow :> (a /. {{x0_Real, p0_Real} :> {x0, p0, (x0 - p0^2)/x0}})
]]
];

GraphicsRow[{
Show[xdeplot, ViewPoint -> Top],
Show[xdeplot, ViewPoint -> Front],
Show[xdeplot, ViewPoint -> {-2, 0, 0}]}]


The view of the singularity on the right suggests that a step in resolving the singularity could be the change of variables q = v p. This turns out to be equivalent to the textbook reduction of order method, which is neat.

Another approach

Note that the terms x[t] x''[t] + x'[t]^2 in the differential equation is the second derivative of x[t]^2. One could make the substitution u[t] == x[t]^2 and work from there.