To complete the picture we must also consider the nonhomogeneous equations with variable coefficients. Equations of this type can be written as

\[{{y^{\left( n \right)}} + {a_1}\left( x \right){y^{\left( {n – 1} \right)}} + \cdots }+{ {a_{n – 1}}\left( x \right)y’ }+{ {a_n}\left( x \right)y }={ f\left( x \right),}\]

where the coefficients \({a_1}\left( x \right), \ldots ,{a_n}\left( x \right)\) and the right-hand side \(f\left( x \right)\) are continuous functions on some interval \(\left[ {a,b} \right].\)

With the help of a linear differential operator \(L\) this equation can be written in compact form:

\[Ly\left( x \right) = f\left( x \right),\]

where \(L\) includes the operations of differentiation, multiplication by the coefficients \({a_i}\left( x \right),\) and addition.

As it is known, the general solution \(y\left( x \right)\) of a nonhomogeneous differential equation is the sum of the general solution \({y_0}\left( x \right)\) of the corresponding homogeneous equation and a particular solution \({y_1}\left( x \right)\) of the nonhomogeneous equation:

\[y\left( x \right) = {y_0}\left( x \right) + {y_1}\left( x \right).\]

Methods of finding the general solution of the homogeneous equation are considered here. Therefore, we focus our attention on constructing solutions of the nonhomogeneous equations.

The method of variation of constants also known as the Lagrange method is commonly used for this purpose. With this method, we can obtain the general solution of the nonhomogeneous equation, if the general solution of the homogeneous equation is known.

### Method of Variation of Constants

Suppose we want to solve an \(n\)th order nonhomogeneous differential equation:

\[{{y^{\left( n \right)}} + {a_1}\left( x \right){y^{\left( {n – 1} \right)}} + \cdots }+{ {a_{n – 1}}\left( x \right)y’ }+{ {a_n}\left( x \right)y }={ f\left( x \right).}\]

We will assume that the general solution of the associated homogeneous equation is found and expressed by the formula

\[{{y_0}\left( x \right) = {C_1}{Y_1}\left( x \right) }+{ {C_2}{Y_2}\left( x \right) + \cdots }+{ {C_n}{Y_n}\left( x \right),}\]

containing \(n\) arbitrary constants \({C_1},\) \({C_2}, \ldots ,\) \({C_n}.\)

The idea of this method is to replace the constants \({C_1},\) \({C_2}, \ldots ,\) \({C_n}\) with continuously differentiable functions \({C_1}\left( x \right),\) \({C_2}\left( x \right), \ldots ,\) \({C_n}\left( x \right),\) which are chosen so that the solution

\[ {y\left( x \right) }={ {C_1}\left( x \right){Y_1}\left( x \right) }+{ {C_2}\left( x \right){Y_2}\left( x \right) + \cdots } + {{C_n}\left( x \right){Y_n}\left( x \right) } = {\sum\limits_{i = 1}^n {{C_i}\left( x \right){Y_i}\left( x \right)} } \]

satisfies the nonhomogeneous differential equation.

The first derivatives of the functions \({{C_i}\left( x \right)}\) are determined from the system of \(n\) equations of the form

\[\left\{ \begin{array}{l} {{C’_1}\left( x \right){Y_1}\left( x \right) }+{ {C’_2}\left( x \right){Y_2}\left( x \right) + \cdots }+{ {C’_n}\left( x \right){Y_n}\left( x \right) }={ 0}\\ {{C’_1}\left( x \right){Y’_1}\left( x \right) }+{ {C’_2}\left( x \right){Y’_2}\left( x \right) + \cdots }+{ {C’_n}\left( x \right){Y’_n}\left( x \right) }={ 0}\\ \cdots \cdots \cdots \cdots \cdots \cdots \cdots \\ {{C’_1}\left( x \right)Y_1^{\left( {n – 1} \right)}\left( x \right) }+{ {C’_2}\left( x \right)Y_2^{\left( {n – 1} \right)}\left( x \right) + \cdots }+{ {C’_n}\left( x \right)Y_n^{\left( {n – 1} \right)}\left( x \right) }={ f\left( x \right)} \end{array} \right.\]

Note that the main determinant of this system is the Wronskian \(W\left( x \right)\) constructed on the basis of the fundamental system of solutions \({Y_1},\) \({Y_2}, \ldots ,\) \({Y_n}.\) As the solutions \({Y_1},\) \({Y_2}, \ldots ,\) \({Y_n}\) are linearly independent, the Wronskian is not zero.

The unknown derivatives \({C’_i}\left( x \right)\) are calculated by Cramer’s rule:

\[{{C’_i}\left( x \right) = \frac{{{W_i}\left( x \right)}}{{W\left( x \right)}},\;\;}\kern-0.3pt{i = 1,2, \ldots ,n,}\]

where the determinant \({{W_i}\left( x \right)}\) is obtained from the Wronskian \(W\left( x \right)\) by replacing the \(i\)th column with the column \(\left[ {0,0, \ldots, f\left( x \right)} \right]\) on the right side.

Further, the expressions for \({C_i}\left( x \right)\) can be found by integration:

\[

{{C_i}\left( x \right) }={ \int {\frac{{{W_i}\left( x \right)}}{{W\left( x \right)}}dx} + {A_i},\;\;}\kern-0.3pt

{i = 1,2, \ldots ,n.}

\]

Here \({A_i}\) denote constants of integration.

As a result, the general solution of the nonhomogeneous equation can be written as

\[ {y\left( x \right) }={ \sum\limits_{i = 1}^n {{C_i}\left( x \right){Y_i}\left( x \right)} } = {\sum\limits_{i = 1}^n {\left( {\int {\frac{{{W_i}\left( x \right)}}{{W\left( x \right)}}dx} + {A_i}} \right){Y_i}\left( x \right)} } = {\sum\limits_{i = 1}^n {{A_i}{Y_i}\left( x \right)} } + {\sum\limits_{i = 1}^n {\left( {\int {\frac{{{W_i}\left( x \right)}}{{W\left( x \right)}}dx} } \right){Y_i}\left( x \right)} } = {{y_0}\left( x \right) + {y_1}\left( x \right).} \]

In the last expression, the first sum corresponds to the general solution \({y_0}\left( x \right)\) of the homogeneous equation (with arbitrary numbers \({A_i}\)), and the second sum describes a particular solution \({y_1}\left( x \right)\) of the nonhomogeneous equation.

## Solved Problems

Click a problem to see the solution.