Method of Undetermined Coefficients/Sine and Cosine/Particular Solution/i b is Root of Auxiliary Equation/Exponential Form

Proof Technique
Consider the nonhomogeneous linear second order ODE with constant coefficients:
 * $(1): \quad y'' + b^2 y = \alpha \sin b x + \beta \cos b x$

The Method of Undetermined Coefficients can be used to find a particular solution to $(1)$ in the following manner.

Method and Proof
Let $\map {y_g} x$ be the general solution to:
 * $y'' + b^2 y = 0$

From General Solution of Linear 2nd Order ODE from Homogeneous 2nd Order ODE and Particular Solution:
 * $\map {y_g} x + \map {y_p} x$

is the general solution to $(1)$.

It remains to find $\map {y_p} x$.

Assume that there is a particular solution to $(1)$ of the form:
 * $y_p = x \paren {A \sin b x + B \cos b x}$

From Euler's Formula:
 * $\cos b x + i \sin b x = e^{i b x}$

and so:
 * $x \paren {A \sin b x + B \cos b x}$ is the real part of $x \paren {A - i B} \paren {\cos b x + i \sin b x} = x \paren {A - i B} e^{i b x}$

It is assumed that $A$, $B$, $p$ and $q$ are all real numbers.

Suppose we have found a solution $y$ of $(1)$ where:
 * $\map f x = \map {f_1} x + i \, \map {f_2} x$

where $\map y x$ and $\map f x$ are complex-valued.

Letting $\map y x = \map {y_1} x + \map {y_2} x$, where $y_1$ and $y_2$ are the real and imaginary parts of $\map y x$, we have:
 * ${y_1} + p {y_1}' + q y_1 + i \paren { {y_2} + p {y_2}' + q y_2} = \map {f_1} x + i \, \map {f_2} x$

Equating real parts:


 * ${y_1}'' + p {y_1}' + q y_1 = \map {f_1} x$

Equating imaginary parts:


 * ${y_2}'' + p {y_2}' + q y_2 = \map {f_2} x$

Thus if $y$ is a particular solution to $(1)$ when the is $\map f x$:


 * $\map \Re y$ is a particular solution to $(1)$ when the is $\map \Re {\map f x}$


 * $\map \Im y$ is a particular solution to $(1)$ when the is $\map \Im {\map f x}$

So to find a particular solution when the is $K \cos x$ or $K \sin x$, we can first find a particular solution when the  is $K e^{i b x}$ and then take its real part or imaginary part as necessary.

Hence, when we have $A \cos b x + B \sin b x$ on the :
 * replace it with $x \paren {A - i B} e^{i b x}$
 * use the Method of Undetermined Coefficients for Exponential functions

and then take its real part.