Linear Nonhomogeneous ODEs

A Linear Second Order Linear ODE can be written as follows: $$ L(y(x)) = y''(x) + p(x) y'(x) + q(x) y(x) = r(x) $$ The solution to the homogeneous problem \(L(y(x)) = 0\) is $$ y_h(x) = c_1 y_1(x) + c_2 y_2(x) $$ We need to find a particular solution to the problem to write the general solution $$ y(x) = y_h(x) + y_p(x)$$ The particular solution can be found by guessing the form of the solution if the right hand side has a simple form.

Example 1

Find the general solution of $$ x^2 y'' - 2 y = 1 $$ given two homogeneous solutions $$ y_1 = x^2, \; y_2 = \frac{1}{x} $$

solution:

The homogeneous solution $$ y_h(x) = c_1 x^2 + c_2 \frac{1}{x} $$ a particular solution of the problem is $$ y_p = -\frac{1}{2} $$ which can be verified by substitution. Then the general solution is $$ y(x) = c_1 x^2 + c_2 \frac{1}{x} - \frac{1}{2} $$

Method of Variation of Parameters

A general method for finding a particular solution is the Variation of the Parameters. $$ y_p(x) = u_1(x) y_1(x) + u_2(x) y_2(x) $$ Note that we replaced the constants of the homogeneous solutions with unkown functions \(u_1, u_2\). Substitution gives an equation for two unkowns. That means we need to make another assumption. $$ y_p'(x) = u_1' y_1 + u_1 y_1' + u_2' y_2 + u_2 y_2' $$ We will assume that $$ u_1' y_1 + u_2' y_2 = 0 $$ With this assumption $$ y_p'(x) = u_1 y_1' + u_2 y_2' $$ $$ y_p''(x) = u_1' y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2'' $$ Substitution gives $$ y_p'' + p(x) y_p' + q(x) y_p = u_1' y_1' + u_1 y_1'' + u_2' y_2' + u_2 y_2''\\ + p(x) (u_1 y_1' + u_2 y_2') + q(x) (u_1 y_1 + u_2 y_2) = r(x)$$ Since \(y_1\) and \(y_2\) are solutions of the homogeneous problems i.e. \(L(y_1) = L(y_2) = 0\) $$ u_1' y_1' + u_2' y_2' = r(x)$$ Now we have two equations for two unknowns $$ u_1' y_1 + u_2' y_2 = 0 $$ $$ u_1' y_1' + u_2' y_2' = r(x)$$ which can be written in matrix form $$ \left[ \begin{array}{c} y_1 && y_2 \\ y_1' && y_2' \end{array} \right] \left[ \begin{array}{c} u_1'\\u_2' \end{array} \right]=\left[ \begin{array}{cc} 0\\r \end{array} \right] $$ This algebraic system has a solution because the determinant of the matrix is not \(0\) due to linear independence of \(y_1,y_2\). Let $$ W = \left| \begin{array}{c} y_1 && y_2 \\ y_1' && y_2' \end{array} \right|, \; W_1 = \left| \begin{array}{c} 0 && y_2 \\ r && y_2' \end{array} \right| ,\; W_2 = \left| \begin{array}{c} y_1 && 0 \\ y_1' && r \end{array} \right| $$ Using Kramer's rule $$ u_1' = \frac{W_1}{W} = \frac{-r y_2}{W}, \; u_2' = \frac{W_2}{W} =\frac{r y_1}{W} $$ Integration and substitution gives $$ y_p = u_1 y_1 + u_2 y_2 = -y_1 \int{\frac{r y_2}{W}dx} + y_2 \int{\frac{r y_1}{W}dx} $$

Example 2

Find the general solution of $$ y'' + y = 2 e^x $$

solution:

The homogeneous solution $$ y_h(x) = c_1 \cos{x} + c_2 \sin{x} $$ a particular solution of the problem is $$ y_1(x) = \cos{x}, y_2(x) = \sin{x}, r(x) = 2 e^x$$ $$ W = \left| \begin{array}{c} \cos{x} && \sin{x} \\ -\sin{x} && \cos{x} \end{array} \right| = 1$$ $$ y_p = -y_1 \int{\frac{r y_2}{W}dx} + y_2 \int{\frac{r y_1}{W}dx} $$ $$ y_p = -\cos{x} \int{2 e^x \sin{x} dx} + \sin{x} \int{2 e^x \cos{x} dx} = e^x $$ The general solution $$ y(x) = c_1 \cos{x} + c_2 \sin{x} + e^x $$

Example 3

Find the general solution of $$ x^2 y'' - 2 y = \log{x} $$ given two homogeneous solutions $$ y_1 = x^2, \; y_2 = \frac{1}{x} $$

solution:

The homogeneous solution $$ y_h(x) = c_1 x^2 + c_2 \frac{1}{x} $$ $$ y_1(x) = x^2, y_2(x) = \frac{1}{x}, r(x) = \frac{\log{x}}{x^2} $$ $$ W = \left| \begin{array}{c} x^2 && \frac{1}{x} \\ 2x && -\frac{1}{x^2} \end{array} \right| = -3$$ $$ y_p = -y_1 \int{\frac{r y_2}{W}dx} + y_2 \int{\frac{r y_1}{W}dx} $$ $$ y_p = -x^2 \int{\frac{\log{x}}{-3 x^3} dx} + \frac{1}{x} \int{\frac{\log{x}}{-3} dx} = \frac{1}{4} - \frac{\log{x}}{2}$$ The general solution $$ y(x) = c_1 x^2 + c_2 \frac{1}{x} + \frac{1}{4} - \frac{\log{x}}{2} $$