0
$\begingroup$

The solving of an ODE problem in version 13 on Windows 10

sol = DSolve[{x'[t] == Sqrt[1 - 2 x[t]^2]^2 + x[t]*Sqrt[1 - 2 x[t]^2],
x[0] == 0}, x, t]

{{x -> Function[{t}, ( 2 (Sqrt[3] Tanh[(Sqrt[3] t)/2] + Tanh[(Sqrt[3] t)/2]^2))/( 3 + 2 Sqrt[3] Tanh[(Sqrt[3] t)/2] + 3 Tanh[(Sqrt[3] t)/2]^2)]}, {x -> Function[{t}, (2 (Sqrt[3] Tanh[1/2 (Sqrt[3] t - 2 ArcTanh[Sqrt[3]])] + Tanh[1/2 (Sqrt[3] t - 2 ArcTanh[Sqrt[3]])]^2))/(3 + 2 Sqrt[3] Tanh[1/2 (Sqrt[3] t - 2 ArcTanh[Sqrt[3]])] + 3 Tanh[1/2 (Sqrt[3] t - 2 ArcTanh[Sqrt[3]])]^2)]}}

brings two solutions and this contradicts the existence and uniqueness of the solution of the Cauchy problem. The above is not a usual technical bug in Mathematica. A bunch of problems related to that ODE problem appears. First, the results of

Plot[(x'[t] - Sqrt[1 - 2 x[t]^2]^2 - x[t]*Sqrt[1 - 2 x[t]^2]) /. 
sol[[1]], {t, 0, 5}, PlotRange -> All] 

enter image description here

and

Plot[(x'[t] - Sqrt[1 - 2 x[t]^2]^2 - x[t]*Sqrt[1 - 2 x[t]^2]) /. sol[[2]], {t, 0, 5}]

enter image description here

demonstrate that sol[[1]] is not a solution of that ODE at all and sol[[2]] is its solution only on the interval $[0,t_0]$ with $t_0\approx 1.04$.

Second, the command

FullSimplify[{x'[t] - Sqrt[1 - 2 x[t]^2]^2 - x[t]*Sqrt[1 - 2 x[t]^2], 
x[0] == 0} /. sol[[2]], Assumptions -> t >= 0 && t <= 1]

is running without any response on my comp during more than two hours. Likely an infinite loop is accomplished here as well as in many, many other commands of Mathematica since the resourses of my comp are not exhausted (40 - 50 % of its processor and 200 - 350 MB of its ROM).

Third, when numerically solving the problem under consideration by

soln = NDSolve[{x'[t] == Sqrt[1 - 2 x[t]^2]^2 + x[t]*Sqrt[1 - 2 x[t]^2], x[0] == 0}, 
x, {t, 0, 5}, MaxSteps -> 10^6];
Plot[Evaluate[x[t] /. soln], {t, 0, 2}, PlotRange -> All]

enter image description here

, one obtains the solution only on the interval $[0,t_0]$ with $t_0\approx 1.04$.

For comparison, Maple 2022 results in x(t) = RootOf(t + Int(-1/(1 - 2*_a^2 + _a*sqrt(-2*_a^2 + 1)), _a = 0 .. _Z)) for the symbolical solution and the same result as Mathematica for the numeric solution.

I think the above problems are caused by

x[1.04] /. sol[[2]]

0.707105 - 9.74433*10^-20 I

so DSolve and NDSove are not able to go over the branch point of Sqrt[1 - 2 x[t]^2] at $t_0\approx 1.04$.

The questions arise: is there a workaround? how to continue the solution for $t \ge t_o$?

$\endgroup$
15
  • 1
    $\begingroup$ @MariuszIwaniuk should not the solution exist inside a thin strip bounded by $x=\pm \frac{1}{4}$? This is because looking at the RHS of the ode, and taking derivative w.r.t $x$, it is undefined at $x^2=1/2$. Since initial conditions at $x(0)=0$, then a unique solution exist somewhere inside this strip, including the origin, and up to $ x=\pm\frac{1}{4}$. so the assumption should be $x<1/4$. Or did I overlook something? $\endgroup$
    – Nasser
    Commented Apr 19, 2022 at 11:27
  • 1
    $\begingroup$ @Nasser: Can you elaborate "Since initial conditions at $x(0)=0$, then a unique solution exist up to $x=\pm \frac 1 4$"? I don't understand it. TIA. $\endgroup$
    – user64494
    Commented Apr 19, 2022 at 11:31
  • 2
    $\begingroup$ I am applying first order ODE existence and uniqueness theorem. Writing the ode as $x'=F(x,t)$, then $\frac{\partial F}{\partial x}$ shows that it becomes undefined at $x^2=\frac{1}{2}$. And since origin must lie on the solution path, the solution exists in some strip up to $x=\pm \frac{1}{4}$ $\endgroup$
    – Nasser
    Commented Apr 19, 2022 at 11:38
  • 1
    $\begingroup$ Opps, I've been writing $\pm \frac{1}{4}$ everywhere, when it should be $\pm \frac{1}{\sqrt 2}$. Any way, this is what the limit should have been, yes. $\endgroup$
    – Nasser
    Commented Apr 19, 2022 at 12:04
  • 1
    $\begingroup$ It all seems fairly obvious from the general solution (IC is satisfied for infinitely many values of the integration parameter $C$, and luckily we got a valid one from DSolve) and elementary considerations (all real solutions reach $x=1/\sqrt{2}$ in finite time). I think I'd call it a typical DSolve technical problem and maybe not even a bug. Better to get a valid solution (sol[[2]]) than none at all, imo, since in this case it seems it is difficult, if not impossible, for DSolve to prove rigorousy each member of sol is a solution. $\endgroup$
    – Goofy
    Commented Apr 19, 2022 at 18:04

1 Answer 1

1
$\begingroup$

Edit2

Defining a piecewise function according to the result of ndsol (which is equal to analytical solution xsol = x /. DSolve[{eq, x[0] == 0}, x, t] below 1.04) proofs this to be a valid solution.

xn = Function[t, 
  Evaluate[Piecewise[{{xsol[[1]][t] // FullSimplify, 
      0 <= t <= Log[1 + Sqrt[3] + Sqrt[6 + 3 Sqrt[3]]]/Sqrt[3]}}, 
    1/Sqrt[2]]]]

Plot[Evaluate[xn[t]], {t, 0, 3}, PlotRange -> All]

Plot[Evaluate[(Subtract @@ eq) /. x -> xn], {t, 0, 3}, 
 PlotRange -> All, PlotStyle -> Thick]

enter image description here

I'm working with the older version "8.0 for Microsoft Windows (32-bit) (December 9, 2010)"

Another way: Splitting x[t] explicitly in real and imaginary part by x -> (a[#] + I b[#] &) Get same results, See below.

You get at least a numerical solution beyond t == Log[1 + Sqrt[3] + Sqrt[6 + 3 Sqrt[3]]]/Sqrt[3] where x[t] == 1/Sqrt[2] if you NDSolve the complexExpanded equation.

eq = x'[t] == Sqrt[1 - 2 x[t]^2]^2 + x[t]*Sqrt[1 - 2 x[t]^2];

ceeq = ComplexExpand[eq, TargetFunctions -> {Re, Im}] // Simplify

(*   2 x[t]^2 + Derivative[1][x][t] == 
 1 + (Cos[1/2 ArcTan[1 - 2 x[t]^2, 0]] + 
     I Sin[1/2 ArcTan[1 - 2 x[t]^2, 0]]) x[t] ((1 - 2 x[t]^2)^2)^(1/4)   *)

xsol = x /. 
  Flatten@NDSolve[{ceeq, x[0] == 0}, x, {t, 0, 5}, MaxSteps -> 10^6]

(*   NDSolve::mxst: Maximum number of 1000000 steps reached at the point t == 3.014453178076721`. >>   *)

Plot[{Re@xsol[t], Im@xsol[t]}, {t, 0, 3}, PlotRange -> All, 
 PlotStyle -> {Blue, {Thick, Red}}]

enter image description here

You see, beyond the critical point, solutions remains constant.

Test with leftsided equation confirms this solution.

Plot[Evaluate[Through[{Re, Im}[Subtract @@ eq /. x -> xsol]]], {t, 0, 
  3}, PlotRange -> All, PlotStyle -> {Blue, Red}]

Edit

eq = x'[t] == Sqrt[1 - 2 x[t]^2]^2 + x[t]*Sqrt[1 - 2 x[t]^2]

ff2 = (Subtract @@ eq) /. x -> (a[#] + I b[#] &)

(*   -1 - Sqrt[1 - 2 (a[t] + I b[t])^2] (a[t] + I b[t]) + 
 2 (a[t] + I b[t])^2 + Derivative[1][a][t] + I Derivative[1][b][t]   *)

cere = ComplexExpand[Re@ff2, TargetFunctions -> {Re, Im}] // Simplify

(*   -1 + 2 a[t]^2 - 2 b[t]^2 - 
 a[t] (16 a[t]^2 b[t]^2 + (1 - 2 a[t]^2 + 2 b[t]^2)^2)^(1/4)
   Cos[1/2 ArcTan[1 - 2 a[t]^2 + 2 b[t]^2, -4 a[t] b[t]]] + 
 b[t] (16 a[t]^2 b[t]^2 + (1 - 2 a[t]^2 + 2 b[t]^2)^2)^(1/4)
   Sin[1/2 ArcTan[1 - 2 a[t]^2 + 2 b[t]^2, -4 a[t] b[t]]] + 
 Derivative[1][a][t]   *)

ceim = ComplexExpand[Im@ff2, TargetFunctions -> {Re, Im}] // Simplify

(*   4 a[t] b[t] - 
 b[t] (16 a[t]^2 b[t]^2 + (1 - 2 a[t]^2 + 2 b[t]^2)^2)^(1/4)
   Cos[1/2 ArcTan[1 - 2 a[t]^2 + 2 b[t]^2, -4 a[t] b[t]]] - 
 a[t] (16 a[t]^2 b[t]^2 + (1 - 2 a[t]^2 + 2 b[t]^2)^2)^(1/4)
   Sin[1/2 ArcTan[1 - 2 a[t]^2 + 2 b[t]^2, -4 a[t] b[t]]] + 
 Derivative[1][b][t]   *)

ndsol = NDSolve[{cere == 0, ceim == 0, a[0] == 0, b[0] == 0}, {a, 
   b}, {t, 0, 3}, MaxSteps -> 10^6]

(*   NDSolve::mxst: Maximum number of 1000000 steps reached at the point t == 2.4880047588617566`. >>  *)

Plot[Evaluate[{a[t], b[t]} /. ndsol], {t, 0, 2.48}, PlotRange -> 1, 
 GridLines -> {{Log[1 + Sqrt[3] + Sqrt[6 + 3 Sqrt[3]]]/Sqrt[3]}, {1/
     Sqrt[2]}}, PlotStyle -> Thick]

enter image description here

Plot[Evaluate[Re[ff2 /. ndsol]], {t, 0, 2.48}]

enter image description here

Plot[Evaluate[Im[ff2 /. ndsol]], {t, 0, 2.48}]
$\endgroup$
10
  • $\begingroup$ Cannot reproduce it, obtaining an error "NDSolve::ntdv: Cannot solve to find an explicit formula for the derivatives. Consider using the option Method->{"EquationSimplification"->"Residual"}." and the returned inputx /. NDSolve[{I Im[Derivative[1][x][t]] + Re[Derivative[1][x][t]] + 2 x[t]^2 == 1 + (Cos[1/2 ArcTan[1 - 2 x[t]^2, 0]] + I Sin[1/2 ArcTan[1 - 2 x[t]^2, 0]]) x[t] ((1 - 2 x[t]^2)^2)^( 1/4), x[0] == 0}, x, {t, 0, 5}, MaxSteps -> 1000000]. Maybe, this is a session depending result. Thank you anyway. $\endgroup$
    – user64494
    Commented Apr 20, 2022 at 13:55
  • $\begingroup$ In view of it I have changed my mind, not accepting your answer and cancelling +1. $\endgroup$
    – user64494
    Commented Apr 20, 2022 at 14:01
  • $\begingroup$ Maybe substitute Re[x'[t]] -> x'[t] - I Im[x'[t]] in ceeq, or ComplexExpand only the right side. Also Method -> "StiffnessSwitching", since the solution reaches the equilibrium in finite time. $\endgroup$
    – Goofy
    Commented Apr 20, 2022 at 18:20
  • 1
    $\begingroup$ @MichaelE2, now show all the interim results. Working with version 8.0 $\endgroup$
    – Akku14
    Commented Apr 21, 2022 at 18:01
  • 1
    $\begingroup$ Did you get the same interim results for cere and ceim as i got? Use them directly. $\endgroup$
    – Akku14
    Commented Apr 22, 2022 at 5: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.