7.6 Variation of parameters
Nonhomogeneous ODEs that don’t have constant coefficients or an r ( x ) r(x) 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.
Variation of parameters
For a nonhomogeneous linear second-order ODE y ′ ′ + p ( x ) y ′ + q ( x ) y = r ( x ) y'' + p(x)y' + q(x)y = r(x) y ′′ + p ( x ) y ′ + q ( x ) y = r ( x ) ,
if y h = c 1 y 1 + c 2 y 2 y_{\rm h} = c_1 y_1 + c_2 y_2 y h = c 1 y 1 + c 2 y 2 solves the corresponding homogenous ODE
y h ′ ′ + p ( x ) y h ′ + q ( x ) y h = 0 y_{\rm h}'' + p(x) y_{\rm h}' + q(x) y_{\rm h} = 0 y h ′′ + p ( x ) y h ′ + q ( x ) y h = 0 , then the particular
solution y p y_{\rm p} y p is:
y p = − y 1 ∫ y 2 r W d x + y 2 ∫ y 1 r W d x y_{\rm p} = -y_1 \int\frac{y_2 r}{W} \d{x} + y_2 \int \frac{y_1 r}{W} \d{x} y p = − y 1 ∫ W y 2 r d x + y 2 ∫ W y 1 r d x where
W = ∣ y 1 y 2 y 1 ′ y 2 ′ ∣ = y 1 y 2 ′ − y 2 y 1 ′ W = \begin{vmatrix}y_1 & y_2 \\y_1' & y_2'\end{vmatrix} = y_1 y_2' - y_2 y_1' W = ∣ ∣ y 1 y 1 ′ y 2 y 2 ′ ∣ ∣ = y 1 y 2 ′ − y 2 y 1 ′ is the Wronksi determinant (or “Wronskian”).
For example, consider the ODE
y ′ ′ + y = sec x y'' + y = \sec x y ′′ + y = sec x 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 y_1 = \cos x y 1 = cos x and y 2 = sin x y_2 = \sin x y 2 = sin x so
y 1 = cos x y 2 = sin x y 1 ′ = − sin x y 2 ′ = cos x \begin{align}
y_1 &= \cos x & y_2 &= \sin x \\
y_1' &= -\sin x & y_2' &= \cos x
\end{align} y 1 y 1 ′ = cos x = − sin x y 2 y 2 ′ = sin x = cos x and
W = cos 2 x − ( − sin 2 x ) = 1 W = \cos^2 x - (-\sin^2 x) = 1 W = cos 2 x − ( − sin 2 x ) = 1 Hence,
y p = − cos x ∫ sin x sec x d x + sin x ∫ cos x sec x d x = cos x ∫ − sin x cos x d x + sin x ∫ d x = cos x ln ∣ cos x ∣ + x sin x \begin{align}
y_{\rm p} &= -\cos x\int\sin x\sec x\d{x} +\sin x\int\cos x\sec x\d{x} \\
&= \cos x\int \frac{-\sin x}{\cos x}\d{x} + \sin x \int \d{x} \\
&= \cos x\ln|\cos x| + x\sin x
\end{align} y p = − cos x ∫ sin x sec x d x + sin x ∫ cos x sec x d x = cos x ∫ cos x − sin x d x + sin x ∫ d x = cos x ln ∣ cos x ∣ + x sin x and
y = c 1 cos x + c 2 sin x + cos x ln ∣ cos x ∣ + x sin x y = c_1 \cos x + c_2 \sin x + \cos x\ln|\cos x| + x\sin x y = c 1 cos x + c 2 sin x + cos x ln ∣ cos x ∣ + x sin x Example: Steady heat diffusion with internal source ¶ We are solving the steady-state heat diffusion equation with an internal source:
α d 2 T d x 2 + q x sin x = 0 \alpha \dd{2}{T}{x} + qx \sin x = 0 α d x 2 d 2 T + q x sin x = 0 where α \alpha α is thermal diffusivity, and q x sin x qx \sin x q x sin x is the heat source. The
boundary conditions are:
T ( − 1 ) = T ( 1 ) = 1 T(-1) = T(1) = 1 T ( − 1 ) = T ( 1 ) = 1 In standard form,
T ′ ′ = − q x sin x T'' = -q x \sin x T ′′ = − q x sin x Find homogeneous solution:
α T h ′ ′ = 0 α λ 2 = 0 λ = 0 \begin{align}
\alpha T_{\rm h}'' &= 0 \\
\alpha \lambda^2 &= 0 \\
\lambda &= 0
\end{align} α T h ′′ α λ 2 λ = 0 = 0 = 0 so,
T h = c 1 + c 2 x T_{\rm h} = c_1 + c_2 x T h = c 1 + c 2 x Find particular solution using variation of parameters:
y 1 = 1 , y 2 = x y 1 ′ = 0 , y 2 ′ = 1 \begin{align}
y_1 &= 1, \quad y_2 = x \\
y_1' &= 0, \quad y_2' = 1
\end{align} y 1 y 1 ′ = 1 , y 2 = x = 0 , y 2 ′ = 1 so the Wronskian is W = 1 ⋅ 1 − 0 ⋅ x = 1 W = 1 \cdot 1 - 0 \cdot x = 1 W = 1 ⋅ 1 − 0 ⋅ x = 1 . The right-hand side
function is
r = − q x sin x α r = -\frac{qx \sin x}{\alpha} r = − α q x sin x so the particular solution is:
T p = − 1 ∫ x ( − q x sin x α ) d x + x ∫ ( − q x sin x α ) d x = q α ∫ x 2 sin x d x − q α x ∫ x sin x d x \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} T p = − 1 ∫ x ( α − q x sin x ) d x + x ∫ ( α − q x sin x ) d x = α q ∫ x 2 sin x d x − α q x ∫ x sin x d x These integrals can both be evaluated by parts. For the first integral,
use the tabular method:
sign u u u d v \d{v} d v sin x \sin x sin x + + + x 2 x^2 x 2 − cos x -\cos x − cos x − - − 2 x 2x 2 x − sin x -\sin x − sin x + + + 2 cos x \cos x cos x 0
so
∫ x 2 sin x d x = − x 2 cos x + 2 x sin x + 2 cos x \int x^2 \sin x \, \d{x} = -x^2 \cos x + 2x \sin x + 2 \cos x ∫ x 2 sin x d x = − x 2 cos x + 2 x sin x + 2 cos x For the second integral, use
u = x d v = sin x d x d u = 1 d x v = − cos x \begin{align}
u &= x & \d{v} &= \sin x \d{x} \\
\d{u} &= 1 \d{x} & v &= -\cos{x}
\end{align} u d u = x = 1 d x d v v = sin x d x = − cos x so
∫ x sin x d x = − x cos x + ∫ cos x d x = − x cos x + sin x \int x \sin x \d{x} = -x \cos x + \int \cos x \d{x} = -x \cos x + \sin x ∫ x sin x d x = − x cos x + ∫ cos x d x = − x cos x + sin x Substitute everything back:
T p = q α [ − x 2 cos x + 2 x sin x + 2 cos x ] − q α x [ − x cos x + sin x ] = q α [ 2 cos x + x sin x ] \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} T p = α q [ − x 2 cos x + 2 x sin x + 2 cos x ] − α q x [ − x cos x + sin x ] = α q [ 2 cos x + x sin x ] Combine and apply boundary conditions.
The general solution is
T = c 1 + c 2 x + q α ( 2 cos x + x sin x ) T = c_1 + c_2 x + \frac{q}{\alpha}(2\cos x + x \sin x) T = c 1 + c 2 x + α q ( 2 cos x + x sin x ) The boundary conditions are:
T ( − 1 ) = c 1 − c 2 + q α [ 2 cos ( − 1 ) − sin ( − 1 ) ] = 1 = c 1 − c 2 + q α [ 2 cos 1 + sin 1 ] T ( 1 ) = c 1 + c 2 + q α [ 2 cos 1 + sin 1 ] = 1 \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} T ( − 1 ) T ( 1 ) = c 1 − c 2 + α q [ 2 cos ( − 1 ) − sin ( − 1 )] = 1 = c 1 − c 2 + α q [ 2 cos 1 + sin 1 ] = c 1 + c 2 + α q [ 2 cos 1 + sin 1 ] = 1 This is a system of linear equations that can be solved for c 1 c_1 c 1 and c 2 c_2 c 2 .
Subtracting the two equations gives:
so c 2 = 0 c_2 = 0 c 2 = 0 . Plugging back in and solving for c 1 c_1 c 1 :
1 = c 1 + q α ( 2 cos 1 + sin 1 ) c 1 = 1 − q α ( 2 cos 1 + sin 1 ) \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} 1 c 1 = c 1 + α q ( 2 cos 1 + sin 1 ) = 1 − α q ( 2 cos 1 + sin 1 ) The final result is:
T = 1 + q α [ 2 ( cos x − cos 1 ) + x sin x − sin 1 ] T = 1 + \frac{q}{\alpha}\left[2(\cos x - \cos 1) + x \sin x - \sin 1\right] T = 1 + α q [ 2 ( cos x − cos 1 ) + x sin x − sin 1 ] Skill builder problems ¶ Solve:
y ′ ′ − 4 y ′ + 4 y = x 2 e x , y ( 0 ) = 0 , y ′ ( 0 ) = 0 y'' - 4y' + 4y = x^{2} e^{x}, \quad y(0) = 0, \quad y'(0) = 0 y ′′ − 4 y ′ + 4 y = x 2 e x , y ( 0 ) = 0 , y ′ ( 0 ) = 0 Find homogeneous solution y h y_{\rm h} y h :
y h ′ ′ − 4 y h ′ + 4 y h = 0 λ 2 − 4 λ + 4 = 0 ( λ − 2 ) 2 = 0 \begin{align}
y_{\rm h}'' - 4y_{\rm h}' + 4y_{\rm h} &= 0 \\
\lambda^2 - 4\lambda + 4 &= 0 \\
(\lambda -2)^2 &= 0
\end{align} y h ′′ − 4 y h ′ + 4 y h λ 2 − 4 λ + 4 ( λ − 2 ) 2 = 0 = 0 = 0 so λ = 2 \lambda = 2 λ = 2 is a repeated eigenvalue and
y h = ( c 1 + c 2 x ) e 2 x y_{\rm h} = (c_1 + c_2 x) e^{2x} y h = ( c 1 + c 2 x ) e 2 x Find particular solution y p y_{\rm p} y p :
y 1 = e 2 x y 2 = x e 2 x y 1 ′ = 2 e 2 x y 2 ′ = ( 1 + 2 x ) e 2 x \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} y 1 y 1 ′ = e 2 x = 2 e 2 x y 2 y 2 ′ = x e 2 x = ( 1 + 2 x ) e 2 x so the Wronskian is W = ( 1 + 2 x ) ⋅ e 4 x − 2 x ⋅ e 4 x = e 4 x W =(1 + 2x) \cdot e^{4x} - 2x \cdot e^{4x} = e^{4x} W = ( 1 + 2 x ) ⋅ e 4 x − 2 x ⋅ e 4 x = e 4 x .
The right-hand side function is
r = x 2 e x r = x^{2} e^{x} r = x 2 e x so the particular solution is:
y p = − e 2 x ∫ x e 2 x ( x 2 e x ) e 4 x d x + x e 2 x ∫ e 2 x ( x 2 e x ) e 4 x d x = − e 2 x ∫ x 3 e − x d x + x e 2 x ∫ x 2 e − x d x \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} y p = − e 2 x ∫ e 4 x x e 2 x ( x 2 e x ) d x + x e 2 x ∫ e 4 x e 2 x ( x 2 e x ) d x = − e 2 x ∫ x 3 e − x d x + x e 2 x ∫ x 2 e − x d x These integrals can both be evaluated by parts using the tabular method:
For the first
sign u u u d v \d{v} d v e − x e^{-x} e − x + + + x 3 x^3 x 3 − e − x -e^{-x} − e − x − - − 3 x 2 3x^2 3 x 2 e − x e^{-x} e − x + + + 6 x 6x 6 x − e − x -e^{-x} − e − x − - − 6 e − x e^{-x} e − x 0
so
∫ x 3 e − x d x = − x 3 e − x − 3 x 2 e − x − 6 x e − x − 6 e − x \int x^3 e^{-x} \d{x} = -x^3 e^{-x} - 3x^2 e^{-x} - 6x e^{-x}- 6 e^{-x} ∫ x 3 e − x d x = − x 3 e − x − 3 x 2 e − x − 6 x e − x − 6 e − x For the second
sign u u u d v \d{v} d v e − x e^{-x} e − x + + + x 2 x^2 x 2 − e − x -e^{-x} − e − x − - − 2 x 2x 2 x e − x e^{-x} e − x + + + 2 − e − x -e^{-x} − e − x 0
so
∫ x 2 e − x d x = − x 2 e − x − 2 x e − x − 2 e − x \int x^2 e^{-x} \d{x} = -x^2 e^{-x} - 2x e^{-x} - 2 e^{-x} ∫ x 2 e − x d x = − x 2 e − x − 2 x e − x − 2 e − x Substitute everything back:
y p = − e 2 x ( − x 3 e − x − 3 x 2 e − x − 6 x e − x − 6 e − x ) + x e 2 x ( − x 2 e − x − 2 x e − x − 2 e − x ) = ( x 2 + 4 x + 6 ) e x \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} y p = − e 2 x ( − x 3 e − x − 3 x 2 e − x − 6 x e − x − 6 e − x ) + x e 2 x ( − x 2 e − x − 2 x e − x − 2 e − x ) = ( x 2 + 4 x + 6 ) e x Combine and apply initial conditions:
The general solution and its first derivative are
y = ( c 1 + c 2 x ) e 2 x + ( x 2 + 4 x + 6 ) e x y ′ = 2 ( c 1 + c 2 x ) e 2 x + c 2 e 2 x + ( x 2 + 4 x + 6 ) e x + ( 2 x + 4 ) e x \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} y y ′ = ( c 1 + c 2 x ) e 2 x + ( x 2 + 4 x + 6 ) e x = 2 ( c 1 + c 2 x ) e 2 x + c 2 e 2 x + ( x 2 + 4 x + 6 ) e x + ( 2 x + 4 ) e x Plugging in intial conditions
y ( 0 ) = c 1 + 6 = 0 y ′ ( 0 ) = 2 c 1 + c 2 + 10 = 0 \begin{align}
y(0) &= c_1 + 6 = 0
y'(0) &= 2 c_1 + c_2 + 10 = 0
\end{align} y ( 0 ) = c 1 + 6 = 0 y ′ ( 0 ) = 2 c 1 + c 2 + 10 = 0 gives c 1 = − 6 c_1 = -6 c 1 = − 6 and c 2 = 2 c_2 = 2 c 2 = 2 .
The final solution is:
y = ( 2 x − 6 ) e 2 x + ( x 2 + 4 x + 6 ) e x y = (2 x - 6) e^{2x} + (x^{2}+4x+6)e^{x} y = ( 2 x − 6 ) e 2 x + ( x 2 + 4 x + 6 ) e x y ′ ′ + y = csc x , y ( π / 2 ) , y ′ ( π / 2 ) = 0 y'' + y = \csc x, \quad y(\pi/2), \quad y'(\pi/2) = 0 y ′′ + y = csc x , y ( π /2 ) , y ′ ( π /2 ) = 0 Find homogeneous solution y h y_{\rm h} y h :
y h ′ + y h = 0 λ 2 + 1 = 0 \begin{align}
y_{\rm h}' + y_{\rm h} &= 0 \\
\lambda^2 + 1 &= 0
\end{align} y h ′ + y h λ 2 + 1 = 0 = 0 so λ 1 , 2 = ± i \lambda_{1,2} = \pm i λ 1 , 2 = ± i and:
y h = c 1 cos x + c 2 sin x y_{\rm h} = c_1 \cos x + c_2 \sin_x y h = c 1 cos x + c 2 sin x Find particular solution y p y_{\rm p} y p :
y 1 = cos x , y 2 = sin x y 1 ′ = − sin x , y 2 ′ = cos x \begin{align}
y_1 &= \cos x , \quad y_2 = \sin x \\
y_1' &= -\sin x, \quad y_2'= \cos x
\end{align} y 1 y 1 ′ = cos x , y 2 = sin x = − sin x , y 2 ′ = cos x so the Wronskian is W = cos 2 x + sin 2 x = 1 W = \cos^2 x + \sin^2 x = 1 W = cos 2 x + sin 2 x = 1 . The right-hand side
function is
so the particular solution is:
y p = − cos x ∫ sin x csc ( x ) d x + sin x ∫ cos x csc ( x ) d x = − cos x ∫ d x + sin x ∫ cos x sin x d x = − x cos x + sin x ln ∣ x ∣ \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} y p = − cos x ∫ sin x csc ( x ) d x + sin x ∫ cos x csc ( x ) d x = − cos x ∫ d x + sin x ∫ sin x cos x d x = − x cos x + sin x ln ∣ x ∣ Combine and apply initial conditions:
The general solution and its first derivative are
y = c 1 cos x + c 2 sin x + sin x ln ∣ sin x ∣ − x cos x y ′ = − c 1 sin x + c 2 cos x + cos x ( 1 + ln ∣ sin x ∣ ) + x sin x − cos x \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} y y ′ = c 1 cos x + c 2 sin x + sin x ln ∣ sin x ∣ − x cos x = − c 1 sin x + c 2 cos x + cos x ( 1 + ln ∣ sin x ∣ ) + x sin x − cos x Plugging in intial conditions
y ( π / 2 ) = c 2 = 0 y ′ ( π / 2 ) = − c 1 + π / 2 = 0 \begin{align}
y(\pi/2) &= c_2 = 0\\
y'(\pi/2) &= -c_1 + \pi/2 = 0
\end{align} y ( π /2 ) y ′ ( π /2 ) = c 2 = 0 = − c 1 + π /2 = 0 so c 1 = π / 2 c_1 = \pi/2 c 1 = π /2 and c 2 = 0 c_2 = 0 c 2 = 0 .
The final solution is:
y = π 2 cos x + sin x ln ∣ sin x ∣ − x cos x y = \frac{\pi}{2} \cos x + \sin x \ln \left| \sin x \right| - x \cos x y = 2 π cos x + sin x ln ∣ sin x ∣ − x cos x