# Variation of Parameters

Variation of parameters, like the method of undetermined coefficients, is another method for finding the particular solution of an nth-order linear differential equation ${L}{\left({y}\right)}=\phi{\left({x}\right)}$ once the solution to the associated homogeneous equation ${L}{\left({y}\right)}={0}$ is known.

Recall from the linear independence note that if ${y}_{{1}}{\left({x}\right)},\ {y}_{{2}}{\left({x}\right)},\ \ldots,\ {y}_{{n}}{\left({x}\right)}$ are ${n}$ linearly independent solutions of ${L}{\left({y}\right)}={0}$, the general solution of ${L}{\left({y}\right)}={0}$ is ${y}_{{h}}={c}_{{1}}{y}_{{1}}{\left({x}\right)}+{c}_{{2}}{y}_{{2}}{\left({x}\right)}+\ldots+{c}_{{n}}{y}_{{n}}{\left({x}\right)}$.

The variation of parameters method assumes that the particular solution has the form of the homogeneous solution, except that the constants ${c}_{{i}},i={1},{2},\ldots,{n}$ are functions of ${x}$ (that's why it is called variation of parameters): ${y}_{{p}}={c}_{{1}}{\left({x}\right)}{y}_{{1}}{\left({x}\right)}+{c}_{{2}}{\left({x}\right)}{y}_{{2}}{\left({x}\right)}+\ldots+{c}_{{n}}{\left({x}\right)}{y}_{{n}}{\left({x}\right)}$.

We know ${y}_{{i}}{\left({x}\right)},i={1},{2},\ldots,{n}$, but we need to determine ${c}_{{i}}{\left({x}\right)},i={1},{2},\ldots,{n}$.

For this, set up the following system of linear equations:

${\left\{\begin{array}{c}{c}_{{1}}'{y}_{{1}}+{c}_{{2}}'{y}_{{2}}+\ldots+{c}_{{n}}'{y}_{{n}}={0}\\{c}_{{1}}'{y}_{{1}}'+{c}_{{2}}'{y}_{{2}}'+\ldots+{c}_{{n}}'{y}_{{n}}'={0}\\\ldots\\{c}_{{1}}'{{y}_{{1}}^{{{\left({n}-{1}\right)}}}}+{c}_{{2}}'{{y}_{{2}}^{{{\left({n}-{1}\right)}}}}+\ldots+{c}_{{n}}'{{y}_{{n}}^{{{\left({n}-{1}\right)}}}}={0}\\{c}_{{1}}'{{y}_{{1}}^{{{\left({n}\right)}}}}+{c}_{{2}}'{{y}_{{2}}^{{{\left({n}\right)}}}}+\ldots+{c}_{{n}}'{{y}_{{n}}^{{{\left({n}\right)}}}}={0}\\ \end{array}\right.}$

Then, integrate each ${c}_{{i}}'$ to obtain ${c}_{{i}}$, disregarding all constants of integration. This is permissible because we are seeking only one particular solution.

Since ${y}_{{1}}{\left({x}\right)},\ {y}_{{2}}{\left({x}\right)},\ \ldots,\ {y}_{{n}}{\left({x}\right)}$ are ${n}$ linearly independent solutions of the same equation ${L}{\left({y}\right)}={0}$, their Wronskian is not zero. This means that the system has a nonzero determinant and can be solved uniquely for ${c}_{{1}}'{\left({x}\right)},\ {c}_{{2}}'{\left({x}\right)},\ \ldots,\ {c}_{{n}}'{\left({x}\right)}$.

The method of variation of parameters can be applied to all linear differential equations. It is therefore more powerful than the method of undetermined coefficients, which is restricted to linear differential equations with constant coefficients and particular forms of $\phi{\left({x}\right)}$. Nonetheless, in those cases where both methods are applicable, the method of undetermined coefficients is usually the more efficient and, hence, the preferable one.
As a practical matter, the integration of ${v}_{{i}}'{\left({x}\right)}$ may be impossible to perform. In any such case, other methods (in particular, numerical techniques) should be employed.

Example 1. Solve ${y}''-{2}{y}'+{y}=\frac{{{{e}}^{{x}}}}{{x}}$.

The homogeneous solution is ${y}_{{h}}={c}_{{1}}{{e}}^{{{x}}}+{c}_{{2}}{x}{{e}}^{{x}}$.

To find the particular solution, set up the system:

${\left\{\begin{array}{c}{c}_{{1}}'{{e}}^{{x}}+{c}_{{2}}'{x}{{e}}^{{x}}={0}\\{c}_{{1}}'{\left({{e}}^{{x}}\right)}'+{c}_{{2}}'{\left({x}{{e}}^{{x}}\right)}'=\frac{{{{e}}^{{x}}}}{{x}}\\ \end{array}\right.}$,

Or

${\left\{\begin{array}{c}{c}_{{1}}'{{e}}^{{x}}+{c}_{{2}}'{x}{{e}}^{{x}}={0}\\{c}_{{1}}'{{e}}^{{x}}+{c}_{{2}}'{\left({x}{{e}}^{{x}}+{{e}}^{{x}}\right)}=\frac{{{{e}}^{{x}}}}{{x}}\\ \end{array}\right.}$.

Subtract the first equation from the second: ${c}_{{2}}'{{e}}^{{x}}=\frac{{{{e}}^{{x}}}}{{x}}$, or ${c}_{{2}}'=\frac{{1}}{{x}}$.

From the first equation, ${c}_{{1}}'=-{c}_{{2}}'{x}=-\frac{{1}}{{x}}{x}=-{1}$.

So, ${c}_{{2}}=\int\frac{{1}}{{x}}{d}{x}={\ln{{\left({\left|{x}\right|}\right)}}}$, and ${c}_{{1}}=\int-{1}{d}{x}=-{x}$.

Thus, ${y}_{{p}}={c}_{{1}}{{e}}^{{x}}+{{c}}^{{2}}{x}{{e}}^{{x}}=-{x}{{e}}^{{x}}+{\ln{{\left({\left|{x}\right|}\right)}}}{x}{{e}}^{{x}}$.

Finally, the general solution is ${y}={y}_{{h}}+{y}_{{p}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{x}{{e}}^{{x}}-{x}{{e}}^{{x}}+{\ln{{\left({\left|{x}\right|}\right)}}}{x}{{e}}^{{x}}={c}_{{1}}{{e}}^{{x}}+{c}_{{3}}{x}{{e}}^{{x}}+{\ln{{\left({\left|{x}\right|}\right)}}}{x}{{e}}^{{x}}$, where ${c}_{{3}}={c}_{{2}}-{1}$.

Let's work one more example.

Example 2. Solve ${2}{y}''-{3}{y}'+{y}={{e}}^{{x}}$.

The corresponding homogeneous equation is ${2}{y}''-{3}{y}'+{y}={0}$. The characteristic equation is ${2}{{r}}^{{2}}-{3}{r}+{1}={0}$ that has the roots ${r}_{{1}}={1},{r}_{{2}}=\frac{{1}}{{2}}$.

So, ${y}_{{h}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{{e}}^{{\frac{{1}}{{2}}{x}}}$.

Now, be careful when applying the variation of parameters method. To apply it correctly, the coefficient near the highest derivative has to be ${1}$; so, first divide both sides of the differential equation by ${2}$: ${y}''-{1.5}{y}'+{0.5}{y}=\frac{{1}}{{2}}{{e}}^{{x}}$.

Now, set up the system:

${\left\{\begin{array}{c}{c}_{{1}}'{{e}}^{{x}}+{c}_{{2}}'{{e}}^{{\frac{{1}}{{2}}{x}}}={0}\\{c}_{{1}}'{\left({{e}}^{{x}}\right)}'+{c}_{{2}}'{\left({{e}}^{{\frac{{1}}{{2}}{x}}}\right)}'=\frac{{1}}{{2}}{{e}}^{{x}}\\ \end{array}\right.}$,

Or

${\left\{\begin{array}{c}{c}_{{1}}'{{e}}^{{x}}+{c}_{{2}}'{{e}}^{{\frac{{1}}{{2}}{x}}}={0}\\{c}_{{1}}'{{e}}^{{x}}+\frac{{1}}{{2}}{c}_{{2}}'{{e}}^{{\frac{{1}}{{2}}{x}}}=\frac{{1}}{{2}}{{e}}^{{x}}\\ \end{array}\right.}$.

Subtract the first equation from the second: $-\frac{{1}}{{2}}{c}_{{2}}'{{e}}^{{\frac{{1}}{{2}}{x}}}=\frac{{1}}{{2}}{{e}}^{{x}}$ or ${c}_{{2}}=-{{e}}^{{\frac{{1}}{{2}}{x}}}$.

From the first equation, ${c}_{{1}}'=-{c}_{{2}}'{{e}}^{{-\frac{{1}}{{2}}{x}}}=-{\left(-{{e}}^{{\frac{{1}}{{2}}{x}}}\right)}{{e}}^{{-\frac{{1}}{{2}}{x}}}={1}$.

So, ${c}_{{1}}=\int{1}{d}{x}={x}$, and ${c}_{{2}}=\int-{{e}}^{{\frac{{1}}{{2}}{x}}}{d}{x}=-{2}{{e}}^{{\frac{{1}}{{2}}{x}}}$.

Therefore, ${y}_{{p}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{{e}}^{{\frac{{1}}{{2}}{x}}}={x}{{e}}^{{x}}-{2}{{e}}^{{x}}$.

Finally, ${y}={y}_{{h}}+{y}_{{p}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{{e}}^{{\frac{{1}}{{2}}{x}}}+{x}{{e}}^{{x}}-{2}{{e}}^{{x}}={c}_{{3}}{{e}}^{{x}}+{c}_{{2}}{{e}}^{{\frac{{1}}{{2}}{x}}}+{x}{{e}}^{{x}}$, where ${c}_{{3}}={c}_{{1}}-{2}$.

Now, let's consider one final example.

Example 3. Find the general solution of ${y}'''+{y}'=\frac{{1}}{{{\cos{{\left({x}\right)}}}}}$.

The solution of the corresponding homogeneous equation is ${y}_{{h}}={c}_{{1}}+{c}_{{2}}{\cos{{\left({x}\right)}}}+{c}_{{3}}{\sin{{\left({x}\right)}}}$.

To find the particular solution, set up the system:

${\left\{\begin{array}{c}{c}_{{1}}'\cdot{1}+{c}_{{2}}'{\cos{{\left({x}\right)}}}+{c}_{{3}}'{\sin{{\left({x}\right)}}}={0}\\{c}_{{1}}'\cdot{\left({1}\right)}'+{c}_{{2}}'{\left({\cos{{\left({x}\right)}}}\right)}'+{c}_{{3}}'{\left({\sin{{\left({x}\right)}}}\right)}'={0}\\{c}_{{1}}'\cdot{\left({1}\right)}''+{c}_{{2}}'{\left({\cos{{\left({x}\right)}}}\right)}''+{c}_{{3}}'{\left({\sin{{\left({x}\right)}}}\right)}''=\frac{{1}}{{{\cos{{\left({x}\right)}}}}}\\ \end{array}\right.}$,

Or

${\left\{\begin{array}{c}{c}_{{1}}'+{c}_{{2}}'{\cos{{\left({x}\right)}}}+{c}_{{3}}'{\sin{{\left({x}\right)}}}={0}\\-{c}_{{2}}'{\sin{{\left({x}\right)}}}+{c}_{{3}}'{\cos{{\left({x}\right)}}}={0}\\-{c}_{{2}}'{\cos{{\left({x}\right)}}}-{c}_{{3}}'{\sin{{\left({x}\right)}}}=\frac{{1}}{{{\cos{{\left({x}\right)}}}}}\\ \end{array}\right.}$.

Solving this system gives ${c}_{{1}}'=\frac{{1}}{{{\cos{{\left({x}\right)}}}}},\ {c}_{{2}}'=-{1},\ {c}_{{3}}'=-{\tan{{\left({x}\right)}}}$.

So,

${c}_{{1}}=\int\frac{{1}}{{{\cos{{\left({x}\right)}}}}}{d}{x}={\ln{{\left({\left|\frac{{{1}+{\sin{{\left({x}\right)}}}}}{{{\cos{{\left({x}\right)}}}}}\right|}\right)}}}$

${c}_{{2}}=\int-{1}{d}{x}=-{x}$

${c}_{{3}}=\int-{\tan{{\left({x}\right)}}}{d}{x}={\ln{{\left({\left|{\cos{{\left({x}\right)}}}\right|}\right)}}}$.

Thus, ${y}_{{p}}={c}_{{1}}+{c}_{{2}}{\cos{{\left({x}\right)}}}+{c}_{{3}}{\sin{{\left({x}\right)}}}={\ln{{\left({\left|\frac{{{1}+{\sin{{\left({x}\right)}}}}}{{{\cos{{\left({x}\right)}}}}}\right|}\right)}}}-{x}{\cos{{\left({x}\right)}}}+{\ln{{\left({\left|{\cos{{\left({x}\right)}}}\right|}\right)}}}{\sin{{\left({x}\right)}}}$

Finally, the general solution is

${y}={y}_{{h}}+{y}_{{p}}={c}_{{1}}+{c}_{{2}}{\cos{{\left({x}\right)}}}+{c}_{{3}}{\sin{{\left({x}\right)}}}+{\ln{{\left({\left|\frac{{{1}+{\sin{{\left({x}\right)}}}}}{{{\cos{{\left({x}\right)}}}}}\right|}\right)}}}-{x}{\cos{{\left({x}\right)}}}+{\ln{{\left({\left|{\cos{{\left({x}\right)}}}\right|}\right)}}}{\sin{{\left({x}\right)}}}$