First-Order Linear ODE: y' + y/x = 1/x^2 with y(1) = 1

Brain Teaser · Easy · Free problem

Solve the initial value problem $$\frac{dy}{dx} + \frac{y}{x} = \frac{1}{x^{2}}, \qquad x > 0, \qquad y(1) = 1.$$

Hints

  1. This is a first-order linear equation $y' + P(x)y = Q(x)$ with $P = 1/x$ and $Q = 1/x^2$. It is not separable, so use an integrating factor.
  2. The integrating factor is $I(x) = e^{\int P\,dx} = e^{\ln x} = x$. Multiply the whole equation by $x$ and look at the left-hand side.
  3. $xy' + y = (xy)'$, so $(xy)' = 1/x$. Integrate, then use $y(1) = 1$.

Worked Solution

How to Think About It: A first-order linear ODE $y' + P(x)y = Q(x)$ is solved by multiplying through by the integrating factor $I(x) = \exp\left(\int P\,dx\right)$, which turns the left side into $(I y)'$. Here $P = 1/x$ gives the especially clean factor $I = x$.

Quick Estimate: At $x = 1$: $y' = 1/x^2 - y/x = 1 - 1 = 0$, so the solution starts flat at $1$. For large $x$ both forcing $1/x^2$ and the solution should decay, roughly like $(\ln x)/x$, since $(xy)' = 1/x$ makes $xy$ grow logarithmically.

Formal Solution:

*Step 1 -- Integrating factor.* With $P(x) = 1/x$, $$I(x) = \exp\left(\int \frac{dx}{x}\right) = e^{\ln x} = x \qquad (x > 0).$$

*Step 2 -- Multiply and recognize a derivative.* $$x y' + y = \frac{1}{x} \quad \Longleftrightarrow \quad \frac{d}{dx}\left(x y\right) = \frac{1}{x}.$$

*Step 3 -- Integrate.* $$xy = \ln x + C \quad \Longrightarrow \quad y = \frac{\ln x + C}{x}.$$

*Step 4 -- Initial condition.* $y(1) = (\ln 1 + C)/1 = C = 1$.

*Step 5 -- Verify.* $y = \dfrac{\ln x + 1}{x}$ gives $y' = \dfrac{1 - (\ln x + 1)}{x^{2}} = -\dfrac{\ln x}{x^{2}}$, and $y' + \dfrac{y}{x} = -\dfrac{\ln x}{x^2} + \dfrac{\ln x + 1}{x^2} = \dfrac{1}{x^2}$. $\checkmark$

Answer: $y(x) = \dfrac{\ln x + 1}{x}$.

Intuition

Multiplying a linear first-order equation by $e^{\int P}$ makes the left-hand side an exact derivative, collapsing the equation to a single integration. The same integrating-factor trick solves the Ornstein-Uhlenbeck SDE (multiply by $e^{\theta t}$), Vasicek bond pricing, and any mean-reverting signal model; the $1/x$ coefficient here is the deterministic cousin of a rate that decays with horizon.

Open the full interactive solver →