3.3: Linear Equations
The linear first-order differential equation (linear in \(y\) and its derivative) can be written in the form \[\label{eq:1}\frac{dy}{dx}+p(x)y=g(x),\] with the initial condition \(y(x_0) = y_0\). Linear first-order equations can be integrated using an integrating factor \(\mu(x)\). We multiply \(\eqref{eq:1}\) by \(\mu(x)\), \[\label{eq:2}\mu (x)\left[\frac{dy}{dx}+p(x)y\right]=\mu (x)g(x),\] and try to determine \(\mu (x)\) so that \[\label{eq:3}\mu (x)\left[\frac{dy}{dx}+p(x)y\right]=\frac{d}{dx}[\mu (x)y].\]
Equation \(\eqref{eq:2}\) then becomes \[\label{eq:4}\frac{d}{dx}[\mu (x)y]=\mu (x)g(x).\]
Equation \(\eqref{eq:4}\) is easily integrated using \(\mu (x_0)=\mu_0\) and \(y(x_0)=y_0\):
\[\mu (x)y-\mu_0 y_0=\int_{x_0}^x\mu (x)g(x)dx,\nonumber\] or \[\label{eq:5}y=\frac{1}{\mu (x)}\left(\mu_0y_0+\int_{x_0}^x\mu(x)g(x)dx\right).\]
It remains to determine \(\mu(x)\) from \(\eqref{eq:3}\). Differentiating and expanding \(\eqref{eq:3}\) yields \[\mu\frac{dy}{dx}+p\mu y=\frac{d\mu}{dx}y+\mu\frac{dy}{dx};\nonumber\] and upon simplifying, \[\label{eq:6}\frac{d\mu}{dx}=p\mu.\]
Equation \(\eqref{eq:6}\) is separable and can be integrated:
\[\begin{aligned}\int_{\mu_0}^{\mu}\frac{d\mu}{\mu}&=\int_{x_0}^xp(x)dx, \\ \ln\frac{\mu}{\mu_0}&=\int_{x_0}^xp(x)dx, \\ \mu(x)&=\mu_0\exp\left(\int_{x_0}^xp(x)dx\right).\end{aligned}\]
Notice that since \(\mu_0\) cancels out of \(\eqref{eq:5}\), it is customary to assign \(\mu_0 = 1\). The solution to \(\eqref{eq:1}\) satisfying the initial condition \(y(x_0) = y_0\) is then commonly written as \[y=\frac{1}{\mu(x)}\left(y_0+\int_{x_0}^x\mu(x)g(x)dx\right),\nonumber\] with \[\mu(x)=\exp\left(\int_{x_0}^xp(x)dx\right)\nonumber\] the integrating factor. This important result finds frequent use in applied mathematics.
Solve \(\frac{dy}{dx}+2y=e^{-x}\), with \(y(0)=3/4\).
Solution
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 2dx\right) \\ &=e^{2x},\end{aligned}\] and \[\begin{aligned}y&=e^{-2x}\left(\frac{3}{4}+\int_0^x e^{2x}e^{-x}dx\right) \\ &=e^{-2x}\left(\frac{3}{4}+\int_0^x e^xdx\right) \\ &=e^{-2x}\left(\frac{3}{4}+(e^x-1)\right) \\ &=e^{-2x}\left(e^x-\frac{1}{4}\right) \\ &=e^{-x}\left(1-\frac{1}{4}e^{-x}\right).\end{aligned}\]
Solve \(\frac{dy}{dx}-2xy=x\), with \(y(0)=0\).
Solution
This equation is separable, and we solve it in two ways. First, using an integrating factor with \(p(x) = −2x\) and \(g(x) = x\):
\[\begin{aligned}\mu(x)&=\exp\left(-2\int_0^x xdx\right) \\ &=e^{-x^2},\end{aligned}\] and \[y=e^{x^2}\int_0^x xe^{-x^2}dx.\nonumber\]
The integral can be done by substitution with \(u = x^2\), \(du = 2xdx\):
\[\begin{aligned}\int_0^x xe^{-x^2}dx&=\frac{1}{2}\int_0^{x^2}e^{-u}du \\ &=-\frac{1}{2}e^{-u}]_0^{x^2}\\ &=\frac{1}{2}\left(1-e^{-x^2}\right).\end{aligned}\]
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}\]
Second, we integrate by separating variables:
\[\begin{aligned}\frac{dy}{dx}-2xy&=x, \\ \frac{dy}{dx}&=x(1+2y), \\ \int_0^y\frac{dy}{1+2y}&=\int_0^x xdx, \\ \frac{1}{2}\ln (1+2y)&=\frac{1}{2}x^2, \\ 1+2y&=e^{x^2}, \\ y&=\frac{1}{2}\left(e^{x^2}-1\right).\end{aligned}\]
The results from the two different solution methods are the same, and the choice of method is a personal preference.