# Two solutions for the same ODE

I want to solve the following differential equation

$$-\frac{1}{t}f'(t)-\frac{1}{2}f'(t)^2-f''(t)+\frac{1}{2t^2}=0$$

for $$t \in \mathbb{R}$$. This can be done by hand. In particular, writing $$g(t)= f'(t)$$ and $$g(t)=\nu(t)-1/t$$, one can write the equation in the following form

$$-\frac{1}{2}\nu(t)^2-\nu'(t)=0$$

which has the solution $$\nu(t) = \frac{2}{t-k}$$ for some constant $$k\in \mathbb{R}$$. Therefore,

$$f(t) = \int dt \left(\frac{2}{t-k}-\frac{1}{t}\right) = 2\ln|t-k|-\ln|t|+c$$ for some constant $$c \in \mathbb{R}$$.

Why is Mathematica returning instead $$f(t) = c_2 + 2\ln(\cosh(\frac{1}{2}(2i c_1 + \ln(t)))$$ with the following command?

-1/t f'[t] - 1/2 f'[t]^2 - f''[t] + 1/(2 t^2) == 0 // DSolve[#, f[t], t] &
(*Out:{{f[t] -> C + 2 Log[Cosh[1/2 (2 I C + Log[t])]]}} *)


EDIT

The solution returned by Mathematica seems to be different from $$f(t)=2\ln|t-k|-\ln|t|+c$$.

• Because it satisfies the equation.Try: eq = -1/t f'[t] - 1/2 f'[t]^2 - f''[t] + 1/(2 t^2) == 0; sol = DSolve[eq, f, t]; eq /. sol // FullSimplify Jun 16, 2020 at 14:34
• @MariuszIwaniuk Sure, it is a solution. I have checked it. The two solutions (mine and the one of Mathematica) however are very different. Mine is always real, the solution given by Mathematica might have an imaginary part Jun 16, 2020 at 14:35
• @apt45: It might, yes, but I suspect that for some values of $c_1$ and $c_2$ you can guarantee it's real. As an analogy, consider the solution to the equation $x''(t) = - x(t)$. We often write the general solution as $x = A e^{it} + B e^{-it}$. Depending on how we pick the constants $A$ and $B$, this solution may or may not have an imaginary part. Jun 16, 2020 at 14:40
• It is better to compare the solutions to the Cauchy problem, which we know should be analytic and unique in some neighborhood of the given point. Jun 16, 2020 at 14:53

It is the same solution

ClearAll[f, t];
ode = -1/t f'[t] - 1/2 f'[t]^2 - f''[t] + 1/(2 t^2) == 0
sol = f[t] /. First@DSolve[ode, f[t], t] sol = TrigToExp[sol] sol = Simplify[sol] But Exp[I C] is constant, say C then Exp[2 I C] is C^2. Therefore we can do this

sol /. {Exp[-I C] -> 1/C, Exp[2 I C] -> C^2} You used k for one constant and c for the second. The above used C and C

Maple gives

ode:= -1/t*diff(f(t),t) - 1/2*diff(f(t),t)^2 -diff(f(t),t\$2) + 1/(2*t^2) = 0;
dsolve(ode)


$$f \left( t \right) =\ln \left( {\frac { \left( -t{\it \_C2}+{\it \_C1 } \right) ^{2}}{4\,t}} \right)$$

Which if you want to work at it, will see it is the same.

To verify this in Mathemtica:

Simplify[ode /.
f -> Function[{t}, C + 2*Log[(1 + t*C^2)/(2*Sqrt[t]*C)]]]

(* True *)

foo = f[t]/. (-1/t f'[t] - 1/2 f'[t]^2 - f''[t] + 1/(2 t^2) == 0 // DSolve[#, f[t], t] &);

Simplify[TrigToExp[ foo //. {C -> -(Log[-k]/(2 I)), C -> c - 2 Log[Sqrt[-k/2]]}]]

(* c - Log[-2 k] + 2 Log[(-k + t)/(Sqrt[-k] Sqrt[t])] *)


In this latter form, the equivalence of the two solutions should be more obvious.