Error on Matlab and Wolfram Alpha?

I solved the differential equation $\frac{\mathrm{d} y}{\mathrm{d} x}= \frac{y^2-1}{2y}$, in the following way:

$\frac{\mathrm{d} y}{\mathrm{d} x}= \frac{y^2-1}{2y} <=>$ $\int \frac{2y}{y^{2}-1}dy=\int1dx <=> ln\left| y^2-1\right |=x+C<=>$

$|y^2-1|=e^xe^C <=> \pm (y^2-1)=e^xe^C <=> y^2-1=Ke^x$, for a constant K, such that $K=\pm e^c$

$<=> y^2=Ke^x+1<=> y= \pm \sqrt{Ke^x+1}$

Now Wolfram Alpha(http://www.wolframalpha.com/input/?i=dy%2Fdx%3D%28y%5E2-1%29%2F%282y%29) and Matlab both tell me that the solution to the original equation is:

$\pm \sqrt{e^Ce^x+1}$, meaning that my constant K can only assume positive values. Is my solution wrong or are both of these software wrong?

• For complex C, your K could be negative (or even complex) – Pieter21 Nov 25 '15 at 15:42

You could have negative values for K in your solutions. There are two branches to this DE. If you had a suitable initial condition to the DE then wolfram (I don't have maple) find it, e.g.: http://www.wolframalpha.com/input/?i=dy%2Fdx%3D%28y%5E2-1%29%2F%282y%29%2C+y%280%29%3D-1%2F2

As mentioned in the comments a complex value of $C$ could give rise to a negative value for $K$.

• So, wolfram alpha constant C used in integrals and differential equations is complex, instead of real, right? – Francisco Nov 25 '15 at 16:01
• Potentially yes. It would depend upon what limitations or initial conditions you have on the problem. – Ian Miller Nov 26 '15 at 4:53

You are right, except that you should be more careful with the constant solutions $y=\pm 1$. (In the final answer, they correspond to $K=0$, but you have defined $K=\pm e^C$, which can never be zero, so you have to "repair" the solution by including those cases "by hand".)

• Wolfram does not consider those special solutions, right? – Francisco Nov 25 '15 at 16:15
• Apparently not! Even if I give the initial condition $y(0)=1$, WA doesn't provide the solution (unlike in Ian Miller's answer, where you do get the answer for $y(0)=-1/2$). – Hans Lundmark Nov 25 '15 at 17:35
• Software will always have its limitations. Finding special cases like $y(0)=1$ is not always easy and I could see many students missing this answer (I didn't think of it myself either until I saw Hans Lundmark's answer). So there are in fact more than two branches to this DE. :) – Ian Miller Nov 26 '15 at 4:58
• It may not be easy to find these special cases, but it seems like it's something that WA and Matlab could be instructed to do, especially as the form of the diff eq might suggest it. It might be worthwhile to bring it to the attention to the software developers, on the off chance they're not aware of it. – Brian Tung Nov 27 '15 at 21:31