“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 == 30}, v[t], t]

I get SystemException["MemoryAllocationFailure"]

NDSolve[{v'[t] == 100 - 0.15 v[t]^2, v == 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] 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},
Internal`InheritedBlock[{Solve},
Unprotect[Solve];
Solve[sys_, vars_, opts___] /; ! TrueQ[$inside] := Block[{$inside = True},
res = Solve[
sys /. Exp[stuff__*C] :> ($stuff = Times[stuff]; C), vars /. C -> C, Reals, opts]; Print[sys -> res]; If[FreeQ[res, C], res, Print["Rewritten: ", (sys /. Exp[stuff__*C] :> C) -> res]; {C -> Log[C]/$stuff} /. res]
];
Protect[Solve];
DSolve[Rationalize@{v'[t] == 100 - 0.15 v[t]^2, v == 30}, v, t]
]] (* solution:
{{v -> Function[{t}, (20 (-10 + 3 Sqrt + 10 E^(2 Sqrt t) +
3 Sqrt E^(2 Sqrt t)))/(-9 + 2 Sqrt +
9 E^(2 Sqrt t) + 2 Sqrt E^(2 Sqrt 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. 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 == 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 (t - (I π + Log[1/7 (47 - 12 Sqrt)])/(
2 Sqrt)))))/(
1 + E^(2 Sqrt (t - (I π + Log[1/7 (47 - 12 Sqrt)])/(2 Sqrt))))]},
...38 solutions omitted..,
{v ->
Function[{t}, (20 Sqrt[5/3] (-1 + E^(2 Sqrt (t -
4 Sqrt[5/3]Log[(-1)^(19/20) (1/7 (-47 + 12 Sqrt))^(1/40)]))))/(
1 + E^(2 Sqrt (t - 4 Sqrt[5/3] *
Log[(-1)^(19/20) (1/7 (-47 + 12 Sqrt))^(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 (t - 20 C))))/(
1 + E^(2 Sqrt (t - 20 C)))}}
*)

Solving the initial condition for C 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]
icsol = % /. C -> 0 // Simplify
(*
{{C ->
ConditionalExpression[(
I π + 2 I π C + Log[-((-9 + 2 Sqrt)/(9 + 2 Sqrt))])/(40 Sqrt),
C ∈ Integers]}}

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

Finally, plug C into the general solution:

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