When playing around with DSolve, I enter the following:
DSolve[{Derivative[1][y][x] == x + Abs[x]*y[x]}, y[x], x]
The output is:
$$y(x)\to e^{\frac{1}{2} (x \left| x\right| -1)} \int_1^x K[1] e^{\frac{1}{2} (1-K[1] \left| K[1]\right| )} \, dK[1]+c_1 e^{\frac{1}{2} (x \left| x\right| -1)}$$
I would have expected a conditional which accounts for $x \le 0$ and $x \gt 0$ or something along those lines.
How is one supposed to interpret the output that is being produced? Is it a bug or am I not reading it correctly?
Answer
Testing the solution numerically shows the solution appears to be valid:
{sol} = DSolve[{Derivative[1][y][x] == x + Abs[x]*y[x]}, y, x]
SeedRandom[0];
RandomReal[{-2, 2}, 10]
Table[
Block[{C},
C[1] = 1;
Derivative[1][y][x] == x + Abs[x]*y[x] /.
(sol /. Integrate -> NIntegrate) /. Abs' -> Sign],
{x, %}]
(*
{0.609871, 0.532281, 0.731252, 0.265407, 1.74081, 1.90475,
-1.04619, 0.550249, -1.59561, 0.582099}
{True, True, True, True, True, True, True, True, True, True}
*)
In response to Amzoti's comment, I'm not so sure about there being a nice solution, if x
is assumed to be complex instead of real, which is how it is treated in Mathematica. If we specify that x
is real, we do get a nice solution (and much more quickly):
Assuming[{x ∈ Reals},
{sol} = DSolve[{Derivative[1][y][x] == x + Abs[x]*y[x]}, y, x]
];
y[x] /. sol // PiecewiseExpand
Comments
Post a Comment