# How to solve this seemingly simple initial value problem? $xy' - y = x^2$

$$xy' - y = x^2,\quad y(-1) = 0$$

I found this question in the old exams paper of a Calculus II course. I tried finding $y'(-1) = 1$ but it doesn't seem to be helpful at all. Can anyone help?

• Hint: $\left(\frac{y}{x}\right)' = \frac{xy' - y}{x^2}$ – achille hui Aug 7 '15 at 11:16

$x y'-y=x^2\Rightarrow\frac{x y'-y}{x^2}=1\Rightarrow\frac{d}{dx}(\frac{y}{x})=1$

Integrate both sides,

$\frac{y}{x}=x+c\Rightarrow y=x^2+cx$

Now put $x=-1,y=0$

$c=1$

$y=x^2+x$

• Thank you!! I found the chapter in my textbook for this :/ – lsy Aug 7 '15 at 16:01
• You've solved for the value of $c$ on $x<0$, but you haven't given a reason why you need the same constant on the $x>0$ part. – user14972 Aug 7 '15 at 18:41
• @Hurkyl, I gave an answer to explain the transition at $x=0$ more carefully. – Joonas Ilmavirta Aug 8 '15 at 16:34

The answers so far use the auxiliary variable $y/x$ and don't properly treat the case $x=0$. Of course a formal calculation does produce an answer and it can easily be checked to solve the problem. Then to see that there is no issue at zero and the obtained solution is the only one, one needs to use a uniqueness theorem for the solution (or some ad hoc version). There is also a more direct way around this, without appealing to high power theorems. The argument is simple, it just should be made explicit.

I assume you are looking for a solution $y$ which is actually a differentiable function everywhere on an interval (around the point $x=-1$). The answers already given show that a solution for $x<0$ must look like $x^2+ax$ and for $x>0$ like $x^2+bx$. To satisfy the given initial condition, we must set $a=1$, and we get a solution $y=x^2+x$ for $x<0$. This solution does not blow up at $x=0$, so it can probably be extended. We know the only possible formula to extend it; we just have to choose $b$ if it is possible.

A differentiable function is necessarily continuous, so $y(0)=\lim_{x\to0-}x^2+x=0$. Consider the function $$y(x) = \begin{cases} x^2+x&x\leq0\\ x^2+bx&x>0. \end{cases}$$ We know now that this is the only possible form of a solution. This function is continuous for any choice of $b$, but it is differentiable at $x=0$ if and only if $b=1$. (The limit of the difference quotient is 1 from the left and $b$ from the right.) Therefore the only possible differentiable solution is $y=x^2+x$. This is indeed a solution, as a simple calculation shows.

I would also like to suggest another way to deal with the issue at $x=0$, although it is less rigorous. Suppose $y(x)$ is a solution to the ODE. Then we must have $y(0)=0$ (plug $x=0$ to the ODE to see this). For a smooth function $y$ this implies that $y(x)=xf(x)$ for a smooth function $f$. (To see why this should be true, write $y$ as a Taylor expansion and factor and $x$ out.) If you write the ODE for this $y$, you get the ODE $x^2(f'-1)=0$. Therefore $f'(x)=1$ whenever $x\neq0$, and since $f$ is continuously differentiable, we have $f'(x)=1$ for all $x$. Thus $f(x)=x+c$ for a constant $c$ and so $y(x)=x^2+cx$. The initial condition forces $c=1$. The problem in this approach is that you have to justify existence and uniqueness of the function $f$. If you can do so, this gives a more rigorous way to divide by $x$ — after all, $f=y/x$ for $x\neq0$.

We have, $$xy'-y=x^2$$ $$\frac{dy}{dx}-\frac{1}{x}y=x$$ Now, the integration factor is given as $$I.F.=e^{\int\frac{-1}{x}dx}=e^{-\ln x}=\frac{1}{x}$$ Hence, we have $$y\cdot(I.F.)=\int(I.F.)xdx+c$$ $$y\frac{1}{x}=\int\frac{1}{x}xdx+c$$ $$\frac{y}{x}=\int 1\cdot dx+c=x+c$$ $$y=x^2+cx$$ substitute $x=-1$, we get $$y(-1)=(-1)^2+c(-1)=0$$ $$1-c=0\iff c=1$$ Hence, we get $$\bbox[5px, border:2px solid #C0A000]{\color{red}{y=x^2+x}}$$

• You are very welcome. I am indeed delighted to help you! – Harish Chandra Rajpoot Aug 7 '15 at 12:49
• You've solved for the value of $c$ on $x<0$, but you haven't argued that $c$ needs to be the same value on $x>0$. – user14972 Aug 7 '15 at 18:41
• Yes, you are absolutely right. That is need in the answer – Harish Chandra Rajpoot Aug 7 '15 at 18:45