# Solving $\frac{dy}{dx} = xy^2$

This problem appears to be pretty simple to me but my book gets a different answer.

$$\frac{dy}{dx} = xy^2$$ For when y is not 0 $$\frac{dy}{y^2} = x \, dx$$ $$\int \frac{dy}{y^2} = \int x \, dx$$

$$\frac{-1}{y^1} = \frac{x^2}{2}$$

$$\frac{-2}{x^2} = y$$

Is there anything wrong with this solution? It is not what my book gets but it is similar to how they do it in the example.

-
You're only missing a constant of integration $C$. An initial condition $f(a)=b$ will give it a value. Meanwhile, it has to be there. –  Pedro Tamaroff Jun 14 '12 at 19:56
My book gets $\frac{2}{K - x^2}$ and $y=0$ –  user138246 Jun 14 '12 at 19:57
The first nice thing about an explicit solution of an ODE is that you can easily differentiate the result and see whether it fulfills the equation. The second nice thing are well known uniqueness results for boundary value problems of ODE, which often tell you that if you have a solution it it is the only one. –  user20266 Jun 14 '12 at 19:58
Well, see that $$-\frac{1} y=\frac{x^2}{2}+K$$ Now solve for $y$. –  Pedro Tamaroff Jun 14 '12 at 19:59
Note that dividing by $y^2$ is not valid if our function $y$ is identically $0$. And indeed $y$ identically $0$ is a solution of the DE. –  André Nicolas Jun 14 '12 at 20:21
show 1 more comment

When you apply indefinite integration, you need to add a "${}+C\,$" (or whatever letter you want) at the end; this is rather infamous for tripping up students. In your problem this gives

$$-\frac{1}{y}=\frac{x^2}{2}+C~~\implies~~ y=\frac{1}{-(x^2/2+C)}=\frac{2}{-x^2-2C}.$$

If we write $K=-2C$ (or again, any old letter), we can write this simply as $\displaystyle\frac{2}{K-x^2}$.

The reason we have "plus a constant" at the end is to prevent erroneous derivations like this:

$$\frac{d}{dx}f(x)=\frac{d}{dx}\big(f(x)+1\big)\implies f(x)=f(x)+1\implies 0=1.$$

In other words, antidifferentiation will only find the antiderivative you want up to addition by an unknown constant. (However with some initial conditions this constant, or constants as it may be in more complicated problems, may be computed exactly.)

Note that it is only necessary to write an add-a-constant to one side of an equation, because for example something like $f(x)+A=g(x)+B$ can be written instead as $f(x)=g(x)+C$ with our constant $C=B-A$.

-

Your mistake is here. You should have $$\int \frac{dy}{y^2} = \int y^{-2}dy = -y^{-1}$$ and not $$\int \frac{dy}{y^2} = \frac{-1}{y^{-1}}$$.

-
It looks like that was just a typo on the op's part.. –  Court Jun 14 '12 at 19:59
No, I don't think so. –  Old John Jun 14 '12 at 20:00
That was a typo, I fixed it. –  user138246 Jun 14 '12 at 20:01
I do think so. Mull over the last line in the OP's derivation. (Also Jordan edited while I was typing.) –  anon Jun 14 '12 at 20:01
OK - it was a typo –  Old John Jun 14 '12 at 20:03

Continuing from what you did, we have

$$\int \frac{dy}{y^2} = \int x\,dx$$

$$-\frac{1}{y} + C_2= \frac{x^2}{2}+C_1$$

Where $C_1$ and $C_2$ are constants of integration. Letting $C_3=C_1-C_2$

$$-\frac{1}{y} + C_2= \frac{x^2}{2}+C_1=-\frac{1}{y}= \frac{x^2}{2}+C_3$$

Solving for $y$, we have:

$$-\frac{1}{y}= \frac{x^2}{2}+C_3= \frac{x^2+2C_3}{2} \implies -y=\frac{2}{x^2+2C_3} \\ \implies y=\frac{2}{2C_3-x^2}$$

Letting $2C_3=K$

$$y=\frac{2}{2C_3-x^2}=\frac{2}{K-x^2}$$

-