1
$\begingroup$

I'm trying to solve the following ODE

$\frac{df}{dx}=-\sqrt{2}\left(\frac{1}{4}-2f(x)^{2}\right)$

In the text where it appears, the authors make a distinction into three cases: $f=-1/(2\sqrt{2})$, $f<-1/(2\sqrt{2})$ and $f>-1/(2\sqrt{2})$ depending on the sign of the right hand side of the equation. Further, $f(x)$ is a negative function.

When I give it into Mathematica with DSolve as

 DSolve[D[f[x],x]==-Sqrt[2]*(1/4-2*f[x]^2),f[x],x]

it only gives me the $\tanh$ solution, which according to the text corresponds to the case $f>-1/(2\sqrt{2})$. For the case $f<-1/(2\sqrt{2})$ I'm supposed to be getting a $\coth$ solution but don't see how.

Where are two other cases? Thank you for any help.

$\endgroup$
9
  • 1
    $\begingroup$ Closely related: DSolve not finding solution I expected. $\endgroup$
    – Artes
    Commented Mar 8, 2016 at 6:53
  • $\begingroup$ @Artes I wouldn't say it's closely related (I read through that thread before posting the question) since the case discussed there does have some initial data, which makes it possible to find an alternative way of finding other solutions, and I don't have any further conditions. $\endgroup$
    – GregVoit
    Commented Mar 8, 2016 at 6:55
  • 1
    $\begingroup$ Even though you don't specify the initial data, to get different classes of solutions you should somehow make the system return desired solutions, if not by the initial value. In principle, this is a different aspect of the same issue. DSolve doesn't find all solutions, rather generic ones. $\endgroup$
    – Artes
    Commented Mar 8, 2016 at 7:02
  • 1
    $\begingroup$ You can use e.g. sols = (Table[ DSolve[D[f[x], x] == -Sqrt[2]*(1/4 - 2 f[x]^2) && f[0] == -(a/(2 Sqrt[2])), f[x], x], {a, -2, 0, 1/2}] // Quiet // Simplify // Flatten)[[All, 2]]; Plot[sols, {x, -2, 2}, Evaluated -> True] and compere the plots with e.g. Plot[{Tanh[x], Coth[x]}, {x, -2, 2}, Evaluated -> True]. In the first case you got both corresponding cases. $\endgroup$
    – Artes
    Commented Mar 8, 2016 at 7:25
  • 1
    $\begingroup$ We want solutions from different classes, thus we are varying a in such a way with Table to include solutions from the both classes. $\endgroup$
    – Artes
    Commented Mar 8, 2016 at 9:21

2 Answers 2

4
$\begingroup$

EDIT

Sorry. I have made a mistake in the choice of the initial conditions which is corrected below. This error does not change the general staetements.

Corrected exposition

As far as I can see there is no problem with the completeness of the solutions provided by Mathematica.

$Version

(* Out[16]= "10.1.0  for Microsoft Windows (64-bit) (March 24, 2015)" *)

The general solution to the ODE is found by Mathematica to be

sol = DSolve[f'[x] == -Sqrt[2] (1/4 - 2 f[x]^2), f[x], x]

(* Out[2]= {{f[x] -> -((-1 + E^(2 x + 4 Sqrt[2] C[1]))/(
    2 Sqrt[2] (1 + E^(2 x + 4 Sqrt[2] C[1]))))}} *)

As expected, the solution contains one arbitrary constant C[1].

The two branches of the solution correspond just to different choices of C[1].

Notice also that C[1] can be a complex number.

Let us have closer look on the situation.

The critical value of the function is

fc = -(1/(2 Sqrt[2]));

Now we complete the problem by imposing an initial condition on f.

And we distinguish two cases (here I am correcting my mistake of not imposing the condition of on the module)

(1) Abs[f[0]] < Abs[fc]:

ff1[x_] = f[x] /. 
  DSolve[f'[x] == -Sqrt[2] (1/4 - 2 f[x]^2) && f[0] == 1/4, f[x], x][[1]]

During evaluation of In[12]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>

    (* Out[14] = -((1 - 3 E^(2 x) + 2 Sqrt[2] E^(2 x))/(
 2 Sqrt[2] (-1 - 3 E^(2 x) + 2 Sqrt[2] E^(2 x))))    *)

(2) Abs[f[0]] > Abs[fc]:

ff2[x_] = f[x] /. 
  DSolve[f'[x] == -Sqrt[2] (1/4 - 2 f[x]^2) && f[0] == 2, f[x], x][[1]]

During evaluation of In[14]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>

(* Out[15] = -((-7 - 9 E^(2 x) + 4 Sqrt[2] E^(2 x))/(
 2 Sqrt[2] (7 - 9 E^(2 x) + 4 Sqrt[2] E^(2 x)))) *)

and compare the results in a plot:

Plot[{ff1[x], ff2[x]}, {x, 0, 3}, 
 PlotLabel -> "Solution of ODE\nblue curve = ff1, yellow curve = ff2",
  PlotRange -> {-2, 2}]

enter image description here

Summarizing: Mathematica in fact provides the general solution. This includes automatically the cases mentioned in the OP which correspond just to different initial conditions.

$\endgroup$
1
$\begingroup$

If we solve for a general initial condition at x == 0, we get the following:

dsol = DSolve[{D[f[x], x] == -Sqrt[2]*(1/4 - 2*f[x]^2), f[0] == F0}, f, x];
{dsol} = dsol /. 
  HoldPattern@Function[v_, body_] :> Function @@ {v, FullSimplify[body]}

Solve::ifun: Inverse functions are being used.... >>

(*
  {{f -> Function[{x}, (4 F0 Cosh[x] - Sqrt[2] Sinh[x]) / 
     (4 Cosh[x] - 8 Sqrt[2] F0 Sinh[x])]}}
*)

You can see the solution contains all three cases (for a negative f) as follows:

Reduce[F0 < 0 && f[x] < 0 && y == f[x] /. dsol, {F0, x, y}, Reals, 
    Backsubstitution -> True] /. Or | And -> List /. 
  x > _ :> Sequence[] // Grid

Mathematica graphics

Whether to write the nontrivial solutions in terms of Tanh or Coth, or even as above, seems a matter of taste.

-Sqrt[2]/4 Tanh[x - ArcTanh[4 F0/Sqrt[2]]] - f[x] /. dsol // TrigExpand // Simplify
-Sqrt[2]/4 Coth[x - ArcCoth[4 F0/Sqrt[2]]] - f[x] /. dsol // TrigExpand // Simplify
(*  0  *)
$\endgroup$
1
  • $\begingroup$ In V13, DSolve[D[f[x], x] == -Sqrt[2]*(1/4 - 2*f[x]^2), f[x], x, IncludeSingularSolutions -> True] now gives answers that include the limiting values as the constant of integration C[1] approaches zero and infinity. $\endgroup$
    – Michael E2
    Commented Jul 21, 2022 at 23:43

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.