7.6. Variation of parameters#
Nonhomogeneous ODEs that don’t have constant coefficients or an \(r(x)\) in our table can’t be solved using the method of undetermined coefficients. An alternative for such ODEs is the method of variation of parameters.
For example, consider the ODE
The secant is not in our table of right-hand sides, so we will use variation of parameters to find a particular solution. The homogenous ODE is solved by \(y_1 = \cos x\) and \(y_2 = \sin x\) so
and
Hence,
and
Example: Steady heat diffusion with internal source
We are solving the steady-state heat diffusion equation with an internal source:
where \(\alpha\) is thermal diffusivity, and \(qx \sin x\) is the heat source. The boundary conditions are:
In standard form,
Find homogeneous solution:
(7.144)#\[\begin{align} \alpha T_{\rm h}'' &= 0 \\ \alpha \lambda^2 &= 0 \\ \lambda &= 0 \end{align}\]so,
(7.145)#\[\begin{equation} T_{\rm h} = c_1 + c_2 x \end{equation}\]Find particular solution using variation of parameters:
(7.146)#\[\begin{align} y_1 &= 1, \quad y_2 = x \\ y_1' &= 0, \quad y_2' = 1 \end{align}\]so the Wronskian is \(W = 1 \cdot 1 - 0 \cdot x = 1\). The right-hand side function is
(7.147)#\[\begin{equation} r = -\frac{qx \sin x}{\alpha} \end{equation}\]so the particular solution is:
(7.148)#\[\begin{align} T_{\rm p} &= -1 \int x \left( \frac{-q x \sin x}{\alpha} \right) \, \d{x} + x \int \left( \frac{-q x \sin x}{\alpha} \right) \, \d{x} \\ &= \frac{q}{\alpha} \int x^2 \sin x \, \d{x} - \frac{q}{\alpha} x \int x \sin x \, \d{x} \end{align}\]These integrals can both be evaluated by parts. For the first integral, use the tabular method:
sign
\(u\)
\(\d{v}\)
\(\sin x\)
\(+\)
\(x^2\)
\(-\cos x\)
\(-\)
\(2x\)
\(-\sin x\)
\(+\)
\(2\)
\(\cos x\)
\(0\)
so
(7.149)#\[\begin{equation} \int x^2 \sin x \, \d{x} = -x^2 \cos x + 2x \sin x + 2 \cos x \end{equation}\]For the second integral, use
(7.150)#\[\begin{align} u &= x & \d{v} &= \sin x \d{x} \\ \d{u} &= 1 \d{x} & v &= -\cos{x} \end{align}\]so
(7.151)#\[\begin{equation} \int x \sin x \d{x} = -x \cos x + \int \cos x \d{x} = -x \cos x + \sin x \end{equation}\]Substitute everything back:
(7.152)#\[\begin{align} T_{\rm p} &= \frac{q}{\alpha} \left[ -x^2 \cos x + 2x \sin x + 2 \cos x \right] - \frac{q}{\alpha} x \left[ -x \cos x + \sin x \right] \\ &= \frac{q}{\alpha} [2 \cos x + x \sin x] \end{align}\]Combine and apply boundary conditions.
The general solution is
(7.153)#\[\begin{equation} T = c_1 + c_2 x + \frac{q}{\alpha}(2\cos x + x \sin x) \end{equation}\]The boundary conditions are:
(7.154)#\[\begin{align} T(-1) &= c_1 - c_2 + \frac{q}{\alpha}[2\cos(-1) - \sin(-1)] = 1\\ &= c_1 - c_2 + \frac{q}{\alpha}[2\cos 1 + \sin 1] \\ T(1) &= c_1 + c_2 + \frac{q}{\alpha}[2\cos 1 + \sin 1] = 1 \end{align}\]This is a system of linear equations that can be solved for \(c_1\) and \(c_2\). Subtracting the two equations gives:
(7.155)#\[\begin{equation} 0 = 2 c_2 \end{equation}\]so \(c_2 = 0\). Plugging back in and solving for \(c_1\):
(7.156)#\[\begin{align} 1 &= c_1 + \frac{q}{\alpha}(2\cos 1 + \sin 1) \\ c_1 &= 1 - \frac{q}{\alpha}(2\cos 1 + \sin 1) \end{align}\]
The final result is:
7.6.1. Skill builder problems#
Solve the differential equation
(7.158)#\[\begin{equation} y'' - 4y' + 4y = x^{2} e^{x}, \quad y(0) = 0, \quad y'(0) = 0 \end{equation}\]Solution
Find homogeneous solution \(y_{\rm h}\):
(7.159)#\[\begin{align} y_{\rm h}'' - 4y_{\rm h}' + 4y_{\rm h} &= 0 \\ \lambda^2 - 4\lambda + 4 &= 0 \\ (\lambda -2)^2 &= 0 \end{align}\]so \(\lambda = 2\) is a repeated eigenvalue and
(7.160)#\[\begin{equation} y_{\rm h} = (c_1 + c_2 x) e^{2x} \end{equation}\]Find particular solution \(y_{\rm p}\):
(7.161)#\[\begin{align} y_1 &= e^{2x} &\quad y_2&= x e^{2x} \\ y_1' &= 2 e^{2x} &\quad y_2'&= (1 + 2x) e^{2x} \end{align}\]so the Wronskian is \(W =(1 + 2x) \cdot e^{4x} - 2x \cdot e^{4x} = e^{4x}\). The right-hand side function is
(7.162)#\[\begin{equation} r = x^{2} e^{x} \end{equation}\]so the particular solution is:
(7.163)#\[\begin{align} y_{\rm p} &= -e^{2x} \int \frac{x e^{2x} (x^{2} e^{x})}{e^{4x}} \d{x} + x e^{2x} \int \frac{e^{2x} (x^{2} e^{x})}{e^{4x}} \d{x} \\ &= -e^{2x} \int x^{3} e^{-x} \d{x} + x e^{2x} \int x^{2} e^{-x} \d{x} \end{align}\]These integrals can both be evaluated by parts using the tabular method:
For the first
sign
\(u\)
\(\d{v}\)
\(e^{-x}\)
\(+\)
\(x^3\)
\(-e^{-x}\)
\(-\)
\(3x^2\)
\(e^{-x}\)
\(+\)
\(6x\)
\(-e^{-x}\)
\(-\)
\(6\)
\(e^{-x}\)
\(0\)
so
(7.164)#\[\begin{equation} \int x^3 e^{-x} \d{x} = -x^3 e^{-x} - 3x^2 e^{-x} - 6x e^{-x}- 6 e^{-x} \end{equation}\]For the second
sign
\(u\)
\(\d{v}\)
\(e^{-x}\)
\(+\)
\(x^2\)
\(-e^{-x}\)
\(-\)
\(2x\)
\(e^{-x}\)
\(+\)
\(2\)
\(-e^{-x}\)
\(0\)
so
(7.165)#\[\begin{equation} \int x^2 e^{-x} \d{x} = -x^2 e^{-x} - 2x e^{-x} - 2 e^{-x} \end{equation}\]Substitute everything back:
(7.166)#\[\begin{align} y_{\rm p} &= -e^{2x} \left( -x^3 e^{-x} - 3x^2 e^{-x} - 6x e^{-x} - 6 e^{-x} \right) \\ &\quad + x e^{2x} \left( -x^2 e^{-x} - 2x e^{-x} - 2 e^{-x} \right) \\ &= (x^2 + 4x + 6) e^x \end{align}\]Combine and apply initial conditions:
The general solution and its first derivative are
(7.167)#\[\begin{align} y &= (c_1 + c_2 x) e^{2x}+(x^{2}+4x+6)e^{x} \\ y' &= 2(c_1 + c_2 x) e^{2x} + c_2e^{2x} + (x^{2}+4x+6) e^{x} + (2x+4)e^{x} \end{align}\]Plugging in intial conditions
(7.168)#\[\begin{align} y(0) &= c_1 + 6 = 0 y'(0) &= 2 c_1 + c_2 + 10 = 0 \end{align}\]gives \(c_1 = -6\) and \(c_2 = 2\).
The final solution is:
(7.169)#\[\begin{equation} y = (2 x - 6) e^{2x} + (x^{2}+4x+6)e^{x} \end{equation}\]Solve the differential equation
(7.170)#\[\begin{equation} y'' + y = \csc x, \quad y(\pi/2), \quad y'(\pi/2) = 0 \end{equation}\]Solution
Find homogeneous solution \(y_{\rm h}\):
(7.171)#\[\begin{align} y_{\rm h}' + y_{\rm h} &= 0 \\ \lambda^2 + 1 &= 0 \end{align}\]so \(\lambda_{1,2} = \pm i\) and:
(7.172)#\[\begin{equation} y_{\rm h} = c_1 \cos x + c_2 \sin_x \end{equation}\]Find particular solution \(y_{\rm p}\):
(7.173)#\[\begin{align} y_1 &= \cos x , \quad y_2 = \sin x \\ y_1' &= -\sin x, \quad y_2'= \cos x \end{align}\]so the Wronskian is \(W = \cos^2 x + \sin^2 x = 1\). The right-hand side function is
(7.174)#\[\begin{equation} r = \csc x \end{equation}\]so the particular solution is:
(7.175)#\[\begin{align} y_p &= -\cos x \int \sin x\csc(x) \d{x} + \sin x\int \cos x\csc(x) \d{x} \\ &= -\cos x \int \d{x} + \sin x \int \frac{\cos x}{\sin x} \d{x} \\ &= -x \cos x + \sin x \ln|x| \end{align}\]Combine and apply initial conditions:
The general solution and its first derivative are
(7.176)#\[\begin{align} y &= c_1 \cos x + c_2 \sin x \\ & \quad + \sin x \ln\left| \sin x \right| - x \cos x \\ y' &= -c_1 \sin x + c_2 \cos x \\ & \quad + \cos x (1 + \ln\left| \sin x \right|) + x \sin x - \cos x \end{align}\]Plugging in intial conditions
(7.177)#\[\begin{align} y(\pi/2) &= c_2 = 0\\ y'(\pi/2) &= -c_1 + \pi/2 = 0 \end{align}\]so \(c_1 = \pi/2\) and \(c_2 = 0\).
The final solution is:
(7.178)#\[\begin{equation} y = \frac{\pi}{2} \cos x + \sin x \ln \left| \sin x \right| - x \cos x \end{equation}\]