# Thread: First-order linear ode

1. ## First-order linear ode

Solve the ordinary differential equation:

$\displaystyle xy^2 + 4\frac{dy}{dx} = 4x$

Attempt:

$\displaystyle \frac{dy}{dx} + \frac{xy^2}{4} = x$

(I tried to get it into the form of $\displaystyle \frac{dy}{dx} + p(x)y = q(x)$ of a first-order linear ode, but in this case the $\displaystyle y$ is $\displaystyle y^2$)

I then found $\displaystyle e^{P(x)}$, where $\displaystyle P(x)$ is an anti-derivative of $\displaystyle p(x)$

In this case $\displaystyle p(x) = \frac{x}{4}$ therefore I got $\displaystyle e^{P(x)} =e^{\frac{x^2}{8}}$

$\displaystyle e^\frac{x^2}{8}\frac{dy}{dx} + \frac{xy^2e^{\frac{x^2}{8}}}{4} = xe^{\frac{x^2}{8}}$
$\displaystyle \frac{d}{dx}(ye^\frac{x^2}{8}) = xe^{\frac{x^2}{8}}$

but this doesnt seem correct

2. It's separable.

3. Originally Posted by SyNtHeSiS
but this doesnt seem correct
'cause it's not linear.

4. Oh ok. How do you know when a differential equation is separable or linear?

Here is my working out:
$\displaystyle xy^2 + 4\frac{dy}{dx} = 4x$
$\displaystyle \frac{dy}{dx} + \frac{xy^2}{4} = x$
$\displaystyle \frac{dy}{dx} = x - \frac{xy^2}{4}$
$\displaystyle \frac{dy}{dx} = x(1- \frac{y^2}{4})$
$\displaystyle dy = x(1 - \frac{y^2}{4})dx$
$\displaystyle \int \frac{1}{(1 - \frac{y^2}{4})}dy = \int x dx$
$\displaystyle \int\frac{1}{(1 - \frac{y}{2})(1 + \frac{y}{2})}dy = \frac{1}{2}x^2 + C$

I then used partial fractions to get:

$\displaystyle \int \frac{\frac{1}{2}}{(1 - \frac{y}{2})} + \frac{\frac{1}{2}}{(1 + \frac{y}{2})}dy = \frac{1}{2}x^2 + C$

but this obviously isnt right

5. Originally Posted by SyNtHeSiS
Oh ok. How do you know when a differential equation is separable or linear?

Here is my working out:
$\displaystyle xy^2 + 4\frac{dy}{dx} = 4x$
$\displaystyle \frac{dy}{dx} + \frac{xy^2}{4} = x$
$\displaystyle \frac{dy}{dx} = x - \frac{xy^2}{4}$
$\displaystyle \frac{dy}{dx} = x(1- \frac{y^2}{4})$
$\displaystyle dy = x(1 - \frac{y^2}{4})dx$
$\displaystyle \int \frac{1}{(1 - \frac{y^2}{4})}dy = \int x dx$
$\displaystyle \int\frac{1}{(1 - \frac{y}{2})(1 + \frac{y}{2})}dy = \frac{1}{2}x^2 + C$

I then used partial fractions to get:

$\displaystyle \int \frac{\frac{1}{2}}{(1 - \frac{y}{2})} + \frac{\frac{1}{2}}{(1 + \frac{y}{2})}dy = \frac{1}{2}x^2 + C$

but this obviously isnt right Mr F asks: Why so you say that?
Why not simplify to

$\displaystyle \displaystyle \int \frac{1}{(2 - y)} + \frac{1}{(2 + y)}dy = \frac{1}{2}x^2 + C$

(assuming there are no careless arithmetic errors - I haven't checked closely but it all looks OK).

6. I am not getting the right answer in my book:

$\displaystyle y = -2$ or $\displaystyle y = 2\frac{1 - ke^{\frac{-x^2}{2}}}{1 +ke^{\frac{-x^2}{2}}}$

From $\displaystyle \displaystyle \int \frac{1}{(2 - y)} + \frac{1}{(2 + y)}dy = \frac{1}{2}x^2 + C$ I got:

$\displaystyle ln|2 - y| + ln|2 + y| = \frac{1}{2}x^2 + C$
$\displaystyle ln|4 - y^2| = \frac{1}{2}x^2 + C$
$\displaystyle 4 - y^2 = e^{\frac{1}{2}x^2}e^c$
$\displaystyle y = \pm\sqrt{4 - Ke^{\frac{1}{2}x^2}}$

7. $\displaystyle \ln|2 - y| + \ln|2 + y| = \dfrac{1}{2}x^{2} + C$
You have an error in there that might change things. Correction:

$\displaystyle -\ln|2 - y| + \ln|2 + y| = \dfrac{1}{2}x^{2} + C$

What does that give you?

8. Originally Posted by SyNtHeSiS
$\displaystyle y = \pm\sqrt{4 - Ke^{\frac{1}{2}x^2}}$
Looks good to me. Have you checked the answer works? i.e. taking its first derivative and substituting it back into the original DE.

Are you looking at the right answer in your book?

9. Originally Posted by Ackbeet
You have an error in there that might change things. Correction:

$\displaystyle -\ln|2 - y| + \ln|2 + y| = \dfrac{1}{2}x^{2} + C$

What does that give you?
Why is it $\displaystyle -\ln|2 - y|$? I cant seem to find a minus sign that I overlooked in my working.

10. Why is it $\displaystyle -\ln|2 - y|$? I cant seem to find a minus sign that I overlooked in my working.
Because

$\displaystyle \displaystyle \int \frac{1}{2 - y}\,dy=-\int\frac{1}{y-2}\,dy=-\ln|y-2|+C.$

The logarithm rule only works if the variable of integration is positive in the denominator.

11. Originally Posted by Ackbeet
Because

$\displaystyle \displaystyle \int \frac{1}{2 - y}\,dy=-\int\frac{1}{y-2}\,dy=-\ln|y-2|+C.$

The logarithm rule only works if the variable of integration is positive in the denominator.
I tried it the long way:

$\displaystyle \int \frac{1}{2 - y}dy$

$\displaystyle u = 2 -y$
$\displaystyle du = -dy$
$\displaystyle dy = -du$

$\displaystyle \int -\frac{1}{u}dy$
$\displaystyle = -ln|2 - y| + C$

I dont understand why I got a different answer to yours, since my steps seem fine

12. Your steps are fine. Your answer is not different from mine, since |y-2| = |2-y|.

13. Oh ok. Using what you said, this is the working I got:

$\displaystyle -\int \frac{1}{(y - 2)} + \frac{1}{(y + 2)} dy = \frac{1}{2}x^2 + C$

$\displaystyle -ln|y - 2| + ln|y + 2| = \frac{1}{2}x^2 + C$

$\displaystyle ln|\frac{y + 2}{y - 2}| = \frac{1}{2}x^2 + C$

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

$\displaystyle y + 2 = (y - 2)Ke^{\frac{1}{2}x^2}$

$\displaystyle y(1 - Ke^{\frac{1}{2}x^2}) = -2Ke^{\frac{1}{2}x^2} - 2$

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

$\displaystyle y = -2\frac{(1 + Ke^{\frac{1}{2}x^2} )}{(1 - Ke^{\frac{1}{2}x^2})}$

but I am still not getting:

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

14. Multiply top and bottom by $\displaystyle e^{-x^{2}/2}.$ You're still not going to have the same signs as the answer you're aiming for. But, since $\displaystyle k$ is an arbitrary constant, replace $\displaystyle k$ with $\displaystyle -k,$ and I think you'll get the final answer.

15. $\displaystyle y = -2\frac{(Ke^{\frac{1}{2}x^2} -2)}{(1 - Ke^{\frac{1}{2}x^2})}$

$\displaystyle = -2\frac{(1 + Ke^{\frac{1}{2}x^2})}{(1 - Ke^{\frac{1}{2}x^2})}$

Multiplying the top and bottom by $\displaystyle e^{-\frac{1}{2}x^2}$ I got:

$\displaystyle =-2\frac{(e^{-\frac{1}{2}x^2} + K)}{(e^{-\frac{1}{2}x^2} - K)}$

If you change the K in the denominator to +K, then the answer is y = -2 (which was one of the solutions), but how else would you manipulate it to get:

$\displaystyle y = 2\frac{(1 - ke^{\frac{-x^2}{2}})}{(1 +ke^{\frac{-x^2}{2}})}$

Page 1 of 2 12 Last