Higher Order Linear nonhomogeneous ODEs can be written in the most general form:
$$ L(y(x)) = y^{(n)} + p_{n-1}(x) y^{(n-1)} + \cdots + p_1(x) y' + p_0(x) y = 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) + \ldots + c_n y_n(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^3 y^{(3)} - 3 x^2 y'' + 6 x y' - 6y = 1 $$
solution:
This is a Cauchy-Euler equation. Indicial Equation
$$r(r-1)(r-2) - 3 r(r-1) + 6r - 6 = (r-1) (r-2) (r-3) = 0$$
Then the homogeneous solution is
$$ y_h(x) = c_1 x + c_2 x^2 + c_3 x^3 $$
a particular solution of the problem is
$$ y_p = -\frac{1}{6} $$
which can be verified by substitution. Then the general solution is
$$ y(x) = c_1 x + c_2 x^2 + c_3 x^3 - \frac{1}{6} $$
Method of Variation of Parameters
A general method for finding a particular solution for a linear equation is the Variation of the Parameters.
$$ y_p(x) = u_1(x) y_1(x) + u_2(x) y_2(x) + \cdots + u_n(x) y_n(x) $$
Note that we replaced the constants of the homogeneous solutions with unkown functions \(u_1, u_2, \cdots, u_n\).
Substitution gives an equation for \(n\) unkowns. That means we need to make additional \(n-1\) assumptions.
We will assume that
$$ u_1' y_1 + u_2' y_2 + \cdots + u_n' y_n= 0 $$
$$ u_1' y_1' + u_2' y_2' + \cdots + u_n' y_n'= 0 $$
$$ \cdots $$
$$ u_1' y_1^{(n-2)} + u_2' y_2^{(n-2)} + \cdots + u_n' y_n^{(n-2)}= 0 $$
from the equation itself we get
$$ u_1' y_1^{(n-1)} + u_2' y_2^{(n-1)} + \cdots + u_n' y_n^{(n-1)} = r(x) $$
which can be written in matrix form
$$ \left[ \begin{array}{cccc} y_1 && y_2 && \cdots && y_n
\\ y_1' && y_2'&& \cdots && y_n'
\\\cdots&&\cdots&&\cdots&&\cdots
\\ y_1^{(n-1)} && y_2^{(n-1)}&& \cdots && y_n^{(n-1)}
\end{array} \right]
\left[ \begin{array}{c} u_1'\\u_2'\\\cdots \\ u_n' \end{array} \right] =
\left[ \begin{array}{c} 0 \\0 \\ \cdots \\ 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,\cdots,y_n\).
Solving this system and integrating gives us the particular solution we need
Example 2
Find the general solution of $$ x^3 y''' - 3 x^2 y'' + 6 x y' - 6y = x $$
solution:
Indicial Equation
$$r(r-1)(r-2) - 3 r(r-1) + 6r - 6 = (r-1) (r-2) (r-3) = 0$$
The homogeneous solution
$$ y(x) = c_1 x + c_2 x^2 + c_3 x^3 $$
$$ \left[ \begin{array}{ccc} x && x^2 && x^3
\\ 1 && 2x && 3x^2
\\ 0 && 2 && 6x
\end{array} \right]
\left[ \begin{array}{c} u_1' \\u_2' \\ u_3' \end{array} \right] =
\left[ \begin{array}{c} 0 \\ 0 \\ r \end{array} \right] $$
where \(r = \frac{1}{x^2}\). Applying Gaussian elimination
$$ \left[ \begin{array}{ccc} 1 && x && x^2
\\ 0 && 1 && 2x
\\ 0 && 0 && 2x
\end{array} \right]
\left[ \begin{array}{c} u_1' \\u_2' \\ u_3' \end{array} \right] =
\left[ \begin{array}{c} 0 \\ 0 \\ \frac{1}{x^2} \end{array} \right] $$
Back substitution gives
$$ u_1' = \frac{1}{2x}, u_2' = -\frac{1}{x^2}, u_3' = \frac{1}{2 x^3} $$
integrating
$$ u_1 = \frac{1}{2} \log{x}, u_2' = \frac{1}{x}, u_3' = -\frac{1}{4 x^2} $$
a particular solution
$$ y_p(x) = \frac{1}{2} x \log{x} + \frac{1}{x} x^2 - \frac{1}{4 x^2} x^3 = \frac{1}{2} x \log{x} + \frac{3}{4} x$$
where the last term is not independent from the homogeneous solution and can be ignored.
The general solution is
$$ y(x) = c_1 x + c_2 x^2 + c_3 x^3 + \frac{1}{2} x \log{x} $$