We all know that for real $x,y$ that $\sqrt{x y} = \sqrt{x} \sqrt{y}$ only when $x,y$ are nonnegative. But Mathematica DSolve
automatically does this when solving an ode. The question is why?
Here is an example
DSolve[y'[x] == Sqrt[x y[x]], y[x], x]
(if you solve it by hand, how would you do this?)
Mathematica gives
How did it do it? It clearly rewrote Sqrt[x y[x]]
as Sqrt[x]* Sqrt[y[x]]
and made it separable and just integrated. This can be seen by calling WolframAlpha and looking at the step-by-step
WolframAlpha["DSolve[y'[x]==Sqrt[x*y[x]],y[x],x]"]
Lets ask Reduce what it thinks about all of this
Reduce[Sqrt[x*y] == Sqrt[x]*Sqrt[y], Reals]
Even if do not use Reals
above
Reduce[Sqrt[x*y] == Sqrt[x]*Sqrt[y]]
The point is, we can't just replace Sqrt[x*y]
by Sqrt[x]*Sqrt[y]]
without assumptions. Right?
This becomes more clear when adding assumptions to DSolve
itself. Now it gives different answers depending if we tell it $x$ is positive or negative
DSolve[y'[x] == Sqrt[x y[x]], y[x], x, Assumptions -> Element[{x, y}, Reals]]
DSolve[y'[x] == Sqrt[x y[x]], y[x], x, Assumptions -> {x > 0, y > 0}]
DSolve[y'[x] == Sqrt[x y[x]], y[x], x, Assumptions -> {x < 0, y > 0}]
This shows that the answer depends on the sign.
I am just trying to understand if Mathematica's answer is valid mathematically wise and why it breaks the sqrt like this without using assumptions.
One possibility I was thinking about why the above can be done when solving the ode, is that the solution has an arbitrary constant of integration and that the constant of integration can be complex itself. But I am not sure that this will give one permission to break the sqrt as done here at the start. But that is what DSolve
does.
When I solve this ode myself by hand, I will at least add assumptions that $x>0,y>$ before breaking up the sqrt. So may be if DSolve
generated the answer with this assumption included, then that would be better.
V 13.2 on windows 10
(if you solve it by hand, how would you do this?)
. Well, the first observation is that $y(x)=0$ is a solution $\forall x$. So, let's find $y(x) \neq 0$. Divide LHS and RHS by $\sqrt{y}$ to bring it in the form: $(2 \sqrt{y})^{\prime}=\sqrt{x}$ which can be readily integrated to give $y = \left(\frac{1}{3} x^{3/2} + \text{constant} \right)^2$. $\endgroup$y'[x]^2 == x y[x]
$\endgroup$this
. Without assumptions on $x$ and $y$, right? $\endgroup$PowerExpand
assumes all quantities are positive. From help,The transformations made by PowerExpand are correct in general only if c is an integer or a and b are positive real numbers.
so it is assuming $x,y$ are positive. We are back to square one. One can't simplify asDSolve
did and break the sqrt without this assumption. $\endgroup$