Constant Coefficient Nonhomogeneous ODEs

A constant coefficient Second Order Linear ODE can be written as follows: $$ L(y(x)) = y''(x) + a y'(x) + b y(x) = r(x) $$ If \(r(x)=0\), the equation is said to be homogeneous. After solving the algebraic equation $$ λ^2 + a λ + b = 0$$ the general solution to the homogeneous problem \(L(y(x)) = 0\) is $$ y_h(x) = c_1 e^{λ_1 x} + c_2 e^{λ_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 $$ y'' + y = 1 $$

solution:

The characteristic equation is $$ λ^2 + 1= 0$$ with two distinct imaginary roots $$ λ_1 = i, \; λ_2 = -i $$ with the homogeneous solution $$ y_h(x) = c_1 \cos{x} + c_2 \sin{x} $$ a particular solution of the problem is $$ y_p = 1 $$ which can be verified by substitution. Then the general solution is $$ y(x) = c_1 \cos{x} + c_2 \sin{x} + 1 $$

Method of Undetermined Coefficients

A particular solution can be guessed if the right hand side is a polynomial, exponential, trigonometric function or some combination. The method of guessing the particular solution can be made systematic if one can use the following rules. For the problem $$ L(y) = r $$ if the right hand side is of the form $$ r(x) = \left[ a(x) \cos{β x} + b(x) \sin{β x} \right] e^{α x} $$ where $$ a(x) = a_n x^n + a_{n-1} x^{n-1} + ... + a_0 $$ $$ b(x) = b_n x^n + b_{n-1} x^{n-1} + ... + b_0 $$ then the particular solution is of the form $$ y_p(x) = \left[ A(x) \cos{β x} + B(x) \sin{β x} \right] e^{α x} x^k $$ where $$ A(x) = A_n x^n + A_{n-1} x^{n-1} + ... + A_0 $$ $$ B(x) = B_n x^n + B_{n-1} x^{n-1} + ... + B_0 $$ \(α, β\) are constants and \(k\) is a positive integer constant. \(x^k\) term may be necessary to make the particular solution linearly independent from the homogeneous solution. Linearity can be used if the right hands side is a combination of terms given above $$ L(y_{p_1}) = r_1, \; L(y_{p_2}) = r_2 \rightarrow L(y_{p_1}+y_{p_2}) = r_1 + r_2 $$ $$ r = r_1 + r_2 \rightarrow y_p = y_{p_1}+y_{p_2}$$

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_p = A_0 e^x $$ $$ n=0, a_i = 0 \;\; i=1,2...n, a_0 = 2, b_i=0 \;\; i=0,1...n, α=1, β=0 $$ \(A_0=1\) can be found by substitution. Then the general solution is $$ y(x) = c_1 \cos{x} + c_2 \sin{x} + e^x $$ That means we can solve the following problem by using linearity $$ y'' + y = 1 + 2 e^x $$ has the general solution $$ y(x) = c_1 \cos{x} + c_2 \sin{x} + 1 + e^x $$

Example 3

Solve the following ODE $$ y'' - 2y' + y = x $$

solution:

Assuming \(y(x)=e^{λx}\). Then the characteristic equation is $$ λ^2 - 2λ + 1= (λ-1)^2 = 0$$ with two identical roots $$ λ_1 = λ_2 = 1 $$ with homogeneous solution $$ y_h(x) = c_1 e^{x} + c_2 x e^{x} $$ a particular solution can be found by assuming $$ y_p(x) = A_1 x + A_0 $$ $$ n=1, a_1 = 1, a_0 = 0, α=0, β=0 $$ substitution $$ y_p'' - 2y_p' + y_p = 0 - 2 A_1 + A_1 x + A_0 = x $$ Since this must be true for all values of \(x\) $$ A_1 = 1 $$ $$ - 2 A_1 + A_0 = 0 \rightarrow A_0 = 2 $$ The general solution $$ y(x) = y_h(x) + y_p(x) = c_1 e^{x} + c_2 x e^{x} + x + 2$$

Example 3

Solve the following ODE $$ y'' - 2y' + y = e^x $$

solution:

The homogeneous solution is $$ y_h(x) = c_1 e^{x} + c_2 x e^{x} $$ a particular solution can be found by assuming $$ y_p(x) = A_0 e^x x^2 $$ $$ y_p' = A_0 e^x (x^2 + 2x) $$ $$ y_p'' = A_0 e^x (x^2 + 4x + 2) $$ $$ n=0, a_0 = 1, α=1, β=0, k = 2 $$ substitution $$ y_p'' - 2y_p' + y_p = A_0 e^x (x^2 + 4x + 2) -2 A_0 e^x (x^2 + 2x) + A_0 e^x x^2 = 2 A_0 e^x = e^x $$ $$ A_0 = \frac{1}{2} $$ The general solution $$ y(x) = y_h(x) + y_p(x) = c_1 e^{x} + c_2 x e^{x} + \frac{1}{2} e^x x^2 $$

Example 4

Solve the following ODE $$ y'' - 4 y = sin(2x) e^x $$

solution:

The characteristic equation is $$ λ^2 - 4 = (λ-2)(λ+2) = 0$$ The homogeneous solution is $$ y_h(x) = c_1 e^{-2x} + c_2 e^{2x} $$ a particular solution can be found by assuming $$ y_p(x) = (A_0 \cos{2x} + B_0 \sin{2x}) e^x $$ $$ y_p' = (-2 A_0 \sin{2x} + 2 B_0 \cos{2x}) e^x + (A_0 \cos{2x} + B_0 \sin{2x}) e^x $$ $$ y_p' = [ (B_0 - 2 A_0) \sin{2x} + (2 B_0 + A_0) \cos{2x} ] e^x $$ $$ y_p'' = [ 2(B_0 - 2 A_0) \cos{2x} - 2 (2 B_0 + A_0) \sin{2x} ] e^x \\ + [ (B_0 - 2 A_0) \sin{2x} + (2 B_0 + A_0) \cos{2x} ] e^x $$ $$ y_p'' = [ (4 B_0 - 3 A_0) \cos{2x} - (3 B_0 + 4 A_0) \sin{2x} ] e^x $$ substitution $$ y_p'' - 4 y_p = [ (4 B_0 - 3 A_0) \cos{2x} - (3 B_0 + 4 A_0) \sin{2x} ] e^x \\ -4 (A_0 \cos{2x} + B_0 \sin{2x}) e^x = sin(2x) e^x $$ $$ 4 B_0 - 7 A_0 = 0 $$ $$ -7 B_0 - 4 A_0 = 1 $$ $$ A_0 = -\frac{4}{65}, \; B_0 = -\frac{7}{65}$$ The general solution $$ y(x) = y_h(x) + y_p(x) = c_1 e^{-2x} + c_2 e^{2x} - (\frac{4}{65} \cos{2x} + \frac{7}{65} \sin{2x}) e^x $$