Is my attempt at solving $y'=\frac{y}x+\left(1-\frac1x\right)$ correct?

101 Views Asked by At

Given the following first-order, linear differential equation, $$y'=\dfrac{y}x+\left(1-\dfrac1x\right)$$ find the constant $c$ such that $y(-1)=0$ and say for which $\alpha$ there are solutions for which $y(0)=\alpha$

My attempt

The equation is of the form $y'(x)=a(x)y(x)+b(x)$ where $a(x)=1/x$ and $b(x)= \left(1-\frac1x\right)$. Both $a(x)$ and $b(x)$ are continuous in $\mathbb R\setminus\{0\}$. Then the solution is:

$$\begin{align}y(x)&=e^{\int1/x \ \mathrm dx}\left[\int e^{-\int1/x \ \mathrm dx}\left(1-\frac1x\right)\mathrm d x +c\right]\\ &=e^{\log|x|}\left[\int e^{-\log|x|}\left(1-\frac1x\right)\mathrm d x +c\right]\\ &=|x|\left[\int\left(\frac{1}{|x|}-\frac{1}{|x|}\frac1x\right)\mathrm d x +c\right]\\ &=|x|\log|x|+c|x|-|x|\int\left(\frac{1}{|x|}\frac1x\right)\mathrm d x\tag1\end{align}$$

I then split the equation in $(-\infty,0)$ and $(0,\infty)$ and I got:

$$\begin{cases}x>0\\ x\log x+cx+1 \end{cases}\cup \begin{cases}x<0\\ -x\log (-x)+cx+1 \end{cases}$$ Then, if $y(-1)=0 \implies 1\log(1)-c+1=0\implies c=1$

I think there are no values of $\alpha$ for which $y(0)=\alpha$ because $y(x)$ is not defined in $x=0$

EDIT: (Thanks to Winther and Isham)

$(1)$ should have been: $$|x|\operatorname{sign}x\log|x|+c|x|-|x|\int\left(\frac{1}{|x|}\frac1x\right)\mathrm d x$$

Then $$y(x)=x\log|x|+cx+1$$

$$\lim_{x\to0^+}y(x)=\lim_{x\to0^-}y(x)=1\implies \alpha=1?$$

1

There are 1 best solutions below

1
On BEST ANSWER

Thats correct to me...Got the same result too $$y'=\dfrac{y}x+\left(1-\dfrac1x\right)$$ $$xy'=y+x\left(1-\dfrac1x\right)$$ $$\frac {xy'-y}{x^2}=\frac 1x\left(1-\dfrac1x\right)$$ $$(\frac yx)'=\frac 1x\left(1-\dfrac1x\right)$$ Integrate $$y(x)=x\int \frac 1x\left(1-\dfrac1x\right)dx +Kx$$ $$y(x)=x \ln|x|+1+Kx$$ $$y(-1)=0 \implies K=1 \implies y(x)=x \ln|x|+1+x$$