7.3: Linear Equations
The linear first-order differential equation (linear in \(y\) and its derivative) can be written in the form
\[\frac{d y}{d x}+p(x) y=g(x) \nonumber \]
with the initial condition \(y\left(x_{0}\right)=y_{0}\) . Linear first-order equations can be integrated using an integrating factor \(\mu(x)\) . We multiply Equation \ref{7.8} by \(\mu(x)\) ,
\[\mu(x)\left[\frac{d y}{d x}+p(x) y\right]=\mu(x) g(x) \nonumber \]
and try to determine \(\mu(x)\) so that
\[\mu(x)\left[\frac{d y}{d x}+p(x) y\right]=\frac{d}{d x}[\mu(x) y] \nonumber \]
Equation Equation \ref{7.9} then becomes
\[\frac{d}{d x}[\mu(x) y]=\mu(x) g(x) \nonumber \]
Equation Equation \ref{7.11} is easily integrated using \(\mu\left(x_{0}\right)=\mu_{0}\) and \(y\left(x_{0}\right)=y_{0}\) :
\[\mu(x) y-\mu_{0} y_{0}=\int_{x_{0}}^{x} \mu(x) g(x) d x \nonumber \]
\[y=\frac{1}{\mu(x)}\left(\mu_{0} y_{0}+\int_{x_{0}}^{x} \mu(x) g(x) d x\right) . \nonumber \]
It remains to determine \(\mu(x)\) from Equation \ref{7.10}. Differentiating and expanding Equation \ref{7.10} yields
\[\mu \frac{d y}{d x}+p \mu y=\frac{d \mu}{d x} y+\mu \frac{d y}{d x} ; \nonumber \]
and upon simplifying,
\[\frac{d \mu}{d x}=p \mu . \nonumber \]
Equation Equation \ref{7.13} is separable and can be integrated:
\[\begin{gathered} \int_{\mu_{0}}^{\mu} \frac{d \mu}{\mu}=\int_{x_{0}}^{x} p(x) d x, \\ \ln \frac{\mu}{\mu_{0}}=\int_{x_{0}}^{x} p(x) d x \\ \mu(x)=\mu_{0} \exp \left(\int_{x_{0}}^{x} p(x) d x\right) . \end{gathered} \nonumber \]
Notice that since \(\mu_{0}\) cancels out of \(Equation \ref{7.12}\) , it is customary to assign \(\mu_{0}=1\) . The solution to Equation \ref{7.8} satisfying the initial condition \(y\left(x_{0}\right)=y_{0}\) is then commonly written as
\[y=\frac{1}{\mu(x)}\left(y_{0}+\int_{x_{0}}^{x} \mu(x) g(x) d x\right) \nonumber \]
with
\[\mu(x)=\exp \left(\int_{x_{0}}^{x} p(x) d x\right) \nonumber \]
the integrating factor. This important result finds frequent use in applied mathematics.
Example: Solve \(\frac{d y}{d x}+2 y=e^{-x}\) , with \(y(0)=3 / 4\) .
Note that this equation is not separable. With \(p(x)=2\) and \(g(x)=e^{-x}\) , we have
\[\begin{aligned} \mu(x) &=\exp \left(\int_{0}^{x} 2 d x\right) \\ &=e^{2 x} \end{aligned} \nonumber \]
and
\[\begin{aligned} y &=e^{-2 x}\left(\frac{3}{4}+\int_{0}^{x} e^{2 x} e^{-x} d x\right) \\ &=e^{-2 x}\left(\frac{3}{4}+\int_{0}^{x} e^{x} d x\right) \\ &=e^{-2 x}\left(\frac{3}{4}+\left(e^{x}-1\right)\right) \\ &=e^{-2 x}\left(e^{x}-\frac{1}{4}\right) \\ &=e^{-x}\left(1-\frac{1}{4} e^{-x}\right) \end{aligned} \nonumber \]
Example: Solve \(\frac{d y}{d x}-2 x y=x\) , with \(y(0)=0\) .
This equation is separable, and we solve it in two ways. First, using an integrating factor with \(p(x)=-2 x\) and \(g(x)=x\) :
\[\begin{aligned} \mu(x) &=\exp \left(-2 \int_{0}^{x} x d x\right) \\ &=e^{-x^{2}} \end{aligned} \nonumber \]
and
\[y=e^{x^{2}} \int_{0}^{x} x e^{-x^{2}} d x \nonumber \]
The integral can be done by substitution with \(u=x^{2}, d u=2 x d x\) :
\[\begin{aligned} \int_{0}^{x} x e^{-x^{2}} d x &=\frac{1}{2} \int_{0}^{x^{2}} e^{-u} d u \\ &\left.=-\frac{1}{2} e^{-u}\right]_{0}^{x^{2}} \\ &=\frac{1}{2}\left(1-e^{-x^{2}}\right) \end{aligned} \nonumber \]
Therefore,
\[\begin{aligned} y &=\frac{1}{2} e^{x^{2}}\left(1-e^{-x^{2}}\right) \\ &=\frac{1}{2}\left(e^{x^{2}}-1\right) \end{aligned} \nonumber \]
Second, we integrate by separating variables:
\[\begin{gathered} \frac{d y}{d x}-2 x y=x, \\ \frac{d y}{d x}=x(1+2 y), \\ \int_{0}^{y} \frac{d y}{1+2 y}=\int_{0}^{x} x d x \\ \frac{1}{2} \ln (1+2 y)=\frac{1}{2} x^{2}, \\ 1+2 y=e^{x^{2}} \\ y=\frac{1}{2}\left(e^{x^{2}}-1\right) \end{gathered} \nonumber \]
The results from the two different solution methods are the same, and the choice of method is a personal preference.