Method of undetermined coefficients
So far we have studied through methods of solving second order differential equations which are homogeneous, in this case, we will turn now into nonhomogeneous second order linear differential equations and we will introduce a method for solving them called the method of undetermined coefficients.
Before we look into the solution method for these equations, let us first differentiate between a homogeneous and a nonhomogeneous second order differential equation.
By definition, a homogeneous equation (homogeneous differential equation) is that which consists only on terms containing the unknown function and derivatives of it, sometimes accompanied by coefficients, but not necessarily. Usually all of these terms are gathered in one side of the equation making it equal to zero.
We usually name our unknown function as "y" due standardization of the cartesian geometric system. The function could really have any name, but it is important to know that we select "y" because of the meaning and relation of mathematical functions with the use of the cartesian coordinate system in their representation.
Continuing with the explanation on homogeneous differential equations, the unknown function y is a function in terms of x (simply put: y(x)), still, no terms of x or constants are outside of the functions for these equations, in other words, besides y, derivatives of y and constant coefficients, one cannot have any other term in the equation or it would make it a nonhomogeneous differential equation like the one show below:
The obvious difference between the two is that the right hand side of the equation is zero for homogeneous equations, while for the nonhomogeneous case is a function of x, but this is just because both equations have been organized this way, there may be cases where the equations have been rearranged differently and you need to learn how to identify each of them. The main difference is that the nonhomogeneous equation can contain independent terms involving only x or constants, while the homogeneous equation cannot. These independent terms are represented on equation 2 as function "d(x)", which is just a name we have given to say "there are terms in there containing x which are not related to the unknown y function".
While analyzing these equations notice both equations 1 and 2 are second order differential equations because both contain as its higher order derivative the second derivation of y; and last but not least, observe how these two simple examples of equations have all coefficients equal to 1, but these equations could contain coefficients equal to any number. More examples of homogeneous and nonhomogeneous differential equations will be presented throughout this article in order for you to learn how to identify one or the other, but before that, let us explain coefficients.
What are coefficients?
In the last section we have mentioned how equations 1 and 2 contain coefficients all equal to 1. Let us quickly recall that coefficients are constant numbers that come before a variable in a mathematical expression, they multiply the variable and can be any number. Therefore, we rewrite equation 1 so you can see what we are talking about its coefficients all being 1:
We usually do not write coefficients equal to one because they do not change the amount of variables we have on an equation and thus, it seems repetitive and impractical. But it is important to note the coefficients are there, and we could have any numbers as coefficients and still, they would not affect the homogeneous or nonhomogeneous status of an equation since they only express how many times the function or its derivatives are contained in the equation but do not add any other expression out of them.
Differential equations examples:
To finalize with the distinction between homogeneous or nonhomogeneous differential equations, let us take a quick look at a few examples to identify if they are homogeneous or nonhomogeneous. Please check the next four example equations and try to identify them as either homogeneous or not homogeneous before you continue to the next part, where the solutions and explanations will be given.
Ready to see how you did?
The answers are:
 Notice there are only two terms in the equation and they all have either y or a derivative of it on them. Also, you can rearrange this equation by passing the right hand side term to the left, making the equation equal to zero and leaving no independent terms by themselves such as x's or constants. So this equation is homogeneous:
 This equation contains two terms which are completely independent of y, if we rearrange the equation leaving these two terms in the right hand side and passing all of the y or yderivatives to the left, the equation looks like:?
 Although equation c does not contain x by itself, we do have a constant in there which is independent to y and so this equation is nonhomogeneous. Rearranging:?
Here d(x) is different to zero, and thus the equation becomes nonhomogeneous.
 This equation is very similar to equation c, but since it only contains terms of y or its derivatives, this is a homogeneous equation. Rearranging:
Which we can even compare with equation 2 and see that in this case d(x)=x+3
How to solve undetermined coefficients:
After all of this introduction and review, it is finally time for us to study and use the method of undetermined coefficients to find one solution of a differential equation. We start by having the general form of a nonhomogeneous constant coefficient second order linear differential equation:
Notice the name of the equation contains the words "constant coefficient" because in this case, the requirement for us to solve for undetermined coefficients is that A, B and C are any constants. The full general solution of equation 5 is in the form of:
Where it can be easily seen that we have two solutions combined: $y_{c}(x)$ and $y_{p}(x)$. These are what we call the complementary and particular solutions. So the method for solving the nonhomogeneous differential equation can be seen as a two part method where we first obtain the complementary solution and then the particular. The good news (and something that may be confusing at first), is that the first step usually is to simplify the nonhomogeneous equation into a homogeneous one in order to use methodology we are already familiarized with, such as repeated roots, real distinct roots, separable equations, etc, to solve for the complementary solution. Then we go ahead and find the particular solution by applying the initial conditions given in the problem.
Let us work through a first example so you can take a look into each step of the process:
Solve the given differential equation by undetermined coefficients method.

Having the initial conditions of: $y(0) = \frac{1}{2}$ and $y'(0) = \frac{1}{2}$
We first find the complementary solution by setting the left hand side of the equation to zero (as in the case of a homogeneous second order differential equation). And so, we rewrite: 
Using the method of real distinct roots we obtain the solutions of the equation:

And thus: $r=5, 1$ and the complementary solution is:
Having found the expression for the complementary solution, the second step for us to find the general solution of the differential equation is to find the particular solution.
 Something worth to pay attention to is that since the general solution comes from adding the complementary solution and the particular solution, if we were NOT to add the particular solution, then the differential equation would continue to be equal to zero and thus incorrect in this case, since we were originally given a nonhomogeneous equation.

And so, the particular solution different to zero comes to be the changing factor between a homogeneous and a nonhomogeneous differential equation.
Now, to find the particular solution we assume:
 Notice we have assumed the solution should be proportional to $e^{3x}$ since the result of the nonhomogeneous equation has this term which has derivatives that do not change its exponent. Therefore, our task here is to find the coefficient A, and that is why the method of solution is called "method of undetermined coefficients"!. Our undetermined coefficient to find here is A since the rest of the term will not change.

Let us find the first and second derivatives of our particular solution:

And plug these into the equation 7 to solve:

And so, the particular solution looks like:

The general solution of the second order nonhomogeneous differential equation is obtained by adding the complementary and the particular solution:

Now all that is left is to find the values of $c_{1}$ and $c_{2}$, so we obtain the first derivative of the equation and then input the initial conditions $y(0)=\frac{1}{2}$ and $y'(0)=\frac{1}{2}$ in order to find the values of $c_{1}$ and $c_{2}$:

So the two equations to solve the two unknowns are:

To solve for $c_{1}$ and $c_{2}$ we substitute the left equation into the right one:

As a consequence, the general solution of y''  6y' + 5y = $2e^{3x}$ is:
As done in past articles, we can prove this result by taking our general solution equation and obtaining its first and second derivative, then plugging these results into the initial equation and simplifying. We will do it only for this, our first example, but it is recommended that you go ahead and make the proofs of all of the problems you work through so that you can continue to develop your skills on the subject.
 Proof. Having:

Substituting into the original equation:

Associating common terms:
To summarize the complete method of undetermined coefficients, let us compile it in the next steps:

Find the complementary solution by simplifying the given equation into a homogeneous differential equation.
 Use methods we already know to solve for the homogeneous equation (look into the links given in past section of this article).

Solve the particular solution by looking into d(x) and creating an initial guessed solution which contains the undefined coefficient.
Note: Remember d(x) is formed by the variables independent to y. For past example: $d(x)=2e^{3x}$
 Find the first and second derivatives of the guessed solution and plug them into the original equation.
 Using simple algebra, simplify and solve for the undetermined coefficient
 Form the general solution by adding the found complementary and particular solutions from past steps
 Use initial conditions to find the missing unknown constant coefficients in the general solution.
And then if you want to make sure your response is correct, go ahead and work the proof!
Undetermined coefficients examples:
For this section we will be working on two examples of undetermined coefficients differential equations solutions with a little higher degree of difficulty. We will be following the list of steps summarized in the last section and what is even better, the next problems have been selected to construct a point for the next section of the article. So without further ado, let us start!
Example 1
Solve differential equation (a):
with initial conditions: $y(0) = \frac{12}{13}$ and $y'(0) = \frac{10}{13}$
We follow the next steps:

1. Simplify the equation into a homogeneous differential equation form and find the complementary solution using the real distinct roots method:

2. Looking back to equation (a) we create an initial guessed solution which contains the undefined coefficients. Recommendation: In general, whenever d(x) contains either a sine or cosine term, or both, always use a guessed solution which contains both terms such as the one we have selected to use next:

3. Find the first and second derivatives of the guessed solution and plug them into the original equation.
Plugging into equation (a):

4. Using simple algebra, simplify and solve for the undetermined coefficients. In this case we do not have any cosine term in the right hand side of the equation, and therefore the whole part associated with it goes to zero as follows:

5. Form the general solution by adding the found complementary and particular solutions from past steps:

6. Use initial conditions to find the missing unknown constant coefficients in the general solution. We start by computing the derivative of our general solution expression, and then we apply the conditions:
Example 2
Solve differential equation (b):
with initial conditions: $y(0)=3$ and $y'(0)=1$
We follow the next steps:

1. Since equation (a) and (b) are exactly the same on their left hand side, then step one is the same as example 1 and we have the complementary solution:

2. Now we create an initial guessed solution which contains the undefined coefficients. Recommendation: since the right hand side of equation (b) has terms with exponents as high as 3, we should create a guessed solution which contains exes with exponents up to 3. In general, for cases like this, the highest exponent will set the amount of coefficients to determine. If the highest exponent of x is n, then you have to create a guessed solution with x terms containing ALL the exponents of x until you reach n.
So the guessed solution is:

3. Finding the first and second derivatives of the guessed solution:

4. Simplify and solve for the undetermined coefficients:

5. Form the general solution by adding the found complementary and particular solutions from past steps:

6. We obtain the first derivative of the general solution and then apply the initial conditions to find the missing unknown constant coefficients:
Undetermined coefficients superposition approach:
We finalize this article with the superposition approach for the undetermined coefficients method, and for that we will solve the next second order nonhomogeneous differential equation:
At first look we may think the process to solve such equation would be very complicated, but it is here where we take approach of the two examples shown in the past section to solve this equation rather efficiently.
We already know that if we simplify the left hand side of the equation into a homogeneous equation, our complementary solution would be:
Then, we need to look for the particular solution which results in the right hand side of the equation equal to:
Well this is just a composite of the right hand side of equations (a) and (b)!
And so, the superposition approach tells us that we can just combine the particular solutions which solve the equations with the given right hand side terms.
Therefore, for:
And the general solution looks like:
The complementary solution to $Ay''+By'+Cy=0$ is $y_c (x)=c_1 f(x)+c_2 g(x)$
And the particular solution to $Ay''+By'+Cy=d(x)$ is $y_p (x)$
So the full general solution to
Will be $y(x)=y_c+y_p$
If $y_p1 (x)$ is a particular solution for
And $y_p2 (x)$ is a particular solution for
Then $y_p1 (x)+y_p2 (x)$ is a solution to