# DSolve leaks internal error messages when attempting to solve two first order autonomous ODEs

Issue reported to Wolfram, Inc as a possible bug in Version 12.1.1; CASE:4630268.

With Mathematica "12.1.1 for Microsoft Windows (64-bit) (June 19, 2020)", DSolve produces unexpected error messages:

 DSolve[{p1'[x] == p1[x]^2 + 2 p1[x] p2[x],
p2'[x] == 2 p1[x] p2[x] + p2[x]^2}, {p1, p2}, x]


Union::normal: Nonatomic expression expected at position 2 in { ... }⋃$Failed. Flatten::normal: Nonatomic expression expected at position 1 in Flatten[$Failed].

and returns unevaluated after a few minutes. Evidently, DSolve has passed the bad argument {...}⋃$Failed to Union. I am asking • With v12.1.1 on a Mac I see two internal errors Union::normal and Flatten::normal – Bob Hanlon Sep 9 at 13:14 • @BobHanlon Upon further consideration, I added the second error. Thanks for the recommendation. – bbgodfrey Sep 11 at 3:52 ## 1 Answer Does this count as a workaround?: (* dividing 2nd ODE by 1st yields a homogeneous ODE *) p2sol = DSolve[ {p2'[p1] == (2 p1 p2[p1] + p2[p1]^2) / (p1^2 + 2 p1 p2[p1])}, p2, p1] /. C -> Log[C] /. p_Power :> RuleCondition[p, True]; (* p2sol turns the p1'[x] ODE in the system into a separable equation *) PrintTemporary@Dynamic[foo = Clock[Infinity]]; TimeConstrained[ (Print[foo]; #) &@ Flatten@ DSolve[#, p2, x], 30, Print[Style[foo, Red]];$Failed] & /@
(Last[system] /. p1[x] -> p1[p2[x]] /. p2sol)

(*
3.30611
33.329
63.273
{{p1 -> Function[{x},
InverseFunction[
Inactive[
Integrate][(-9 C K^2 +
Sqrt Sqrt[C^2 K^3 (4 C + 27 K)])^(1/3)/(
K (-2 2^(1/3) 3^(2/3) C K +
9 K (-9 C K^2 +
Sqrt Sqrt[C^2 K^3 (4 C + 27 K)])^(1/3) +
2^(2/3) 3^(
1/3) (-9 C K^2 +
Sqrt Sqrt[C^2 K^3 (4 C + 27 K)])^(
2/3))), {K, 1, #1}] &][
x/3 + C]]}, $$Failed,$$Failed}
*)


One can combine with with p2sol to obtain p2'[x]. The solutions can be stated as implicit equations, but Mathematica tries really hard to solve them.

Note this system and the one it came from admit two one-parameter families of symmetries, scalings {p1, p2, 1/x} -> C {p1, p2, 1/x} and translations x -> x + C. Thus they can theoretically be expressed as successive quadratures as above, provided one can solve the intermediate equations such as the one produced by this generalization:

DSolve[
{p2'[p1] == (2 a p1 p2[p1] + b p2[p1]^2)/(c p1^2 + 2 d p1 p2[p1])},
p2, p1]

(*
Solve[(-c (b - 2 d) Log[p2[p1]/p1] +
(b c - 4 a d) Log[-2 a + c - (b p2[p1])/p1 + (2 d p2[p1])/ p1]) /
((2 a - c) (b - 2 d)) == C - Log[p1], p2[p1]]
*)

• Very nice answer (+1), A few questions: x -> x + C is essential to reducing the second order system to first order. What advantage does {p1, p2} -> C {p1, p2} (actually, {p1, p2, 1/x} -> C {p1, p2, 1/x}, I believe) provide? Where is RuleCondition documented, and what does /. p_Power :> RuleCondition[p, True] do in the code above? Should the undefined symbol p1sol actually be p2sol? – bbgodfrey Sep 11 at 15:14
• The scaling symmetry means it's reducible to a homogeneous ODE; the translation symmetry means it's autonomous, and autonomous first-order ODEs, which you get after the first integration, are separable. RuleCondition can be found only on site; look at the oldest posts; I think @WReach explains it. I used it for in-place simplification inside Function, which is HoldAll. All it does is evaluate and replace the Power[E, Log[C] that comes from the previous substitution inside Function. The power evaluates to C, which looks much nicer. It's not important, though. – Michael E2 Sep 11 at 15:26
• @bbgodfrey Yeah, p1sol should be p2sol. I solved it both ways, but it made little difference. And then I changed the fancy monitoring code and forgot to change the p1 back to p2. – Michael E2 Sep 11 at 15:29
• @bbgodfrey My computer was crashing...I think my first comment was too hasty: It becomes homogeneous because of both symmetries. The system being autonomous, which is necessary to reduce the system to a single ODE, led me to ignore x or 1/x as you cleverly formulated the transformation. Scalings and homogeneity go hand-in-hand, and the single ODE obtained being homogeneous is connected to the scaling symmetry. – Michael E2 Sep 11 at 16:05