# Solve the following differential equation: $xy' - y = x^2$

I'm preparing to exam in Linear Algebra $2$ and I have problems with differential equations..

For example, the following exercise:

Solve the following differential equation: $xy' - y = x^2$.

I started to solve:

$$xy' - y = x^2$$

$$\implies y' - \frac{y}{x} = x$$

I need to find some $u$ and multiply both sides by it:

$$uy' - \frac{u}{x}y = ux$$

I need somehow to satisfy the product rule of derivative, by finding $u$ such that $u' = -\frac{u}{x}$ and by this get: $(uy)' = uy' + u'y$.

# I need the help to find $u$.

I need to find $u$ such that $u' = -\frac{u}{x}$.

How would you find $u$? thanks in advance.

• Isn't this just a new differential equation to solve? How would you solve $u'+\frac ux=0$, which might be re-expressed as $u'x+u=0$? – abiessu Feb 28 '14 at 19:44
• Haven't you been told about integrating factors? It's easy to solve these types of ODE if you can find an integrating factor. – Fly by Night Feb 28 '14 at 20:07

Your differential equation $xy'-y=x^2$ can, assuming $x \neq 0$, be rewritten as $$y' - \frac{1}{x}y = x$$ This is a first order differential question of the form $y'+P(x)y=Q(x)$. Such equations can be solved by finding an integrating factor, say $\mu$, which when we multiply through by $\mu$, the left-hand side is an exact derivative. In the case of $y' + Py = Q$ we have $$\mu = \mathrm{e}^{\ \int P\, \mathrm{d}x}$$ In our case, $P=-\frac{1}{x}$ and so $\mu = \frac{1}{|x|}$.
If $x>0$, then $\mu =\frac{1}{|x|} \equiv \frac{1}{x}$. If $x<0$, then $\mu = \frac{1}{|x|} \equiv -\frac{1}{x}$. Multiplying through by $\mu = \pm\frac{1}{x}$ gives an equation equivalent to $$\frac{1}{x}y'-\frac{1}{x^2}y = 1$$ The left-hand side is an derivative: $$\left(\frac{1}{x}y\right)' = 1$$ Integrating both sides gives $$\frac{1}{x}y = x + c$$ It follows that $y=x^2 + cx$, where $c \in \mathbb{R}$.
The method of using an integrating factor can be used to solve $u'+\frac{1}{x}u=0$. In this case $P=\frac{1}{x}$ and so $\mu = x$. Multiplying through gives $xu'+u=0$ and hence $(xu)'=0$. It follows that $xu = c$ and hence $u=\frac{c}{x}$.
• Why is $\exp\left(\int P(x) \, \mathrm dx\right) = 1/x$? Shouldn't it be $1/|x|$ as $\int P(x) \,\mathrm dx = -log|x|$ ? – lemontree Feb 10 '18 at 13:05
• @lemontree Thanks for the question. You're right that it should, at first, be $\mu = \frac{1}{|x|}$. But it doesn't matter in the end. If $x>0$ then $\mu = \frac{1}{x}$. If $x<0$ then $\mu = -\frac{1}{x}$. If $x>0$, then we multiply through by $\frac{1}{x}$ to give $\frac{1}{x}y'-\frac{1}{x^2}y=1$. If $x<0$, then we multiply through by $-\frac{1}{x}$ to give $-\frac{1}{x}y'+\frac{1}{x^2}y=-1$, which is equivalent to $\frac{1}{x}y'-\frac{1}{x^2}y=1$. – Fly by Night Feb 10 '18 at 20:08
Hint: $\dfrac{u'}{u}=(\ln u)'$, so $\dfrac{u'}{u}+\dfrac{1}{x}=0$ implies $(\ln u)'+(\ln x)'=0$.