Wichita State University Logo

M555: Ordinary Differential Equations

3.6 Variation of Parameters


3.6.1 Solving Nonhomogeneous Equations

In the last section we utilized the method of Undetermined Coefficients to find a particular solution to a nonhomogeneous linear differential equation. After also solve the associated homogeneous solution we added them together to get the general solution of the linear differential equation.

In general if we have a 2nd-order linear nonhomogeneous initial value problem

$$y''(t) + p(t)y'(t) + q(t)y = g(t),\qquad y(t_0) = y_0,\ y'(t_0)=y_1,$$
then we solve the differential equation in three steps.

1. Solve the Associated 2nd-Order Linear Homogeneous Differential Equation

First we set the right-hand side of the differential equation to zero

$$y''(t) + p(t)y'(t) + q(t)y = 0$$
This can be thought of as solving the linear operator problem

$$L[y] = 0,$$
where $L[y] = y''(t) + p(t)y'(t) + q(t)y$. The solutions form a two-dimensional vector space called the kernel of the differential operator. We find two fundamental solutions $y_1(t)$ and $y_2(t)$ for the homogenous differential equation and the kernel of the differential equation, the two-dimensional vector space of all solutions, is the set of all possible linear combinations of the two fundamental solutions

$$y(t) = c_1y_1(t) + c_2y_2(t).$$

2. Find a Particular Solution

Next we look at the 2nd-order linear nonhomogeneous differential equation and try to find a particular solution $\Psi(t)$. There are several methods for finding a particular solution and they generally depend on the function on the right-hand side $\ g(t)$. If right-hand side $\ g(t)\ $ is the first and second derivative of functions we recognize, then one can use the method of undetermined coefficients to find a particular solution $\ \Psi(t)$.

If the method of undetermined coefficients fails, there are other methods for finding a particular solution so that

$$L\left[\Psi(t)\right] = \Psi''(t) + p(t)\Psi'(t) + q(t)\Psi(t) = g(t).$$
In any case if a particular solution is found then the general solution of the 2nd-order linear nonhomogeneous differential equation is given by

$$y(t) = c_1y_1(t) + c_2y_2(t) + \Psi(t).$$
This is because $L$ is a linear operator so

$$\begin{align*} L\left[c_1y_1(t) + c_2y_2(t) + \Psi(t)\right] &= c_1L\left[y_1(t)\right] + c_2L\left[y_2(t)\right] + L\left[\Psi(t)\right] \\ \\ &= c_1(0) + c_2(0) + g(t) \\ \\ &= g(t). \end{align*}$$

3. Use the Initial Conditions to Find the Unique Solution

At this point we differentiate our general solution and use our initial conditions to obtain two equations for our arbitrary constants

$$\begin{align*} y_0 &= y(t_0) = c_1y_1(t_0) + c_2y_2(t_0) + \Psi(t_0) \\ \\ y_1 &= y'(t_0) = c_1y_1'(t_0) + c_2y_2'(t_0) + \Psi'(t_0). \\ \end{align*}$$
This results in a system of two linear equations for our two unknown constants.

3.6.2 Method of Variation of Parameters

The method of variation of parameters is more general than the method of undetermined coefficients and will work for any 2nd-order linear differential equation. If we have a homogeneous differential equation or we recognize the types of functions that our nonhomogeneous differential equation must take, then we prefer the simpler methods already introduced. Think of the methods of this section like the quadratic formula; it is a method of last resort that you know will always work; it just takes a lot more of effort. The method of variation of parameters is a three-step process just like the method of undetermined coefficients. The first and last step are also the same.

  1. Solve the associated 2nd-order linear homogeneous differential equation.

  2. Utilize Variation of Parameters to find a particular solution.

  3. Use the initial conditions to find the unique solution.

The only difference is how we find a particular solution.

Example 1

Find the general solution to the 2nd-order linear differential equation

$$y'' + 4y = 8\tan(2t).$$
Notice that we do not have an initial value problem so we will not be using the third step in our process.

1. Solve the associated 2nd-order linear homogeneous differential equation.

Writing down the characteristic equation we have

$$\begin{align*} d^2 + 4 &= 0 \\ \\ d^2 &= -4 \\ \\ d &= \pm 2i \end{align*}$$
The homogeneous solution is therefore

$$y_h(t) = c_1 \cos(2t) + c_2 \sin(2t).$$

2. Find a particular solution.

Unlike sine and cosine, one generally doesn't recognize functions whose second derivative is the tangent function. We can integrate tangent to get

$$\displaystyle\int\tan(t)\,dt = -\log\left|\cos(t)\right| + C = \log\left|\sec(t)\right| + C.$$
Looking for elementary functions whose second derivative are $\tan(t)\ $ is much more difficult. Instead we will resort to variation of parameters because it always works. We will start as we did in d'Alembert's method in Section 3.4 by replacing the arbitrary constants in our homogeneous solution with functions $u(t)$ and $v(t)$ to write our solution

$$y(t) = u(t)y_1(t) + v(t)y_2(t) = u\cos(2t) + v\sin(2t).$$
Next, we substitute this into our differential equation. To do this we will need the second derivative as well. We write out both terms vertically one derivative at a time.

$$\begin{align*} y'(t) &= u'\cos(2t) - 2u\sin(2t) + v'\sin(2t) + 2v\cos(2t) \\ \\ &= 2v\cos(2t) - 2u\sin(2t) + u'\cos(2t) + v'\sin(2t). \end{align*}$$
Notice that one differentiates using the product rule, but we write the first derivative with the two terms with $u(t)$ and $v(t)$ first and the terms with $u'(t)$ and $v'(t)$ last. When we finish substituting $u\cos(2t) + v\sin(2t)$ into our differential equation by evaluating our differential operator at $u\cos(2t) + v\sin(2t)$ we will obtain

$$L\left[u\cos(2t) + v\sin(2t)\right] = \tan(2t).$$
We will have only one equation and two unknowns $u(t)$ and $v(t)$. This means that there are infinitely many different particular solutions we might find. However, we only need one particular solution. We need some other condition imposed on our system. When we are in this position of selecting one from infinitely many possible solutions we generally look for a condition that helps us pick out a solution in some way.

  1. A condition that is easy to use and consistent with our system of equations.

  2. A condition that simplifies our computations.

  3. A condition that selects an elementary solution over more complicated ones.

The condition we choose is

$$u'\cos(2t) + v'\sin(2t) = 0.$$
This makes the computation for $y'(t)$

$$\begin{align*} y'(t) &= 2v\cos(2t) - 2u\sin(2t) + u'\cos(2t) + v'\sin(2t) \\ \\ &= 2v\cos(2t) - 2u\sin(2t) + 0 \\ \\ &= 2v\cos(2t) - 2u\sin(2t). \end{align*}$$
Differentiating again to obtain $y''(t)$ gives us

$$y''(t) = -4u\cos(2t) - 4v\sin(2t) - 2u'\sin(2t) + 2v'\cos(2t).$$
Using the equations for $y'$ and $y''$, we can now substitute $u\cos(2t) + v\sin(2t)$ into our differential equation.

$$\begin{align*} L[y(t)] &= L\left[u\cos(2t) + v\sin(2t)\right] = y'' + 4y = \tan(2t) \\ \\ 4y(t) &= \ \ 4u\cos(2t) + 4v\sin(2t) \\ y''(t) &= -4u\cos(2t) - 4v\sin(2t) - 2u'\sin(2t) + 2v'\cos(2t) \\ ----&- ----------------------- \\ \tan(2t) &= \qquad 0\quad\ \ \ \ + \qquad 0\ \ \ \ - 2u'\sin(2t) + 2v'\cos(2t) \\ \end{align*}$$
This gives us a second equation we can use

$$ - 2u'\sin(2t) + 2v'\cos(2t) = \tan(2t).$$

Together our chosen condition on the particular solution and the above equation give us a linear system of two equations and two unknowns

$$\begin{align*} u'\cos(2t) + v'\sin(2t) &= 0 \\ \\ -2u'\sin(2t) + 2v'\cos(2t) &= \tan(2t). \end{align*}$$

To make this easier to see, let us write the system in matrix form

$$\left[\begin{array}{cc} \cos(2t) & \sin(2t) \\ -2\sin(2t) & 2\cos(2t) \end{array}\right]\left[\begin{array}{c} u'(t) \\ v'(t) \end{array}\right] = \left[\begin{array}{c} 0 \\ \tan(t) \end{array}\right].$$
The linear equation can be solved for $u'(t)$ and $v'(t)$ using Cramer's Rule

$$\begin{align*} W\left[\cos(t),\ \sin(t)\right] &= \left|\begin{array}{cc} \cos(2t) & \sin(2t) \\ -2\sin(2t) & 2\cos(2t) \end{array}\right| \\ \\ &= 2\cos^2(t) + 2\sin^2(t) = 2 \\ \\ u'(t) &= \dfrac{\left|\begin{array}{cc} 0 & \sin(2t) \\ \tan(2t) & 2\cos(2t) \end{array}\right|}{\left|\begin{array}{cc} \cos(2t) & \sin(2t) \\ -2\sin(2t) & 2\cos(2t) \end{array}\right|} \\ \\ &= \dfrac{-\sin(2t)\tan(2t)}{2} \\ \\ v'(t) &= \dfrac{\left|\begin{array}{cc} \cos(2t) & 0 \\ -2\sin(2t) & \tan(2t) \end{array}\right|}{\left|\begin{array}{cc} \cos(2t) & \sin(2t) \\ -2\sin(2t) & 2\cos(2t) \end{array}\right|} \\ \\ &= \dfrac{\sin(2t)}{2} \end{align*}$$
Unfortunately, we have yet to find $u(t)$ and $v(t)$. We found $u'(t)$ and $v'(t)$. We integrate to $u'(t)$ to get

$$\begin{align*} u(t) &= \displaystyle\int -\dfrac{1}{2}\sin(2t)\tan(2t)\,dt \\ \\ &= -\dfrac{1}{2}\displaystyle\int\dfrac{\sin^2(2t)}{\cos(2t)}\,dt \\ \\ &= -\dfrac{1}{2}\displaystyle\int\dfrac{1 - \cos^2(2t)}{\cos(2t)}\,dt \\ \\ &= \dfrac{1}{2}\displaystyle\int\left(\cos(2t) - \sec(2t)\right)\,dt \\ \\ &= \dfrac{1}{4}\sin(2t) - \dfrac{1}{4}\log\left|\sec(2t) + \tan(2t)\right| + c_1 \end{align*}$$
We integrate $v'(t)$ to obtain

$$\begin{align*} v(t) &= \displaystyle\int \dfrac{\sin(2t)}{2}\,dt \\ &= -\dfrac{\cos(2t)}{4} + c_2. \end{align*}$$
Substituting our expressions for $u(t)$ and $v(t)$ into our general solution we see that the solution takes the form

$$y(t) = \left(\dfrac{1}{4}\sin(2t) - \dfrac{1}{4}\log\left|\sec(2t) + \tan(2t)\right| + c_1\right)\cos(2t) + \left(-\dfrac{\cos(2t)}{4} + c_2\right)\sin(2t).$$
If we distribute our multiplication over addition are rearrange the terms the solution becomes

$$\begin{align*} y(t) &= c_1\cos(2t) + c_2\sin(2t) + \dfrac{1}{4}\sin(2t)\cos(2t) - \dfrac{1}{4}\sin(2t)\cos(2t) \\ &\qquad\qquad -\cos(2t)\dfrac{1}{4}\log\left|\sec(2t) + \tan(2t)\right|. \end{align*}$$
This simplifies to our general solution for the 2nd-order linear nonhomogeneous differential equation

$$y(t) = c_1\cos(2t) + c_2\sin(2t) - \dfrac{\cos(2t)}{4}\log\left|\sec(2t) + \tan(2t)\right|.$$

3. Use the initial conditions to find the unique solution

Isn't it a good thing we don't have initial conditions and this problem is over!

Example 2

There are simpler methods than variation of parameters, however they don't work with every 2nd-order linear nonhomogeneous differential equation

$$y'' + p(t)y' + q(t)y = g(t).$$
Undetermined coefficients works well only if we recognize the two antiderivatives of $g(t)$. If we can factor the differential operator into a composition of two first order differential equations, then we can solve two 1st-order linear differential equations. Consider the 2nd-order linear nonhomogeneous differential equation

$$y'' - 2y' - 3y = -3te^{-t}. $$
Factoring the characteristic polynomial, we obtain

$$\begin{align*} (d^2 - 2d - 3)[y] &= -3te^{-t} \\ \\ (d + 1)(d - 3)[y] &= -3te^{-t} \\ \end{align*}$$
If we define $v(t) = (d - 3)y(t),$ then we have

$$\begin{align*} (d + 1)[v] &= -3te^{-t} \\ \\ v' + v &= -3te^{-t} \\ \\ \mu(t) &= e^{\int\,dt} = e^t\qquad\text{integrating factor} \\ \\ e^tv' + e^tv &= -3te^{-t}e^t = -3t \\ \\ \left[e^tv\right]' &= -3t \\ e^tv &= \displaystyle\int -3t\,dt = -\dfrac{3}{2}t^2 + c_1 \\ \\ v(t) &= -\dfrac{3}{2}t^2e^{-t} + c_1e^{-t} \\ \\ (d - 3)[y] &= -\dfrac{3}{2}t^2e^{-t} + c_1e^{-t} \\ \\ y' - 3y &= -\dfrac{3}{2}t^2e^{-t} + c_1e^{-t} \\ \\ \mu(t) &= e^{\int -3\,dt} = e^{-3t}\qquad\text{integrating factor} \\ \\ e^{-3t}y' - 3e^{-3t}y &= \left(-\dfrac{3}{2}t^2e^{-t} + c_1e^{-t}\right)e^{-3t} \\ \\ \left[e^{-3t}y\right]' &= -\dfrac{3}{2}t^2e^{-4t} + c_1e^{-4t} \\ \\ e^{-3t}y &= \displaystyle\int -\dfrac{3}{2}t^2e^{-4t} + c_1e^{-4t}\,dt \\ \end{align*}$$
In order to integrate $-\frac{3}{2}t^2e^{-4t}\,dt$ we will need to integrate by parts several times

The function -(3/2) t squared times e to the negative 4 t is integrated by parts several times using a technique called the ladder. Two columns are formed. In the left column, the function designed as u is differentiated several times, and in the right column, the dv function is integrated several times.

Completing our integration, we obtain

$$e^{-3t}y = \dfrac{3}{8}t^2e^{-4t} + \dfrac{3}{16}te^{-4t} + \dfrac{3}{64}e^{-4t} -\dfrac{c_1}{4}e^{-4t} + c_2. $$
If we multiply both sides of the equation by $e^{3t}$ and recall that an arbitrary constant divided by $-4$ and added to $\frac{3}{64}$ is also an arbitrary constant, then we get our general solution

$$y(t) = \dfrac{3}{8}t^2e^{-t} + \dfrac{3}{16}te^{-t} + c_1e^{-t} + c_2e^{3t}. $$
This solution is often written

$$y(t) = \dfrac{3}{16}e^{-t}\left( 2t^2 + t\right) + c_1e^{-t} + c_2e^{3t}. $$
This method works well if you can factor the characteristic polynomial to get a composition of two real 1st-order differential operators. If the characteristic polynomial has complex conjugate roots then you will usually resort to the method of variation of parameters. The method of variation of parameters is also useful when we do not already know the nonhomogeneous function $g(t)$. This often happens in engineering and science as we want design our testing or manufacturing device to adapt to the situation at hand; $g(t)$ is not known until it is measured in a real-time environment. Our computer program must compute the response or solution to the differential equation using the measured input $g(t)$ and the equation for the general solution.

Exercise 1

Find the response or solution of the initial value problem with input $g(t)$

$$y'' +5y' + 6y = g(t),\qquad y(0)=0,\ y'(0)=1$$


View Solution
First we solve the associated homogeneous problem
$$\begin{align*} d^2 + 5d + 6 &= 0 \\ \\ (d + 3)(d + 2) &= 0 \\ \\ y_h(t) &= c_1e^{-3t} + c_2e^{-2t} \end{align*}$$
Then we use variation of parameters to find an equation for the general solution
$$\begin{align*} y(t) &= \ \ \ \ \ ue^{-3t} + \ \ ve^{-2t} \\ \\ y'(t) &= -3ue^{-3t} - 2ve^{-2t} + \left[\ u'e^{-3t} + v'e^{-2t} = 0\ \right] \\ \\ y''(t) &= \ \ \ 9ue^{-3t} + 4ve^{-2t} - 3u'e^{-3t} - 2v'e^{-2t} \end{align*}$$
We substitute these expressions into our differential equation
$$\begin{align*} 6y(t) &= \ \ \ \ \ 6ue^{-3t} + \ \ 6ve^{-2t} \\ \\ 5y'(t) &= -15ue^{-3t} - 10ve^{-2t} \\ \\ y''(t) &= \ \ \ \ \ 9ue^{-3t} + \ \ 4ve^{-2t} - 3u'e^{-3t} - 2v'e^{-2t} \\ \hline \\ L[y] &= \ \ \ \ \ \ \ 0 \ \ \ \ \ \ + \ \ 0 \ \ \ \ \ \ \ \ \ -3u'e^{-3t} - 2v'e^{-2t} = g(t) \\ \end{align*}$$
This gives us two equations for $u'(t)$ and $v'(t)$
$$\begin{align*} u'e^{-3t} +\ \ v'e^{-2t} &= 0 \\ \\ -3u'e^{-3t} - 2v'e^{-2t} &= g(t) \end{align*}$$
We can write the system in matrix form
$$\left[\begin{array}{cc} \ \ \ \ \ e^{-3t} & \ \ \ \ \ e^{-2t} \\ -3e^{-3t} & -2e^{-2t} \end{array}\right]\left[\begin{array}{cc} u'(t) \\ v'(t) \end{array}\right] = \left[\begin{array}{cc} 0 \\ g(t) \end{array}\right].$$
We solve for $u'(t)$ and $v'(t)$ using the Wronskian and Cramer's Rule
$$\begin{align*} W(t) &= \left|\begin{array}{cc} \ \ \ \ \ e^{-3t} & \ \ \ \ \ e^{-2t} \\ -3e^{-3t} & -2e^{-2t} \end{array}\right| \\ \\ &= -2e^{-3t}e^{-2t} + 3e^{-3t}e^{-2t} = e^{-5t} \\ \\ u'(t) &= \dfrac{\left|\begin{array}{cc} \ 0 & \ \ \ \ \ e^{-2t} \\ g(t) & -2e^{-2t} \end{array}\right|}{W(t)} = -\dfrac{g(t)e^{-2t}}{e^{-5t}} = -g(t)e^{3t} \\ \\ u(t) &= \displaystyle\int_{t_0}^t -g(s)e^{3s}\,ds \\ \\ v'(t) &= \dfrac{\left|\begin{array}{cc} \ \ \ \ \ e^{-3t} & \ 0 \\ -3e^{-3t} & g(t) \end{array}\right|}{W(t)} = \dfrac{g(t)e^{-3t}}{e^{-5t}} = g(t)e^{2t} \\ \\ v(t) &= \displaystyle\int_{t_0}^t g(s)e^{2s}\,ds \\ \end{align*}$$
One substitutes the initial conditions into the general solution
$$\begin{align*} y(t) &= c_1e^{-3t} + c_2e^{-2t} + \left(\displaystyle\int_0^t -g(s)e^{3s}\,ds\right)e^{-3t} + \left(\displaystyle\int_0^t g(s)e^{2s}\,ds\right)e^{-2t} \\ \\ y(0) &= c_1e^0 + c_2e^0 + \left(\displaystyle\int_0^0 -g(s)e^{3s}\,ds\right)e^{-3t} + \left(\displaystyle\int_0^0 g(s)e^{2s}\,ds\right)e^{-2t} \\ \\ &= c_1 + c_2 = 0 \\ \\ y'(t) &= -3c_1e^{-3t} - 2c_2e^{-2t} - g(t)e^{3t} + g(t)e^{2t} \\ \\ y'(0) &= -3c_1 - 2c_2 - g(t) + g(t) = -3c_1 - 2c_2 = 1 \\ \\ \end{align*}$$
This gives us the system of equations
$$\begin{align*} \ \ c_1 + \ \ c_2&= 0 \\ \\ -3c_1 - 2c_2 &= 1 \\ c_1 &= \dfrac{\left|\begin{array}{cc} \ \ 0 & \ \ 1 \\ \ \ 1 & -2 \end{array}\right|}{\left|\begin{array}{cc} \ \ 1 & \ \ 1 \\ -3 & -2 \end{array}\right|} = \dfrac{-1}{1} = -1 \\ \\ c_2 &= \dfrac{\left|\begin{array}{cc} \ \ 1 & \ \ 0 \\ -3 & \ \ 1 \end{array}\right|}{\left|\begin{array}{cc} \ \ 1 & \ \ 1 \\ -3 & -2 \end{array}\right|} = \dfrac{1}{1} = 1 \end{align*}$$
The unique response (solution) for any input $g(t)$ is given by

$$y(t) = -\left(1 + \displaystyle\int_0^t g(s)e^{3s}\,ds\right)e^{-3t} + \left(1 + \displaystyle\int_0^t g(s)e^{2s}\,ds\right)e^{-2t}.$$

Exercise 2

Find the general solution of the nonhomogeneous equation

$$y'' - 2y' + y = \dfrac{e^t}{1+t^2}$$


View Solution
If we write the differential equation using the differential operator one obtains

$$(d^2 - 2d + 1)[y] = \dfrac{e^t}{1+t^2}$$
Factoring we determine that the characteristic polynomial has repeated roots

$$(d - 1)(d - 1)[y] = \dfrac{e^t}{1+t^2}$$
Letting $v(t) = (d - 1)y(t)$ one gets the 1st-order differential equation
$$\begin{align*} (d-1)[v] &= \dfrac{e^t}{1+t^2} \\ \\ v' - v &= \dfrac{e^t}{1+t^2} \\ \\ \mu(t) &= e^{\int -dt} = e^{-t}\qquad\text{integrating factor} \\ \\ e^{-t}v' - e^{-t}v &= \dfrac{e^t}{1+t^2}e^{-t} \\ \\ \left[\ e^{-t}v\ \right]' &= \dfrac{1}{1+t^2} \\ \\ e^{-t}v &= \displaystyle\int \dfrac{1}{1+t^2}\,dt = \tan^{-1}(t) + c_1 \\ \\ v(t) &= c_1e^t + e^t\tan^{-1}(t) \\ \\ (d - 1)[y] &= c_1e^t + e^t\tan^{-1}(t) \\ \\ y' - y &= c_1e^t + e^t\tan^{-1}(t) \\ \\ e^{-t}y' - e^{-t}y &= c_1 + \tan^{-1}(t)\qquad\text{integrate by parts} \\ \\ e^{-t}y &= c_1t + t\tan^{-1}(t) - \dfrac{1}{2}\log\left(1+t^2\right) + c_2 \\ \\ y(t) &= \left(c_1t + c_2 + t\tan^{-1}(t) - \dfrac{1}{2}\log\left(1+t^2\right)\right)e^t. \\ \end{align*}$$

Exercise 3

Find the general solution of the nonhomogeneous equation

$$ y'' + 4y' + 4y = t^{-2}e^{-2t}. $$

Check Your Work
$$ y(t) = c_1 e^{-2t} + c_2 te^{-2t} - (\ln t)e^{-2t}$$

Video Solution