Krista King Math | Online math help

View Original

Solving linear differential equations

Standard form of a first order linear differential equation

To investigate first order differential equations, we’ll start by looking at equations given in a few very specific forms. The first of these is a first order linear differential equation.

Form of a first order linear differential equation

First order linear differential equations are equations given in the form

???\frac{dy}{dx}+P(x)y=Q(x)???

where ???P(x)??? and ???Q(x)??? are continuous functions. They always have a solution in the form ???y=y(x)???. Realize that some linear equations might be disguised in a slightly different form. For instance, the equation

???P(x)y=Q(x)-\frac{dy}{dx}???

is a linear equation because it can be manipulated to match the form above simply by adding ???dy/dx??? to both sides of the equation.

Either way, these linear equations are first order equations because they contain a first derivative. Later we’ll look at how to solve higher order linear differential equations (which contain higher order derivatives), but for now we’ll focus only on first order equations.

When ???Q(x)=0???, the first order linear equation is homogeneous, and the equation simplifies to 

???\frac{dy}{dx}+P(x)y=0???

These homogeneous linear equations are also called separable differential equations, which we’ll cover a little later. For now, we’ll only say that the solution to a homogeneous linear equation is

???y=Ce^{K(x)}???, where ???K(x)=-\int P(x)\ dx???

Solving first order linear differential equations using the integrating factor method


Take the course

Want to learn more about Differential Equations? I have a step-by-step course for that. :)


Two examples of finding the general solution to a first-order linear differential equation

Here’s a quick example showing how we can use these formulas to find the solution to the homogeneous linear equation (separable equation).

Example

Find the solution to the linear differential equation.

???\frac{dy}{dx}-2xy=0???

We start with 

???K(x)=-\int(-2x)\ dx=\int2x\ dx=x^2???

so the general solution is

???y=Ce^{x^2}???


Again, we’ll talk more about these homogeneous linear equations (separable equations) later, but our focus here is really on solving nonhomogeneous first order linear equations, in which ???Q(x)\ne0???.

Solving equations with the integrating factor

Once we’ve identified that we have a first order linear differential equation, we can always follow the same set of steps to arrive at the solution to the equation, ???y=y(x)???.

  1.  Make sure that the equation matches the general form of a first order linear differential equation

  2.  From the equation, identify ???P(x)??? and ???Q(x)???.

  3.  Find the equation’s integrating factor, ???I(x)=e^{\int P(x)\ dx}???.

  4.  Multiply through the linear equation by the integrating factor.

  5.  Reverse the product rule to rewrite the left side of the resulting equation as ???(d/dx)[yI(x)]???.

  6.  Integrate both sides of the equation to find ???y=y(x)???.

Let’s work through an example so that we can see these steps in action.


Example

Find the solution to the linear differential equation.

???x\frac{dy}{dx}-2y=x^2???

Our first step is to match the given equation to the standard form of a first order linear differential equation, which we’ll do by dividing through both sides of the equation by ???x???.

???x\frac{dy}{dx}-2y=x^2???

???\frac{dy}{dx}-\frac{2}{x}y=x??? (Step 1)

This new form matches the standard form we need, which means we can now identify ???P(x)??? and ???Q(x)??? (Step 2) as

???P(x)=-\frac{2}{x}???

???Q(x)=x???

Notice that we included the negative sign in front of the ???2/x??? as part of the ???P(x)??? function. Any negative sign that precedes the ???P(x)??? function should be included in ???P(x)???, and any negative sign that leads the right side ???Q(x)??? function should be included in ???Q(x)???.

Now that we have ???P(x)???, we can find the integrating factor (Step 3).

???I(x)=e^{\int P(x)\ dx}???

???I(x)=e^{\int -\frac{2}{x}\ dx}???

???I(x)=e^{-2\int \frac{1}{x}\ dx}???

???I(x)=e^{-2\ln{x}}???

???I(x)=e^{\ln{x^{-2}}}???

???I(x)=x^{-2}???

???I(x)=\frac{1}{x^2}???

When we integrated, notice that we didn’t add ???C??? to account for the constant of integration, like we normally would whenever we’re evaluating an indefinite integral.

We can always leave it out during this process, because we’re only looking for one solution to the linear differential equation, and that one solution can be associated with ???C=0???. Other values of ???C??? could give other solutions to the linear equation, but we only need one solution, so for the sake of simplicity, we’ll always choose ???C=0???.

Once we have the integrating factor, we’ll multiply it by both sides of our equation (Step 4).

???\frac{dy}{dx}\left(\frac{1}{x^2}\right)-\frac{2}{x}y\left(\frac{1}{x^2}\right)=x\left(\frac{1}{x^2}\right)???

???\frac{dy}{dx}\left(\frac{1}{x^2}\right)-\frac{2}{x^3}y=\frac{1}{x}???

Rewriting ???dy/dx??? as ???y’???, we get

???y'x^{-2}-2yx^{-3}=x^{-1}???

The reason we multiply through by the integrating factor is that it does something for us that’s extremely convenient, even though we don’t realize it yet.

It turns out that the left side of ???y'x^{-2}-2yx^{-3}=x^{-1}???, ???y'x^{-2}-2yx^{-3}???, is actually the derivative of ???yx^{-2}???. This is interesting because ???yx^{-2}??? is the product of ???y??? and our integrating factor. In other words, ???yI(x)=yx^{-2}???. We can prove this to ourselves if we take the derivative of ???yx^{-2}???. We’ll need to use the product rule for derivatives,

???\frac{d}{dx}f(x)g(x)=f'(x)g(x)+f(x)g'(x)???

Applying product rule, the derivative of ???yx^{-2}??? is

???\frac{d}{dx}(yx^{-2})=\left(\frac{d}{dx}y\right)(x^{-2})+(y)\left(\frac{d}{dx}x^{-2}\right)???

???\frac{d}{dx}(yx^{-2})=(y')(x^{-2})+(y)(-2x^{-3})???

???\frac{d}{dx}(yx^{-2})=y'x^{-2}-2yx^{-3}???

See how the derivative we just found matches ???y'x^{-2}-2yx^{-3}???, the left side of ???y'x^{-2}-2yx^{-3}=x^{-1}???? This is the magic of the integrating factor.

In other words, if we multiply our original linear differential equation by its integrating factor, the left side of the resulting equation will always be equal to

???\frac{d}{dx}(yI(x))???

Which means, coming back to this example, that we can make a substitution, replacing the left side of the resulting equation with ???(d/dx)(yx^{-2})??? (Step 5), which gives

???\frac{d}{dx}(yx^{-2})=x^{-1}???

Once we have the equation in this form, we integrate both sides (Step 6). On the left, the integral and the derivative cancel out, since they are inverse operations.

???\int \frac{d}{dx}(yx^{-2})=\int x^{-1}\ dx???

???yx^{-2}=\ln{|x|}+C???

We solve for ???y???, and find that the solution to the linear differential equation is

???y=x^{2}(\ln{|x|}+C)???


Let’s do one more example to show that this method works on another first order linear differential equation, but this time we’ll go a little faster.


Example

Solve the differential equation.

???\frac{dy}{dx}+2y=4e^{-2x}???

The equation is already in standard form for a linear differential equation, so we can identify ???P(x)=2??? and ???Q(x)=4e^{-2x}???, and then use ???P(x)??? to find the integrating factor.

???\rho(x)=e^{\int{P(x)\ dx}}???

???\rho(x)=e^{\int{2\ dx}}???

???\rho(x)=e^{2x}???

Multiply through the linear differential equation by the integrating factor.

???\frac{dy}{dx}(e^{2x})+2y(e^{2x})=4e^{-2x}(e^{2x})???

???\frac{dy}{dx}e^{2x}+2e^{2x}y=4e^{0}???

???\frac{dy}{dx}e^{2x}+2e^{2x}y=4???

We’ll replace the left side of the equation with ???(d/dx)(yI(x))???,

???\frac{d}{dx}(ye^{2x})=4???

then integrate both sides of the equation, remembering that the integral and derivative will cancel each other.

???\int\frac{d}{dx}(ye^{2x})\ dx=\int4\ dx???

???ye^{2x}=4x+C???

Dividing both sides by ???e^{2x}??? to get ???y??? by itself, we can say that the solution to the linear differential equation is

???y=\frac{4x+C}{e^{2x}}???


Why the integrating factor solves linear equations

The most interesting part about solving these linear equations is the idea of the integrating factor, ???I(x)=e^{\int P(x)\ dx}???. Here’s the reason this special value helps us to solve linear differential equations. If we start with a simplified version of the standard form of a linear equation,

???y'+Py=Q???

and then we multiply through by the integrating factor ???I???, we get

???y'I+PIy=QI???

Now if we were somehow able to replace the left side of this equation with ???(Iy)’???, the derivative of ???Iy???, then we would have

???(Iy)'=QI???

We could then integrate both sides of this,

???\int(Iy)'=\int QI???

and the derivative and integral operations would cancel each other on the left side, leaving us with just

???Iy=\int QI???

We’d then be able to divide through by ???I???, and thereby quickly and easily find the solution to the linear differential equation,

???y=\frac{1}{I}\int QI???

Okay, it’s great that we’ve found a solution equation for ???y???, but we only got here by making the significant assumption that we could just replace the left side of ???y'I+PIy=QI??? with ???(Iy)'???, and we can’t just change equations like this without some kind of justification.

If we’re going to do this, we need to show that it’s valid to say

???(Iy)'=y'I+PIy???

Well, notice that the left side of this equation is the derivative of a product, which should make us think about the product rule for derivatives. If we treat ???I??? as one function and ???y??? as another, then the derivative of the product, ???(Iy)'???, would be equal to

???(Iy)'=I'y+Iy'???

???(Iy)'=y'I+I'y???

If we compare this equation to ???(Iy)'=y'I+PIy???, we can see that they are perfectly identical, as long as

???I'=PI???

If we rewrite this equation and then separate variables (we’ll talk more about separating variables in a later lesson), we get

???\frac{dI}{dx}=P(x)I(x)???

???dI=P(x)I(x)\ dx???

???\frac{1}{I(x)}\ dI=P(x)\ dx???

Integrating both sides gives

???\int\frac{1}{I(x)}\ dI=\int P(x)\ dx???

???\ln{(I(x))}=\int P(x)\ dx???

???e^{\ln{(I(x))}}=e^{\int P(x)\ dx}???

???I(x)=e^{\int P(x)\ dx}???

This is how we build the formula for the integrating factor. We’ve shown why it’s the special function that, when we use it to multiply through the linear differential equation, it gives us a really easy way to find the solution to that linear equation.


Get access to the complete Differential Equations course