Linear Equations
Discussion
We solved exact equations by assuming there was a solution and working backwards. But there will be a solution to any equation we can solve, and it is a theorem that all (reasonable) first order equations can be solved. So why aren't all equations exact? Consider the following example. $$ \begin{align} (x^2+y)+(x-\sin(y))\frac{dy}{dx}&=0\qquad\text{is exact} \\ \frac{x^2+y}{x}+\frac{x-\sin(y)}{x}\frac{dy}{dx}&=0\qquad\text{is not exact} \end{align} $$ There is no real difference between the two equations, we have just divided through by $x$ to obtain the second equation from the first. The equations have the same solutions. But when we test for exactness, we find that only the first equation is exact. The reason most first order equations aren't exact is that some key factor has been divided out. One way to solve the equation would be to find the factor, called an integrating factor, and put it back in. Unfortunately, finding integrating factors can be extremely difficult. There is one situation where it is fairly straightforward, when the equation is linear. A first order differential equation is said to be linear if it can be written in the form $$ y' + p(x)y = q(x) $$ For a linear equation, we find an integrating factor as follows $$ \mu(x) = e^{\int p(x)\,dx} $$ If we multiply through the linear equation by $\mu(x)$ we obtain $$ \mu(x)y'(x) + \mu(x)p(x)y(x) = \mu(x)q(x) $$ Now $\mu'(x) = \mu(x)p(x)$ from the way we defined $\mu(x)$, so we can now write our equation as $$ \mu(x)y'(x) + \mu'(x)y(x) = \mu(x)q(x) $$ or (applying the product rule in reverse) $$ \frac{d}{dx}(\mu(x)y(x)) = \mu(x)q(x) $$ Now we integrate both sides to obtain $$ \mu(x)y(x) = \int \mu(x)q(x)\,dx $$ so $$ y(x) = \frac{1}{\mu(x)}\int \mu(x)q(x)\,dx $$ WARNING: You can't cancel the $\mu(x)$ inside the integral by the $\mu(x)$ outside the integral. This formula is confusing because we are using $x$ as both the dummy variable of integration and as the independent variable of the resulting function. Because of this it is often preferable to write the solution as $$ y(x)=\frac{1}{\mu(x)}\left(\int_a^x \mu(s)q(s)\,ds + C\right) \tag 1$$ In this form we use $s$ as the variable of integration and use $x$ as the upper limit of integration to show we want to treat the result as a function of $x$. The $a$ as the lower limit of integration is an arbitrary constant as is $C$, the constant of integration. This seems to give us two arbitrary constants, but we really only have one "degree of freedom." That is, for any choice of $a$, we can choose $C$ to give us any solution to the equation. This is easiest to understand when we deal with a particular example. Example: $y'+2y=e^x$ $$ \begin{align} \mu(x)&=e^{\int2\,dx}=e^{2x} \\ y(x)&=\frac{\int_a^x e^{2s}e^s\,ds+C}{e^{2x}}=\frac{\int_a^x e^{3s}\,ds+C}{e^{2x}} \\ y(x)&=\frac{e^{3x}/3-e^{3a}/3+C}{e^{2x}} \\ y(x)&=e^x/3+\tilde{C}e^{-2x}\qquad(\tilde{C}=C-e^{3a}/3) \end{align} $$ As you see, the choice of $a$ doesn't matter, it all gets sucked into the arbitrary constant in the end. Linear equations won't have singular solutions, so the general solution gives all the solutions. You may be wondering about why I left out the constant of integration when computing $\mu(x)$. I could have included a constant of integration, which would give me an infinite family of integrating factors. But I don't need an infinite family of integrating factors to solve the problem; I only need one integrating factor. So I can ignore that constant. We are now ready to give the paradigm. While it is possible to just memorize the formula for the solution, I prefer to work through the whole process. While that takes longer, I find I am less likely to make mistakes if I go through the details. You are welcome to use the paradigm or the formula (1) depending on which you find works best for you.Paradigm
Solve $$dy/dx+2y/x=4$$ Step 1: Find the integrating factor $$ \mu(x)=e^{\int 2/x\,dx}=e^{2\log(x)}=x^2 $$ Step 2: Multiply through by the integrating factor $$ x^2\frac{dy}{dx}+2xy=4x^2 $$ Step 3: Recognize the left hand side as the derivative of $\mu y$. $$ \frac{d}{dx}(x^2y)=4x^2 $$ Step 4: Integrate both sides $$ x^2y=\int 4x^2\,dx=(4/3)x^3+C $$ Step 5: Solve for $y$. $$ y(x)=(4/3)x+Cx^{-2} $$ EXAMPLE: Solve the initial value problem $$dy/dx+2xy=1, y(1)=2$$. FIRST: Find the general solution. Step 1: $$\displaystyle\mu(x)=e^{\int 2x\,dx}=e^{x^2}$$ Step 2: $$\displaystyle e^{x^2}dy/dx+2xe^{x^2}y=e^{x^2}$$ Step 3: $$\displaystyle \frac{d}{dx}(e^{x^2}y)=e^{x^2}$$ Step 4: $$\displaystyle e^{x^2}y=\int e^{x^2}\,dx=???$$ Unfortunately, I don't know the indefinite integral of $e^{x^2}$. So I leave the integral as a definite integral with $x$ as the upper limit to give me a function of $x$ and $1$ as the lower limit because the initial value is given at $1$ (you'll see why that matters in a second). And I won't forget the constant of integration. Step 4: (Take Two) $$\displaystyle e^{x^2}y=\int_1^x e^{s^2}\,ds+C$$ Step 5: $$\displaystyle y(x)=e^{-x^2}\int_1^x e^{s^2}\,ds+Ce^{-x^2}$$ SECOND: Solve the initial value problem by plugging in. $$ \begin{align} y(1)=e^{-1^2}\int_1^1 e^{s^2}\,ds+Ce^{-1^2}&{\buildrel \text{set}\over =} 2 \\ C&=2e \end{align} $$ While I don't know the indefinite integral of $e^{s^2}$, I do know that the integral of anything from $1$ to $1$ is $0$. That is the advantage of choosing the lower limit to be the same as the place where the initial value is given. So the final answer is $$y(x)=e^{-x^2}\int_1^x e^{s^2}\,ds+2e^{1-x^2}$$ You can generate additional examples of initial value problems for first order linear equations here.If you have any problems with this page, please contact bennett@math.ksu.edu.
©2010, 2014 Andrew G. Bennett