2
$\begingroup$

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?

$\endgroup$
0

1 Answer 1

3
$\begingroup$

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

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ It may be valid, but it is also quite ugly. A nice closed form solution without integrals is possible and that is how one would do it by hand. (+1) $\endgroup$
    – Amzoti
    Commented Feb 17, 2015 at 13:51
  • $\begingroup$ @Amzoti Thanks. See update. $\endgroup$
    – Michael E2
    Commented Feb 17, 2015 at 14:00
  • $\begingroup$ That is what I would have expected and I forgot to take into account reals only, so thanks! I am surprised Mathematica does not respond that way by default with a statement, if $x \in \mathbb{R}$ or something along those lines. $\endgroup$
    – Amzoti
    Commented Feb 17, 2015 at 14:04
  • $\begingroup$ Hello, I ran the first piece of code, but I didn't get True. The result was a very complex expression. (v 14.0) $\endgroup$
    – lotus2019
    Commented Aug 14 at 2:29

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.