DiffEq Home

Variation of Parameters

    


Consider the linear nonhomogeneous second order ODE \[y''+p(x)y'+q(x)y=g(x), \;\;\;\;(40)\] where \(p(x),\;q(x)\), and \(g(x)\) are continuous functions. Note that if \(g(x)\) is not exponential, polynomial, sine or cosine functions, then the method of undetermined coefficients does not work. We will use a general method called variation of parameters} to find a particular solution of (40).

Theorem. Suppose \(y_1\) and \(y_2\) are fundamental solutions of the corresponding homogeneous ODE of (40). Then a particular solution \(y_p\) of (40) is \[y_p=-y_1\int\frac{y_2g}{W(y_1,y_2)}\, dx+y_2\int\frac{y_1g}{W(y_1,y_2)}\, dx.\]

The homogeneous solution of the corresponding homogeneous ODE of (40) is \[y=c_1y_1+c_2y_2.\] Suppose \(c_1=u(x)\) and \(c_2=v(x)\) are functions of \(x\) to find a particular solution \(y_p\) of (40). Then we have \[\begin{align*} y_p&=uy_1+vy_2\\ y_p'&=uy_1'+u'y_1+vy_2'+v'y_2. \end{align*}\] We choose \(u\) and \(v\) such that \[u'y_1+v'y_2=0. \;\;\;\;(41)\] Then \[\begin{align*} y_p'&=uy_1'+vy_2'\\ y_p''&=uy_1''+u'y_1'+vy_2''+v'y_2'. \end{align*}\] Since \(y_p\) is particular solution of (40), we have \[\begin{align} y_p''+py_p'+qy_p&=g \nonumber\\ (uy_1''+u'y_1'+vy_2''+v'y_2')+p(uy_1'+vy_2')+q(uy_1+vy_2)&=g \nonumber\\ u(y_1''+py_1'+qy_1)+v(y_2''+py_2'+qy_2)+u'y_1'+v'y_2' &=g \nonumber\\ u'y_1'+v'y_2' &=g \;\;\;\;(42) \end{align}\] Solving for \(u'\) and \(v'\) from (41) and (42), we get \[\begin{align*} u'&=\frac{-y_2g}{y_1y_2'-y_2y_1'}=\frac{-y_2g}{W(y_1,y_2)}\\ v'&=\frac{y_1g}{y_1y_2'-y_2y_1'}=\frac{y_1g}{W(y_1,y_2)}. \end{align*}\] Then \(u=\displaystyle\int\frac{-y_2g}{W(y_1,y_2)}\, dx\) and \(v=\displaystyle\int\frac{y_1g}{W(y_1,y_2)}\, dx\). Thus a particular solution is \[y_p=-y_1\int\frac{y_2g}{W(y_1,y_2)}\, dx+y_2\int\frac{y_1g}{W(y_1,y_2)}\, dx. \;\blacksquare\]

Example. Find the general solution of \(xy''-(x+1)y'+y=x^2e^x\).
You may use the fact that \(y_1=x+1\) and \(y_2=e^x\) are fundamental solutions of the corresponding homogeneous ODE.

Solution. Let's first put it in the standard form for variation of parameters: \[y''-\left(1+\frac{1}{x}\right)y'+\frac{y}{x}=xe^x.\] The homogeneous solution is \(y_h=c_1(x+1)+c_2e^x\). \[W(y_1,y_2)=\,\begin{array}{|cc|}x+1& e^x\\1& e^x\end{array}=(x+1)e^x-e^x=xe^x.\] By variation of parameters a particular solution is \[\begin{align*} y_p&=-y_1\int\frac{y_2g}{W(y_1,y_2)}\, dx+y_2\int\frac{y_1g}{W(y_1,y_2)}\, dx\\ &=-(x+1)\int\frac{e^xxe^x}{xe^x}\, dx+e^x\int\frac{(x+1)xe^x}{xe^x}\, dx\\ &=-(x+1)\int e^x\, dx+e^x\int (x+1)\, dx\\ &=-(x+1)e^x+e^x\left(\frac{x^2}{2}+x\right)\\ &=e^x \left(\frac{x^2}{2}-1\right). \end{align*}\] Thus the general solution is \[y=c_1(x+1)+c_2e^x+e^x \left(\frac{x^2}{2}-1\right).\]
Example. Find the general solution of \(y''+y=\tan x\).

Solution. The characteristic equation is \(r^2+1=0\implies r=\pm i\).
The homogeneous solution is \(y_h=c_1\cos x+c_2\sin x\). \[W(y_1,y_2)=\,\begin{array}{|cc|}\cos x& \sin x\\-\sin x& \cos x\end{array}=\cos^2x+\sin^2 x=1.\] By variation of parameters a particular solution is \[\begin{align*} y_p&=-y_1\int\frac{y_2g}{W(y_1,y_2)}\, dx+y_2\int\frac{y_1g}{W(y_1,y_2)}\, dx\\ &=-\cos x\int\frac{\sin x \tan x}{1}\, dx+\sin x\int\frac{\cos x \tan x}{1}\, dx\\ &=-\cos x\int\frac{\sin^2x}{\cos x}\, dx+\sin x\int\sin x\, dx\\ &=-\cos x\int\frac{1-\cos^2x}{\cos x}\, dx+\sin x(-\cos x)\\ &=-\cos x\int\left(\sec x-\cos x\right)\, dx-\sin x\cos x\\ &=-\cos x\left(\ln|\sec x+\tan x|-\sin x\right)-\sin x\cos x\\ &=-\cos x\ln|\sec x+\tan x|. \end{align*}\] Thus the general solution is \[y=c_1\cos x+c_2\sin x-\cos x\ln|\sec x+\tan x|.\]


Last edited