I happen to know that the equation $$0=-\lambda \phi (t)^3+\mu ^2 \phi (t)+\phi ''(t)$$ has a simple solution: $$\phi(t) = \frac{\mu \tanh \left(\frac{\mu \left(t-t_0\right)}{\sqrt{2}}\right)}{\sqrt{\lambda }}$$ which is easily verified:

    {eqn, \[Phi]},
    \[Phi][t_] := \[Mu]/Sqrt[\[Lambda]] Tanh[(\[Mu] (t - t0))/Sqrt[2]];
    eqn = \[Phi]''[t] + \[Mu]^2 \[Phi][t] - \[Lambda] \[Phi][t]^3 == 0;
  Assumptions -> And[\[Mu] > 0, \[Lambda] > 0, t > t0]]

But Mathematica has a hard time providing a useful solution. It gives some very strange functions which I cannot reduce in any way to the known solution. In fact if you plot them they look like the given solution, rotated by 90 degrees. Is there a way to get it to simplify? Do not suppose the form of the solution given above in your answer to the question. How could you use Mathematica to find it? Here is the present solution using DSolve:

$$\left\{\left\{\phi (t)\to -\frac{2 i c_1 \sqrt{\lambda } \sqrt{-\frac{1}{\mu ^2-\sqrt{\mu ^4-2 c_1 \lambda }}} \text{sn}\left(\frac{\sqrt{\mu ^2 t^2+\sqrt{\mu ^4-2 \lambda c_1} t^2+2 \mu ^2 c_2 t+2 \sqrt{\mu ^4-2 \lambda c_1} c_2 t+\mu ^2 c_2{}^2+\sqrt{\mu ^4-2 \lambda c_1} c_2{}^2}}{\sqrt{2}}|\frac{\mu ^2-\sqrt{\mu ^4-2 \lambda c_1}}{\mu ^2+\sqrt{\mu ^4-2 \lambda c_1}}\right)}{\mu ^2+\sqrt{\mu ^4-2 c_1 \lambda }}\right\},\left\{\phi (t)\to \frac{2 i c_1 \sqrt{\lambda } \sqrt{-\frac{1}{\mu ^2-\sqrt{\mu ^4-2 c_1 \lambda }}} \text{sn}\left(\frac{\sqrt{\mu ^2 t^2+\sqrt{\mu ^4-2 \lambda c_1} t^2+2 \mu ^2 c_2 t+2 \sqrt{\mu ^4-2 \lambda c_1} c_2 t+\mu ^2 c_2{}^2+\sqrt{\mu ^4-2 \lambda c_1} c_2{}^2}}{\sqrt{2}}|\frac{\mu ^2-\sqrt{\mu ^4-2 \lambda c_1}}{\mu ^2+\sqrt{\mu ^4-2 \lambda c_1}}\right)}{\mu ^2+\sqrt{\mu ^4-2 c_1 \lambda }}\right\}\right\}$$


4 Answers 4


Applying the chain rule \[Phi]''[t]==\[Phi]s[\[Phi]] \[Phi]s'[\[Phi]]the ode can be reduced to first order for \[Phi]s[\[Phi]]==\[Phi]'[t] .

From the initial ode we know \[Phi]''[0]==0( because \[Phi][0]==0 ) which implies \[Phi]s[\[0]]==0

sol = DSolve[{\[Phi]s[\[Phi]] \[Phi]s'[\[Phi]] + \[Mu]^2 \[Phi] - \[Lambda] \[Phi] ^3 == 0 ,\[Phi]s[0]\[Equal]0  }, \[Phi]s, \[Phi]]

    (*{{\[Phi]s -> Function[{\[Phi]}, -(Sqrt[-\[Phi]^2 (2 \[Mu]^2 - \[Lambda] \[Phi]^2)]/Sqrt[2])]}, 
    {\[Phi]s ->Function[{\[Phi]},Sqrt[-\[Phi]^2 (2 \[Mu]^2 - \[Lambda] \[Phi]^2)]/Sqrt[2]]}}*)

Transforming back into time space we get for t[\[Phi]]

Integrate[1/\[Phi]s[\[Phi]] /. sol, \[Phi] ]// Simplify[#, \[Phi] > 0] &
(*{-(ArcTan[Sqrt[-\[Mu]^2 + (\[Lambda] \[Phi]^2)/2]/\[Mu]]/\[Mu]), ArcTan[Sqrt[-\[Mu]^2 + (\[Lambda] \[Phi]^2)/2]/\[Mu]]/\[Mu]}*)

Dissolve after \[Phi] gives the expected solution!


Perhaps phasespace gives some more insight

  Show[{StreamPlot[{\[Phi]p, -\[Mu] \[Phi] + \[Lambda] \[Phi]^3}, {\
\[Phi], -Pi/2, Pi/2}, {\[Phi]p, 0, 1}, 
     FrameLabel -> {"\[Phi]", "\[Phi]'[\[Phi]]"}], 
     Evaluate[{(\[Mu] Tanh[(t \[Mu])/Sqrt[2]])/Sqrt[\[Lambda]], 
       D[(\[Mu] Tanh[(t \[Mu])/Sqrt[2]])/Sqrt[\[Lambda]], 
        t]}], {t, -Pi , Pi }, PlotStyle -> Red]}], {{\[Lambda], 1}, 0,
    3, Appearance -> "Labeled"}, {{\[Mu], 1}, 0, 3, 
   Appearance -> "Labeled"} , ControlPlacement -> {Top }] 

enter image description here

Red curve is the special solution (OP's simple solution) which separates stable and unstable regions (separatrix)

  • $\begingroup$ Clever! Is there a name for this technique-- integrating factor or some such? $\endgroup$
    – Diffycue
    Commented Apr 20, 2022 at 16:31
  • $\begingroup$ Perhaps "Separation of variables" but I'm unsure. See Autonomous in MathWorld/Weisstein $\endgroup$ Commented Apr 20, 2022 at 16:34
  • $\begingroup$ @Diffycue So when Ulrich uses the solution to derive the solution it's ok, but not Bob? (Ulrich uses \[Phi][0]==0, without which we get the general solution in terms of theta functions.) $\endgroup$
    – Michael E2
    Commented Apr 20, 2022 at 16:43
  • $\begingroup$ @MichaelE2 One answer is helpful and the other is not. Is it so hard to see? $\endgroup$
    – Diffycue
    Commented Apr 20, 2022 at 16:54
  • 1
    $\begingroup$ @Diffycue Yes, it is. Both are helpful. OTOH it is not hard to see that one is based on weaker hypotheses. It's also possible to solve the problem without any hypotheses. -- Ulrich is right to point out autonomous, which implies the order may be reduced as he showed. -- What's hard to see is why ask for a solution you already know? But motivations don't matter a lot to me. $\endgroup$
    – Michael E2
    Commented Apr 20, 2022 at 16:59

In general our equation can be rewritten as a first order ODE if we multiply it by $\;\phi'(t)$ and integrate once: $$0=-\lambda \phi (t)^3 \phi'(t)+\mu ^2 \phi (t) \phi'()t+\phi ''(t) \phi'(t)$$ $$0=-\frac{c_1}{4}-\frac{\lambda}{4} \phi (t)^4 +\frac{\mu ^2}{2} \phi(t)^2 +\frac{\phi'(t)^2}{2}$$ This is a standard technique of recasting certain autonomous nonlinear second order ODEs to first order ones, usually used in case of elliptic functions underlying behind.
Now we can rewrite it in the following way: $$\int\frac{ dt}{\sqrt{2}}=\int \frac{d w}{\sqrt{w^4 -2\mu ^2 w^2 +c}}$$ where $w =\sqrt{\lambda}\; \phi\;$ and $c_1 \lambda =c$. The rhs in general is an elliptic integral an cannot be calculated in terms of elementary functions (this Integrate[1/Sqrt[w^4 -2 \[Mu]^2 w^2 + c], w] // TraditionalForm yields

enter image description here

and an inverse function is an elliptic function expressed in terms of JacobiSN which we get when solving this ODE without initial conditions),

however for a special case when $c=\mu^4$ it might be reduced to $$\int \frac{d w}{w^2 -\mu ^2}=-\frac{arcth(\frac{w}{\mu})}{\mu}$$ and this is the case of the solution in the question.


eqn = ϕ''[t] + μ^2 ϕ[t] - λ ϕ[t]^3 == 0;

rule = ϕ -> (μ/Sqrt[λ] Tanh[(μ (# - t0))/Sqrt[2]] &);

eqn /. rule // Simplify

(* True *)

To get the desired form you need consistent initial conditions.

{ϕ0, ϕp0} = {ϕ[0], ϕ'[0]} /. rule

(* {-((μ Tanh[(t0 μ)/Sqrt[2]])/Sqrt[λ]), 
    (μ^2 Sech[(t0 μ)/Sqrt[2]]^2)/(Sqrt[2] Sqrt[λ])} *)

Using the initial conditions

sol = DSolve[{eqn, ϕ[0] == ϕ0, ϕ'[0] == ϕp0}, ϕ, t][[1]]

(* {ϕ -> Function[{t}, (μ Tanh[1/2 (Sqrt[2] t μ - Sqrt[2] t0 μ)])/

(ϕ[t] /. sol // Simplify) === (ϕ[t] /. rule)

(* True *)
  • $\begingroup$ Maybe I misunderstand your solution, but I don't see how this contributes anything. $\endgroup$
    – Diffycue
    Commented Apr 20, 2022 at 16:14
  • 1
    $\begingroup$ You asked how to get Mathematica to give the known solution. This shows that if you give initial conditions consistent with the desired solution then you will get the desired form. $\endgroup$
    – Bob Hanlon
    Commented Apr 20, 2022 at 16:18
  • $\begingroup$ But in generating those conditions it was required to use the known form, which was forbidden: "Imagine that you did not know the solution above but had the intuition that the result could not be too complicated.". This seems only to add an additional step in verifying the known answer. $\endgroup$
    – Diffycue
    Commented Apr 20, 2022 at 16:22
  • $\begingroup$ There are an infinite number of solutions as shown in the general solution with the arbitrary constants. All of these solutions are correct; none are excluded until you specify some initial conditions. Without specifying consistent conditions there is no reason to prefer your desired form over any other. All you can then ask for is to verify that there exists a set of arbitrary constants that reduces the general solution to your desired solution. $\endgroup$
    – Bob Hanlon
    Commented Apr 20, 2022 at 16:33

If we look up the Jacobi theta functions in the DLMF, we'll find limiting values not included in the expressions returned by DSolve. They lie on the closure of the solution manifold, and it is typical for the general solution returned by DSolve to be missing such special solutions.

Following the implicit advice of the DLMF, we can recover the complete solution.

eqn = ϕ''[t] + μ^2 ϕ[t] - λ ϕ[t]^3 == 0;
dsol = DSolve[{eqn}, ϕ, t];

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

Length@dsol            (* two solutions *)
ϕ[t] /. dsol // Total  (* of opposite signs *)
phisol = ϕ[t] /. First@dsol // FullSimplify (* show just one *)

$$\frac{\displaystyle i\, \text{sn}\left(\frac{\sqrt{\left(\mu ^2+\sqrt{\mu ^4-2 \lambda c_1}\right) (t+c_2){}^2}}{\displaystyle \sqrt{2}}\,\Bigg|\,\frac{\displaystyle \mu ^4-\sqrt{\mu ^4-2 \lambda c_1} \mu ^2-\lambda c_1}{\lambda c_1}\right)}{\sqrt{\frac{\displaystyle \lambda }{\displaystyle -\mu ^2+\sqrt{\mu ^4-2 c_1 \lambda }}}}$$

One limiting value is the limit of $\text{sn}(z,k)$ as $k\rightarrow1$. This yields the solution the desired by the OP, if we clean it up with some assumptions about the parameters:

lim = Solve[(μ^4 - λ C[1] - μ^2 Sqrt[μ^4 - 2 λ C[1]])/(λ C[1]) == 1, 
   C[1]][[1, 1]]
(*  C[1] -> μ^4/(2 λ)  *)
Limit[phisol, lim] // Simplify[#, {λ, μ} ∈ PositiveReals] &

$$\frac{\mu \tanh \left(\frac{\mu \sqrt{(t+c_2){}^2}}{\sqrt{2}}\right)}{\sqrt{\lambda }}$$

The other limiting value is the limit of $\text{sn}(z,k)$ as $k\rightarrow0$. This yields a solution even simpler than the one desired by the OP, namely the trivial solution. This is impossible to solve for algebraically directly from the expression for $k$. Instead we solve for an ansatz and verify it.

(* numerator of k *)
Solve[μ^4 - λ C[1] - μ^2 Sqrt[μ^4 - 2 λ C[1]] == 0, C[1]]

Solve::nongen: There may be values of the parameters for which some or all solutions are not valid.

(*  {{C[1] -> 0}}  *)
(* limit of k *)
Limit[(μ^4 - λ C[1] - μ^2 Sqrt[μ^4 - 2 λ C[1]])/(λ C[1]),
  C[1] -> 0,
  Assumptions -> μ ∈ Reals]
(*  0  *)
  • $\begingroup$ Super cool, thank you! The strategy here should be useful in all sorts of cases. $\endgroup$
    – Diffycue
    Commented Apr 20, 2022 at 17:43
  • $\begingroup$ @Diffycue Usually it's the limit as C[1] (or C[2] etc.) goes to infinity, but that limit doesn't exist here. $\endgroup$
    – Michael E2
    Commented Apr 20, 2022 at 17:47

Your Answer

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

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