Variation of parameters exercise 2


Initial value problem:

$$\begin{align*}y’&=-\frac{y}{x}+1\\ y(2)&=\frac{3}{2}\end{align*}$$


At first we solve the homogeneous equation by separation of variables:

$$\begin{align*}y’&=-\frac{y}{x}\\ \frac{dy}{dx}&=-\frac{y}{x}\\ \frac{1}{y}dy&=-\frac{1}{x}dx\\ \int\frac{1}{y}dy&=-\int\frac{1}{x}dx\\ \ln(|y|)&=-\ln(|x|)+k_0 \quad\quad k_0\in\mathbb{R}\\ y&=\exp(-ln(|x|)+k_0)\\ y&=\exp(-ln(|x|))\cdot \exp(k_0)\\ y_h&=\frac{1}{x} \cdot k \quad\quad k\in\mathbb{R}\end{align*}$$

Comment about the absolute value:
The solution of a homogeneous linear differential equation is either zero or always different from zero, meaning in each interval either positive or negative. If it is positive, we can forget the absolute value sign. If it is negative, we can multiply by -1 an get another solution of the homogeneous differential equation. That is why we can forget the absolute value sign in this case.

To solve the non-homogeneous equation, we transform the constant k into a function of x

$$y = K(x)\cdot \frac{1}{x}$$

Let’s derive y:

$$y’= K(x)\cdot (-\frac{1}{x^2}) + K'(x)\cdot \frac{1}{x}$$

These y and y’ are plugged into the initial non-homogeneous equation:

$$\begin{align*}y’&=-\frac{y}{x}+1\\ \Leftrightarrow K(x)\cdot (-\frac{1}{x^2}) + K'(x)\cdot \frac{1}{x}&=K(x)\cdot \frac{1}{x}\cdot (-\frac{1}{x}) +1\\ \Leftrightarrow K(x)\cdot (-\frac{1}{x^2}) + K'(x)\cdot \frac{1}{x}&=K(x)\cdot (-\frac{1}{x^2}) +1\\ \Leftrightarrow K'(x)\cdot \frac{1}{x}&=1\\ \Leftrightarrow K'(x)&=x\\ \Leftrightarrow K(x)&=\frac{1}{2}x^2+c\quad\quad c\in\mathbb{R}\end{align*}$$

To get the general solution plug this into the above for K(x):

$$\begin{align*}y &= K(x)\cdot \frac{1}{x}\\ &= (\frac{1}{2}x^2+c)\cdot \frac{1}{x}\\ &= \frac{x}{2}+\frac{c}{x}\end{align*}$$

To solve the initial value problem, meaning finding the constant c, we simply plug in x = 2 and y = 3/2:

$$\frac{3}{2}=\frac{2}{2}+\frac{c}{2}\\ \Rightarrow c=1$$

Therefore the solution is: