Skip to main content
Mathematics LibreTexts

5.6: Variation of Parameters

  • Page ID
    103511
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Caution

    If you have not had Math 410 (linear algebra), then you may want to review Appendix 11.3 again before starting this section.

    In this section we'll discuss the method of variation of parameters to find a particular solution of

    \[\label{eq:5.7.1} P_0(x)y''+P_1(x)y'+P_2(x)y=F(x)\]

    if we know a fundamental set \(\{y_1,y_2\}\) of solutions of the homogeneous equation

    \[\label{eq:5.7.2} P_0(x)y''+P_1(x)y'+P_2(x)y=0.\]

    Having found a particular solution \(y_p\) by this method, we can write the general solution of Equation \ref{eq:5.7.1} as

    \[y=y_p+c_1y_1+c_2y_2. \nonumber \]

    Since we previously only needed solutions of Equation \ref{eq:5.7.2} and annihilation to find the general solution of Equation \ref{eq:5.7.1}, it is natural to ask why we are interested in another method to achieve the same goal. Here’s the answer:

    • We cannot annihilate all types of functions \(F(x)\) that may occur in Equation \ref{eq:5.7.1}.
    • Annihilation is more complicated when we do not have constant coefficients. Note the coefficients in Equation \ref{eq:5.7.1} are not necessarily constants.
    • Variation of parameters generalizes naturally to a method for finding particular solutions of linear systems of equations in Chapter 10, while annihilation doesn’t.
    • Although a detailed discussion of this is beyond the scope of this book, variation of parameters is a powerful theoretical tool used by researchers in differential equations.

    We’ll now derive the method. As usual, we consider solutions of Equation \ref{eq:5.7.1} and Equation \ref{eq:5.7.2} on an interval \((a,b)\) where \(P_0\), \(P_1\), \(P_2\), and \(F\) are continuous and \(P_0\) has no zeros. Suppose that \(\{y_1,y_2\}\) is a fundamental set of solutions of the homogeneous equation Equation \ref{eq:5.7.2}. We use a similar idea to what we did in section 5.2. We look for a particular solution of Equation \ref{eq:5.7.1} in the form

    \[\label{eq:5.7.3} y_p=u_1y_1+u_2y_2\]

    where \(u_1\) and \(u_2\) are functions to be determined so that \(y_p\) satisfies Equation \ref{eq:5.7.1}. You may not think this is a good idea, since there are now two unknown functions to be determined, rather than one like we had in section 5.2. However, since \(u_1\) and \(u_2\) have to satisfy only one condition (that \(y_p\) is a solution of Equation \ref{eq:5.7.1}), we can impose a second condition that produces a convenient simplification, as follows.

    Differentiating Equation \ref{eq:5.7.3} yields

    \[\label{eq:5.7.4} y_p'=u_1y_1'+u_2y_2'+u_1'y_1+u_2'y_2.\]

    As our second condition on \(u_1\) and \(u_2\) we require that

    \[\label{eq:5.7.5} u_1'y_1+u_2'y_2=0.\]

    Then Equation \ref{eq:5.7.4} becomes

    \[y_p'=u_1y_1'+u_2y_2'; \label{eq:5.7.6}\]

    that is, Equation \ref{eq:5.7.5} permits us to differentiate \(y_p\) (once!) as if \(u_1\) and \(u_2\) are constants. Differentiating Equation \ref{eq:5.7.6} yields

    \[\label{eq:5.7.7} y_p''=u_1y''_1+u_2y''_2+u_1'y_1'+u_2'y_2'.\]

    (There are no terms involving \(u_1''\) and \(u_2''\) here, as there would be if we hadn’t required Equation \ref{eq:5.7.5}.) Substituting Equation \ref{eq:5.7.3}, Equation \ref{eq:5.7.6}, and Equation \ref{eq:5.7.7} into Equation \ref{eq:5.7.1} and collecting the coefficients of \(u_1\) and \(u_2\) yields

    \[u_1(P_0y''_1+P_1y_1'+P_2y_1)+u_2(P_0y''_2+P_1y_2'+P_2y_2) +P_0(u_1'y_1'+u_2'y_2')=F. \nonumber \]

    As in the derivation of the method of reduction of order, the coefficients of \(u_1\) and \(u_2\) here are both zero because \(y_1\) and \(y_2\) satisfy the homogeneous equation. Hence, we can rewrite the last equation as

    \[\label{eq:5.7.8} P_0(u_1'y_1'+u_2'y_2')=F.\]

    Therefore \(y_p\) in Equation \ref{eq:5.7.3} satisfies Equation \ref{eq:5.7.1} if

    \[\begin{array}{rcl} u_1'y_1+u_2'y_2 = 0 \\ u_1'y_1'+u_2'y_2' = {F\over P_0}, \end{array}\nonumber\]

    where the first equation is the same as Equation \ref{eq:5.7.5} and the second is from Equation \ref{eq:5.7.8}.

    From Cramer's Rule (covered in linear algebra) you can always solve Equation \ref{eq:5.7.9} for \(u_1'\) and \(u_2'\). To make things a little cleaner we will replace \({F\over P_0}\) with simply \(f(x)\) as we did when using annihilation, and rearrange the factors slightly, giving us:

    \[\label{eq:5.7.9} \begin{array}{rcl} y_1u_1'+y_2u_2' = 0 \\ y_1'u_1'+y_2'u_2' = f(x) \end{array}\]

    Now, letting \[W=\left| \begin{array}{cc} y_1 & y_2 \\ y'_1 & y'_2 \end{array} \right|,\quad W_1=\left| \begin{array}{cc} 0 & y_2 \\ f(x) & y'_2 \end{array} \right|, \quad W_2=\left| \begin{array}{cc} y_1 & 0 \\ y'_1 & f(x) \end{array} \right|,\nonumber \]

    Cramer's rule then says that \[u_1'={W_1\over W}, \quad u_2'={W_2\over W}\nonumber\].

    Since \(\{y_1,y_2\}\) is a fundamental set of solutions of Equation \ref{eq:5.7.2} on \((a,b)\), Theorem 5.1.3 implies that the Wronskian \(W=y_1y_2'-y_1'y_2\) has no zeros on \((a,b)\).

    We can now obtain \(u_1\) and \(u_2\) by integrating \(u_1'\) and \(u_2'\). The constants of integration can be taken to be zero, since any choice of \(u_1\) and \(u_2\) in Equation \ref{eq:5.7.3} will suffice.

    Example 5.6.1

    Find a particular solution \(y_p\) of

    \[\label{eq:5.7.15} x^2y''-2xy'+2y=x^{9/2},\]

    given that \(y_1=x\) and \(y_2=x^2\) are solutions of the complementary equation

    \[x^2y''-2xy'+2y=0. \nonumber \]

    Then find the general solution of Equation \ref{eq:5.7.15}.

    Solution

    Note that we have variable coefficients and a function that cannot be annihilated.

    We set

    \[y_p=u_1x+u_2x^2, \nonumber \]

    where \[\begin{aligned} xu_1'+\phantom{2}x^2u_2'&=0\\ \phantom{x}u_1'+2x\phantom{^2}u_2'&={x^{9/2}\over x^2}=x^{5/2}.\end{aligned}\]

    Now, letting \[W=\left| \begin{array}{cc} x & x^2 \\ 1 & 2x \end{array} \right|=x^2,\quad W_1=\left| \begin{array}{cc} 0 & x^2 \\ x^{5/2} & 2x \end{array} \right|=-x^{9/2}, \quad W_2=\left| \begin{array}{cc} x & 0 \\ 1 & x^{5/2} \end{array} \right|=x^{7/2},\nonumber \]

    So, \(u_1'={W_1\over W}=-x^{5/2}\) and \(u_2'={W_2\over W}=x^{3/2}\). Integrating and taking the constants of integration to be zero yields

    \[u_1=-{2\over7}x^{7/2}\quad \text{and} \quad u_2={2\over5}x^{5/2}. \nonumber \]

    Therefore

    \[y_p=u_1x+u_2x^2 =-{2\over7}x^{7/2}x+{2\over5}x^{5/2}x^2={4\over35}x^{9/2}, \nonumber \]

    and the general solution of Equation \ref{eq:5.7.15} is

    \[y={4\over35}x^{9/2}+c_1x+c_2x^2. \nonumber \]

    Example 5.6.2

    Find a particular solution \(y_p\) of

    \[\label{eq:5.7.16} (x-1)y''-xy'+y=(x-1)^2,\]

    given that \(y_1=x\) and \(y_2=e^x\) are solutions of the homogeneous equation

    \[(x-1)y''-xy'+y=0. \nonumber \]

    Then find the general solution of Equation \ref{eq:5.7.16}.

    Solution

    We set

    \[y_p=u_1x+u_2e^x, \nonumber \]

    where

    \[\begin{aligned} xu_1'+e^xu_2'&=0\\ \phantom{x}u_1'+e^xu_2'&={(x-1)^2\over x-1}=x-1.\end{aligned}\]

    Now, letting \[W=\left| \begin{array}{cc} x & e^x \\ 1 & e^x \end{array} \right|=xe^x-e^x,\quad W_1=\left| \begin{array}{cc} 0 & e^x \\ x-1 & e^x \end{array} \right|=-e^x(x-1), \quad W_2=\left| \begin{array}{cc} x & 0 \\ 1 & x-1 \end{array} \right|=x(x-1),\nonumber \]

    So, \(u_1'={W_1\over W}=-1\) and \(u_2'={W_2\over W}=xe^{-x}\). Integrating and taking the constants of integration to be zero yields

    \[u_1=-x \quad \text{and} \quad u_2=-(x+1)e^{-x}. \nonumber \]

    Therefore

    \[y_p=u_1x+u_2e^x =(-x)x+(-(x+1)e^{-x})e^x=-x^2-x-1, \nonumber \]

    so the general solution of Equation \ref{eq:5.7.16} is

    \[\label{eq:5.7.17} y=y_p+c_1x+c_2e^x=-x^2-x-1+c_1x+c_2e^x = -x^2-1+(c_1-1)x+c_2e^x.\]

    However, since \(c_1\) is an arbitrary constant, so is \(c_1-1\); therefore, we improve the appearance of this result by renaming the constant and writing the general solution as

    \[\label{eq:5.7.18} y= -x^2-1+c_1x+c_2e^x.\]

    Example 5.6.3

    Find a particular solution of

    \[\label{eq:5.7.19} y''+3y'+2y={1\over 1+e^x}.\]

    Then find the general solution.

    Solution

    The characteristic polynomial of the homogeneous equation

    \[\label{eq:5.7.20} y''+3y'+2y=0\]

    is \(r^2+3r+2=(r+1)(r+2)=0\), so \(y_1=e^{-x}\) and \(y_2=e^{-2x}\) form a fundamental set of solutions of Equation \ref{eq:5.7.20}. We look for a particular solution of Equation \ref{eq:5.7.19} in the form

    \[y_p=u_1e^{-x}+u_2e^{-2x}, \nonumber \]

    where

    \[\begin{aligned} \phantom{-}e^{-x}u_1'+\phantom{2}e^{-2x}u_2'&=0\\ -e^{-x}u_1'-2e^{-2x}u_2'&={1\over 1+e^x}.\end{aligned}\]

    Now, letting \[W=\left| \begin{array}{cc} e^{-x} & e^{-2x} \\ -e^{-x} & -2e^{-2x} \end{array} \right|=-e^{-3x},\quad W_1=\left| \begin{array}{cc} 0 & e^{-2x} \\ {1\over 1+e^x} & -2e^{-2x} \end{array} \right|={-e^{-2x}\over 1+e^x}, \quad W_2=\left| \begin{array}{cc} e^{-x} & 0 \\ -e^{-x} & {1\over 1+e^x} \end{array} \right|={e^{-x}\over 1+e^x},\nonumber \]

    So, \(u_1'={W_1\over W}={e^x\over e^x+1}\) and \(u_2'={W_2\over W}={-e^{2x}\over e^x+1}\).

    Integrating by means of the substitution \(v=e^x\) and taking the constants of integration to be zero yields

    \[u_1=\int{e^x\over 1+e^x}\,dx=\int {dv\over 1+v} =\ln(1+v)=\ln(1+e^x) \nonumber \]

    and

    \[\begin{aligned} u_2&=-\int{e^{2x}\over 1+e^x}\,dx=-\int {v\over 1+v}\,dv =\int\left[{1\over 1+v}-1\right]\,dv \\ &=\ln(1+v)-v=\ln(1+e^x)-e^x.\end{aligned}\]

    Therefore

    \[\begin{aligned} y_p&=u_1e^{-x}+u_2e^{-2x}\\ &=[\ln(1+e^x)]e^{-x}+\left[\ln(1+e^x)-e^x\right]e^{-2x},\end{aligned}\]

    so

    \[y_p=\left(e^{-x}+e^{-2x}\right)\ln(1+e^x)-e^{-x}. \nonumber \]

    Since the last term on the right satisfies the homogeneous equation, we drop it and redefine

    \[y_p=\left(e^{-x}+e^{-2x}\right)\ln(1+e^x). \nonumber \]

    The general solution of Equation \ref{eq:5.7.19} is

    \[y=y_p+c_1e^{-x}+c_2e^{-2x}=\left(e^{-x}+e^{-2x}\right)\ln(1+e^x) +c_1e^{-x}+c_2e^{-2x}. \nonumber \]

    Example 5.6.4

    Solve the initial value problem

    \[\label{eq:5.7.21} (x^2-1)y''+4xy'+2y={2\over x+1}, \quad y(0)=-1,\quad y'(0)=-5,\]

    given that

    \[y_1={1\over x-1}\quad\mbox{ and }\quad y_2={1\over x+1} \nonumber \]

    are solutions of the homogeneous equation

    \[(x^2-1)y''+4xy'+2y=0. \nonumber \]

    Solution

    We first use variation of parameters to find a particular solution of

    \[(x^2-1)y''+4xy'+2y={2\over x+1} \nonumber \]

    on \((-1,1)\) in the form

    \[y_p={u_1\over x-1}+{u_2\over x+1}, \nonumber \]

    where

    \[\label{eq:5.7.22}\frac{u_{1}'}{x-1}+\frac{u_{2}'}{x+1}=0\]

    \[-\frac{u_{1}'}{(x-1)^{2}}-\frac{u_{2}'}{(x+1)^{2}}=\frac{2}{(x+1)(x^{2}-1)}=\frac{2}{(x+1)^2(x-1)}\nonumber\]

    Now, letting \[W=\left| \begin{array}{cc} {1\over x-1} & {1\over x+1} \\ {-1\over (x-1)^2} & {-1\over (x+1)^2} \end{array} \right|={2\over (x+1)^2(x-1)^2},\quad W_1=\left| \begin{array}{cc} 0 & {1\over x+1} \\ {2\over (x+1)^2(x-1)} & {-1\over (x+1)^2} \end{array} \right|={-2\over (x+1)^3(x-1)}, \quad W_2=\left| \begin{array}{cc} {1\over x-1} & 0 \\ {-1\over (x-1)^2} & {2\over (x+1)^2(x-1)} \end{array} \right|={2\over (x+1)^2(x-1)^2}.\nonumber \]

    So, \(u_1'={W_1\over W}=-{x-1\over x+1}\) and \(u_2'={W_2\over W}=1\).

    Integrating and taking the constants of integration to be zero yields

    \[\begin{aligned} u_1&=-\int{x-1\over x+1}\,dx=-\int{x+1-2\over x+1}\,dx \\ &=\int\left[{2\over x+1}-1\right]\,dx=2\ln(x+1)-x\end{aligned}\]

    and

    \[u_2=\int\,dx=x. \nonumber \]

    Therefore

    \[\begin{aligned} y_p&={u_1\over x-1}+{u_2\over x+1}=\left[2\ln(x+1)-x\right]{1\over x-1} +x{1\over x+1} \\ &={2\ln(x+1)\over x-1}+x\left[{1\over x+1}-{1\over x-1}\right] ={2\ln(x+1)\over x-1}-{2x\over(x+1)(x-1)}.\end{aligned}\]

    However, since

    \[{2x\over(x+1)(x-1)}=\left[{1\over x+1}+{1\over x-1}\right] \nonumber \]

    is a solution of the homogeneous equation, we redefine

    \[y_p={2\ln(x+1)\over x-1}. \nonumber \]

    Therefore the general solution of Equation \ref{eq:5.7.24} is

    \[\label{eq:5.7.24} y={2\ln(x+1)\over x-1}+{c_1\over x-1}+{c_2\over x+1}.\]

    Differentiating this yields

    \[y'={2\over x^2-1}-{2\ln(x+1)\over(x-1)^2}-{c_1\over(x-1)^2}-{c_2\over(x+1)^2}. \nonumber \]

    Setting \(x=0\) in the last two equations and imposing the initial conditions \(y(0)=-1\) and \(y'(0)=-5\) yields the system

    \[\begin{aligned} -c_1+c_2&=-1\phantom{.}\\ -2-c_1-c_2&=-5.\end{aligned}\]

    The solution of this system is \(c_1=2,\,c_2=1\). Substituting these into Equation \ref{eq:5.7.24} yields

    \[\begin{aligned} y&={2\ln(x+1)\over x-1}+{2\over x-1}+{1\over x+1}\\ &={2\ln(x+1)\over x-1}+{3x+1\over x^2-1}\end{aligned}\]

    as the solution of Equation \ref{eq:5.7.21}. Figure 5.6.1 is a graph of the solution.

    clipboard_efe3876d19d189750d71c754779bdc01f.png
    Figure 5.6.1 : \(y=\frac{2\ln (x+1)}{x-1}+\frac{3x+1}{x^{2}-1}\)

    We’ve now considered two methods for solving nonhomogeneous linear equations: annihilation and variation of parameters. It’s natural to ask which method is best for a given problem. The method of annihilation should be used for constant coefficient equations with forcing functions that are linear combinations of polynomials multiplied by functions of the form \(e^{\alpha x}\), \(e^{\lambda x}\cos \omega x\), or \(e^{\lambda x}\sin \omega x\). Although variation of parameters can be used to solve such problems, it will be more difficult except in the most trivial cases, because of the integrations involved.

    If the equation isn’t a constant coefficient equation or the forcing function isn’t of the form just specified, the method of annihilation does not apply and the choice is necessarily variation of parameters.

    Using the Principle of Superposition

    The next example shows how to combine the method of annihilation and variation of parameters, along with Theorem 5.4.3, the principle of superposition.

    Example \(\PageIndex{5}\)

    Find the general solution of

    \[\label{eq:5.7.25} y''-2y'+y=4x^2-3+{e^x\over x}\] on \((0,\infty)\).

    Solution

    Solving the homogeneous equation \(y''-2y'+y=0\), we get the characteristic equation \((r-1)^2=0\) which gives us

    \[y_h=c_1e^x+c_2xe^x\nonumber\]

    Now, when we turn to \ref{eq:5.7.25} it might appear that we must use variation of parameters to solve it because we cannot annihilate the entire right hand side of \ref{eq:5.7.25}. However, we can annihilate the first two terms and use variation for the last term, and then use the principle of superposition to find \(y_p\).

    Let's first consider \[\label{eq:5.7.26} y''-2y'+y=4x^2-3.\]

    Writing it as \[(D-1)^2y=4x^2-3\nonumber\] and using \(D^3\) to annihilate the right hand side we get

    \[D^3(D-1)^2y=0\nonumber\] which gives us a characteristic equation of \(r^3(r-1)^2=0\) and roots \(0,0,0,1,1\). We have used \(1,1\) so that gives us

    \[ y_{p_1} =A+Bx+Cx^2\nonumber\]

    which gives us \(y_{p_1}' =B+2Cx\) and \(y_{p_1}''=2C\). Substituting into \ref{eq:5.7.26} gives us

    \[2C-2(B+2Cx)+(A+Bx+Cx^2)=4x^2-3\nonumber\] which gives us \(A=21, B=16, C=4\) and therefore

    \[ y_{p_1}=21+16x+4x^2\nonumber\] is the solution to \ref{eq:5.7.26}.

    Let's now consider \[\label{eq:5.7.27} y''-2y'+y={e^x\over x}.\]

    Here we are forced to use variation of parameters with

    \[W=\left| \begin{array}{cc} e^x & xe^x \\ e^x & xe^x+e^x \end{array} \right|=e^{2x},\quad W_1=\left| \begin{array}{cc} 0 & xe^x \\ {e^x\over x} & xe^x+e^x \end{array} \right|=-e^{2x}, \quad W_2=\left| \begin{array}{cc} e^x & 0 \\ e^x &{e^x\over x} \end{array} \right|={e^{2x}\over x},\nonumber \]

    So, \(u_1'={W_1\over W}=-1\) and \(u_2'={W_2\over W}={1\over x}\). Integrating and taking the constants of integration to be zero yields

    \[u_1=-x\quad \text{and} \quad u_2=\ln x. \nonumber \]

    Therefore,

    \[y_{p_2}=u_1x+u_2x^2 =-xe^x+xe^x\ln x, \nonumber \] is the solution to \ref{eq:5.7.27}.

    Putting \(y_{p_1}\) and \(y_{p_2}\) together we get \[y_p=y_{p_1}+y_{p_2}=21+16x+4x^2-xe^x+xe^x\ln x.\nonumber\]

    The term \(-xe^x\) can be absorbed into \(y_h\), so the general solution of Equation \ref{eq:5.7.25} is

    \[y=c_1e^x+c_2xe^x+21+16x+4x^2+xe^x\ln x. \nonumber \]


    This page titled 5.6: Variation of Parameters is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by William F. Trench via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.