# “MemoryAllocationFailure” in DSolve

Mathematica 10.4, Windows 10, 6 GB RAM, 64 bits

When I trying to solve

DSolve[{v'[t] == 100 - 0.15 v[t]^2, v[0] == 30}, v[t], t]


I get SystemException["MemoryAllocationFailure"]

NDSolve[{v'[t] == 100 - 0.15 v[t]^2, v[0] == 30}, v[t], {t, 0, 10}]


working without any problems.

Questions: Can this equation be solved analytically? Maybe it is a bug?

• Use 15/100 instead of 0.15. Approximate real numbers can sometimes bog down exact solvers. (DSolve and NDSolve do not have a lot in common in terms of algorithms used, so I'm not surprised at the difference.) – Michael E2 Apr 17 '16 at 13:12
• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Apr 17 '16 at 14:34

I don't know if it's a bug, but Mathematica makes a move that, when it's your student you say, why did you do that! It was simpler before.

I ran this code without the replacement with Exp[stuff__ * C[1]] in order to figure out what to do to fix it. (The colored output below are from the Print statements showing the various calls to Solve that happen inside DSolve.)

Module[{$inside, res,$stuff},
InternalInheritedBlock[{Solve},
Unprotect[Solve];
Solve[sys_, vars_, opts___] /; ! TrueQ[$inside] := Block[{$inside = True},
res = Solve[
sys /. Exp[stuff__*C[1]] :> ($stuff = Times[stuff]; C[2]), vars /. C[1] -> C[2], Reals, opts]; Print[sys -> res]; If[FreeQ[res, C[2]], res, Print["Rewritten: ", (sys /. Exp[stuff__*C[1]] :> C[2]) -> res]; {C[1] -> Log[C[2]]/$stuff} /. res]
];
Protect[Solve];
DSolve[Rationalize@{v'[t] == 100 - 0.15 v[t]^2, v[0] == 30}, v, t]
]]


(* solution:
{{v -> Function[{t}, (20 (-10 + 3 Sqrt[15] + 10 E^(2 Sqrt[15] t) +
3 Sqrt[15] E^(2 Sqrt[15] t)))/(-9 + 2 Sqrt[15] +
9 E^(2 Sqrt[15] t) + 2 Sqrt[15] E^(2 Sqrt[15] t))]}}
*)


You can see in the yellow call to Solve, the equation is in the perfect state to solve for the constant of integration C[1]. But through exponentiation we get an expression for v that has 40 complex solutions to the initial condition:

DSolve[Rationalize@{v'[t] == 100 - 0.15 v[t]^2, v[0] == 30}, v, t]


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

(*
{{v -> Function[{t}, (
20 Sqrt[5/3] (-1 + E^(2 Sqrt[15] (t - (I π + Log[1/7 (47 - 12 Sqrt[15])])/(
2 Sqrt[15])))))/(
1 + E^(2 Sqrt[15] (t - (I π + Log[1/7 (47 - 12 Sqrt[15])])/(2 Sqrt[15]))))]},
...38 solutions omitted..,
{v ->
Function[{t}, (20 Sqrt[5/3] (-1 + E^(2 Sqrt[15] (t -
4 Sqrt[5/3]Log[(-1)^(19/20) (1/7 (-47 + 12 Sqrt[15]))^(1/40)]))))/(
1 + E^(2 Sqrt[15] (t - 4 Sqrt[5/3] *
Log[(-1)^(19/20) (1/7 (-47 + 12 Sqrt[15]))^(1/40)])))]}}
*)


You might be better off solving the initial condition by itself:

dsol = DSolve[Rationalize@{v'[t] == 100 - 0.15 v[t]^2}, v[t], t]
(*
{{v[t] -> (20 Sqrt[5/3] (-1 + E^(2 Sqrt[15] (t - 20 C[1]))))/(
1 + E^(2 Sqrt[15] (t - 20 C[1])))}}
*)


Solving the initial condition for C[1] has to be done over the complex numbers. This introduces a free parameter which can be given any integer value, since they are all equivalent real solutions.

Solve[v[t] == 30 /. First@dsol /. t -> 0, C[1]]
icsol = % /. C[2] -> 0 // Simplify
(*
{{C[1] ->
ConditionalExpression[(
I π + 2 I π C[2] + Log[-((-9 + 2 Sqrt[15])/(9 + 2 Sqrt[15]))])/(40 Sqrt[15]),
C[2] ∈ Integers]}}

{{C[1] -> (I π + Log[1/7 (47 - 12 Sqrt[15])])/(40 Sqrt[15])}}
*)


Finally, plug C[1] into the general solution:

dsol0 = dsol /. First@icsol // Simplify
(*
{{v[t] -> (20 Sqrt[5/3] (7 + (47 + 12 Sqrt[15]) E^(2 Sqrt[15] t))) /
(-7 + (47 + 12 Sqrt[15]) E^(2 Sqrt[15] t))}}
*)
`