Mathematics, Sciences, and Technologies

“Every secret of a writer’s soul, every experience of his life, every quality of his mind is written large in his works.”
– Virginia Woolf

ODEs 2-8: Variation of Parameters

,

Constructing the Particular Solution from Complementary Solution

Another more general method to derive the particular solution for a non-homogeneous second-order ODE is the Variation of Parameters. Assume that the complementary solution takes the form of \( y_c = c_1 y_1 + c_2 y_2 \) where \( y_1(x), y_2(x) \) are two linearly independent bases. The essence of this method is to “vary” the constants \( c_1, c_2 \) so now they are some parameters \( p_1(x), p_2(x) \) that are functions of \(x\), and the particular solution will look like \( y_p = p_1(x) y_1 + p_2(x) y_2 \). The corresponding first derivative is

\begin{align}
y_p’ &= p_1^\prime y_1 + p_1 y_1^\prime + p_2^\prime y_2 + p_2 y_2^\prime \\
&= (p_1^\prime y_1 + p_2^\prime y_2) + p_1 y_1^\prime + p_2 y_2^\prime \\
&= p_1 y_1^\prime + p_2 y_2^\prime \tag{1}
\end{align}

where we have made a very important assumption that

\begin{equation}
p_1^\prime y_1 + p_2^\prime y_2 = 0 \tag{2}
\end{equation}

This will be of use later. Subsequently, the second derivative will be

\begin{align}
y_p^{\prime\prime} = p_1^\prime y_1^\prime + p_1 y_1^{\prime\prime} + p_2^\prime y_2^\prime + p_2 y_2^{\prime\prime} \tag{3}
\end{align}

For the original second-order non-homogeneous ODE:

\begin{equation}
\frac{d^2y}{dx^2} + \alpha\frac{dy}{dx} + \beta y = G(x) \tag{4}
\end{equation}

where \( G(x) \) is the source term, substituting the particular solution with (1) and (3) leads to

\begin{align}
y_p^{\prime\prime} + \alpha y_p’ + \beta y_p &= G(x) \\
\begin{aligned}
&p_1^\prime y_1^\prime + p_1 y_1^{\prime\prime} + p_2^\prime y_2^\prime + p_2 y_2^{\prime\prime} \\
& + \alpha (p_1 y_1^\prime + p_2 y_2^\prime) + \beta (p_1 y_1 + p_2 y_2)
\end{aligned}
&= G(x) \\
\begin{aligned}
&p_1 y_1^{\prime\prime} + \alpha p_1 y_1^\prime + \beta p_1 y_1 + p_2 y_2^{\prime\prime} + \alpha p_2 y_2^\prime + \beta p_2 y_2 \\
& + p_1^\prime y_1^\prime + p_2^\prime y_2^\prime
\end{aligned}
&= G(x) \\
\begin{aligned}
&p_1 (y_1^{\prime\prime} + \alpha y_1^\prime + \beta y_1) + p_2 (y_2^{\prime\prime} + \alpha y_2^\prime + \beta y_2) \\
& + p_1^\prime y_1^\prime + p_2^\prime y_2^\prime
\end{aligned}
&= G(x) \\
p_1^\prime y_1^\prime + p_2^\prime y_2^\prime &= G(x) \tag{5}
\end{align}

The bracketed terms vanish because \( y_1, y_2 \) are exactly the complementary solutions that satisfy the original ODE: \( y_1^{\prime\prime} + \alpha y_1^\prime + \beta y_1 = 0\) and \( y_2^{\prime\prime} + \alpha y_2^\prime + \beta y_2 = 0 \). Equations (2) and (5) then form a linear system

\begin{align}
\left\{\begin{aligned}
p_1^\prime y_1 + p_2^\prime y_2 &= 0 \\
p_1^\prime y_1^\prime + p_2^\prime y_2^\prime &= G(x)
\end{aligned}\right. \tag{6}
\end{align}

which can be solved for \( p_1^\prime, p_2^\prime \) (\(y_1, y_2\) are known). Integrating them respectively then yields \( p_1, p_2 \) and hence we shall retrieve the particular solution.

Example

Find the particular solution for the non-homogeneous ODE:

\begin{equation}
\frac{d^2y}{dx^2} + 4y = \tan x \tag{7}
\end{equation}

The two complementary solutions are easily seen to be \( y_1 = \cos(2x) \) and \( y_2 = \sin(2x) \). Now we let \( y_p = v_1(x)y_1 + v_2(x)y_2 \) and need to solve

\begin{align}
\left\{\begin{aligned}
v_1’y_1 + v_2’y_2 &= 0 \\
v_1’y_1^\prime + v_2’y_2^\prime &= \tan x
\end{aligned}\right.
\Rightarrow
\left\{\begin{aligned}
v_1’\cos(2x) + v_2’\sin(2x) &= 0 \\
v_1^\prime(-2\sin(2x)) + v_2^\prime(2\cos(2x)) &= \tan x
\end{aligned}\right. \tag{8}
\end{align}

according to (6) with \( p \) replaced by \( v \). By Cramer’s Rule in Linear Algebra, we get

\begin{align}
v_1^\prime &= \frac{
\begin{vmatrix}
0 & \sin(2x) \\
\tan x & 2\cos(2x)
\end{vmatrix}
}{W} \\
&= \frac{1}{2}(-\sin(2x)\tan(x)) \\
&= -\frac{1}{2}(2\sin x\cos x)\frac{\sin x}{\cos x} = -\sin^2 x \tag{9}
\end{align}

where the Wronskian is

\begin{align}
W[y_1, y_2] &=
\begin{vmatrix}
\cos(2x) & \sin(2x) \\
-2\sin(2x) & 2\cos(2x)
\end{vmatrix} \\
&= 2\cos^2(2x) + 2\sin^2(2x) = 2 \tag{10}
\end{align}

Similarly,

\begin{align}
v_2^\prime &= \frac{1}{2}\cos(2x)\tan x \\
&= \frac{1}{2}(2\cos^2 x -1)\tan x \\
&= \sin x \cos x -\frac{1}{2} \tan x = \frac{1}{2} \sin 2x -\frac{1}{2} \tan x \tag{11}
\end{align}

Now what remains is to integrate them to obtain

\begin{align}
v_1 &= \int -\sin^2 x dx \\
&= \int \frac{\cos (2x) -1}{2} dx = \frac{1}{4} \sin (2x) -\frac{1}{2}x \tag{12} \\
v_2 &= \int (\frac{1}{2} \sin 2x -\frac{1}{2} \tan x) dx \\
&= -\frac{1}{4} \cos (2x) + \frac{1}{2} \ln (\cos x) \tag{13}
\end{align}

(No need to include the integration constants, why?) and thus

\begin{align}
y_p &= v_1y_1 + v_2y_2 \\
&= [\frac{1}{4} \sin (2x) -\frac{1}{2}x](\cos(2x)) \\
&\quad+ [-\frac{1}{4} \cos (2x) + \frac{1}{2} \ln (\cos x)](\sin(2x)) \\
&= -\frac{1}{2}x\cos(2x) + \frac{1}{2}\sin(2x)\ln (\cos x) \tag{14}
\end{align}

where we have absorbed the terms same as the complementary solutions.

Exercise

Derive the full solution of

\begin{equation}
2\frac{d^2y}{dx^2} -3\frac{dy}{dx} + y = xe^x \tag{15}
\end{equation}

where \( y(0) = 1, y'(0) = 0\), by Variation of Parameters.

Answer

The auxiliary equation is seen to be \( 2r^2 -3r + 1 = 0 \) which has the root of \( r = 1/2, 1 \). Therefore, the complementary solutions are \( y_1 = e^{x/2} \) and \( y_2 = e^x \). We then seek to solve (6); however, note that the leading coefficient of (15) is \( 2 \), so we need to normalize it by multiplying \( 1/2 \), and \(G(x)\) will be \( xe^x/2 \). The linear system is then

\begin{align}
\left\{\begin{aligned}
p_1’y_1 + p_2’y_2 &= 0 \\
p_1’y_1^\prime + p_2’y_2^\prime &= xe^x/2
\end{aligned}\right.
\Rightarrow
\left\{\begin{aligned}
p_1’e^{x/2} + p_2’e^{x} &= 0 \\
p_1^\prime((1/2)e^{x/2}) + p_2^\prime e^{x} &= xe^x/2
\end{aligned}\right.
\end{align}

This is not very hard to solve: \( p_1^\prime = -xe^{x/2} \) and \( p_2^\prime = x \), and

\begin{align}
p_1 &= -\int xe^{x/2} dx \\
&= -2\int x d(e^{x/2}) \\
&= -2[xe^{x/2}] + 2\int e^{x/2}dx \\
&= -2xe^{x/2} + 4e^{x/2}
\end{align}

also \( p_2 = x^2/2\) easily. The particular solution is hence

\begin{align}
y_p &= p_1y_1 + p_2y_2 \\
&= (-2xe^{x/2} + 4e^{x/2})e^{x/2} + (x^2/2)e^x \\
&= 4e^x -2xe^x + x^2e^x/2 = -2xe^x + x^2e^x/2
\end{align}

where the \(4e^x\) term can be absorbed into \( y_2 \). The general solution will be

\begin{align}
y = c_1e^{x/2} + c_2e^x -2xe^x + x^2e^x/2
\end{align}

and \( y’ = (c_1/2)e^{x/2} + (c_2-2)e^x -xe^x + x^2e^x/2 \). Matching the I.C. reveals that \( c_1 = -2, c_2 = 3 \), and the full solution is therefore

\begin{equation}
y = -2e^{x/2} + (x^2/2 -2x +3)e^x
\end{equation}

This question can also be solved by the previous method of Undetermined Coefficients.

Leave a Reply

I’m Benjamin

Welcome to my Mathematical World! Here you can find posts and tutorials related to applied topics like Linear Algebra, Calculus, Differential Equations, as well as Programming. Feel free to leave comments and suggestions!

Let’s connect

Discover more from Benjamin's Maths World

Subscribe now to keep reading and get access to the full archive.

Continue reading