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] + 2 Log[Cosh[1/2 (2 I C[1] + Log[t])]]}} *)


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

  • $\begingroup$ 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 $\endgroup$ Jun 16, 2020 at 14:34
  • $\begingroup$ @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 $\endgroup$
    – apt45
    Jun 16, 2020 at 14:35
  • 1
    $\begingroup$ @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. $\endgroup$ Jun 16, 2020 at 14:40
  • $\begingroup$ 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. $\endgroup$
    – yarchik
    Jun 16, 2020 at 14:53

2 Answers 2


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]

enter image description here

sol = TrigToExp[sol]

enter image description here

sol = Simplify[sol]

enter image description here

But Exp[I C[1]] is constant, say C[3] then Exp[2 I C[1]] is C[3]^2. Therefore we can do this

sol /. {Exp[-I C[1]] -> 1/C[3], Exp[2 I C[1]] -> C[3]^2}

enter image description here

You used k for one constant and c for the second. The above used C[2] and C[3]

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;

$$ 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] + 2*Log[(1 + t*C[3]^2)/(2*Sqrt[t]*C[3])]]]

(* 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[1] -> -(Log[-k]/(2 I)), C[2] -> 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.


Your Answer

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

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