How to use Euler's formula for this nonhomogeneous ODE? This is a homework problem that I have for an engineering mathematics class. The problem is as follows:

Solve the following ODE by using the method of undetermined coefficients in which Euler's formula needs to be utilized:
$$y'' - 2y' + y = \sin(t)$$

The way that I solved this doesn't involve Euler's formula, and I was wondering how I might use the formula here.
My approach:
The formula can be written as $y(t) = y_h(t) + y_p(t)$ where $y_h(t)$ is the "homogeneous version" of the ODE and $y_p(t)$ is the particular solution that we'll obtain via the basic rule of the method of undetermined coefficients.
$y_h(t)$:
Putting $r(t) = \sin(t) = 0$ in the original equation, the ODE we need to solve is:
$$y'' - 2y' + y = 0$$
where we can set the general solution as $y = e^{\lambda t}$ and obtain the characteristic equation:
$$\lambda^2 - 2\lambda + 1 = 0$$
which has a real double root, hence giving us the solution:
$$y_h(t) = (c_1 + c_2t)e^t$$
$y_p(t)$:
Judging by the fact that $r(t)$ is shape $k\sin(\omega t)$ and we know that $\omega = 1$ we can set the general solution to be of form:
$$
\begin{align}
y_p(t) & = \phantom{-}K\cos(t) + M\sin(t) \\
y_p'(t) & = -K\sin(t) + M\cos(t) \\ 
y_p''(t) & = -K\cos(t) - M\sin(t)
\end{align}$$
substituting these equations into the original equation and then simplifying gives us:
$$y_p(t) = \frac{1}{2} \cos(t)$$
And in conclusion, we can write that the solution to the given ODE is:
$$
\begin{align}
y(t) & = y_h(t) + y_p(t) \\
& = (c_1 + c_2 t)e^t + \frac{1}{2}\cos(t)
\end{align}
$$
How would we be able to derive this conclusion via Euler's formula? Thanks in advance.
 A: So, here Euler's formula means using $\sin t= =\frac{e^{it}-e^{-it}}{2i}$ The particular integral will be found as
$$f(D)y=e^{at}\implies y_p(t)=\frac{ e^{at}}{f(a)}$$
Where we have $$(D-1)^2y= \frac{e^{it}-e^{-it}}{2i}\implies y_p(t)= (2i)^{-1} \left( \frac{e^{it}}{(i-1)^2} -\frac{e^{-it}}{(-i-1)^2}\right)= \frac{1}{4} [e^{it}+e^{-it}]$$ $$=\frac{1}{2} \cos t.$$
$y_h(t)$ remains the same as you found.
A: I am answering this based on my understanding from Elementary Differential Equations by Boyce and Diprima.
Consider a new differential equation
\begin{equation}\label{1}\tag{1}
\frac{d^{2}y}{dt^{2}}-2\frac{dy}{dt}+1=\left(\frac{d^{2}}{dt}-2\frac{d}{dt}+1\right)y=e^{it}.
\end{equation}
Let $y=e^{it}g(t)$. By the product rule
\begin{align*}
\frac{dy}{dt}=\frac{d}{dt}\left(e^{it}g(t)\right)=e^{it}\frac{d}{dt}g(t)+\left(\frac{d}{dt}e^{it}\right)g(t)=e^{it}\left(\frac{d}{dt}+i\right)g(t).
\end{align*}
Then the differential equation (1) becomes
\begin{align*}
e^{it}\left[\left(\frac{d}{dt}+i\right)^{2}-2\left(\frac{d}{dt}+i\right)+1\right]g(t)=e^{it}
\end{align*}
so that after cancelling $e^{it}$ from both sides and expanding the expression in parenthesis on the LHS
\begin{align*}
\left[\left(\frac{d}{dt}+i\right)^{2}-2\left(\frac{d}{dt}+i\right)+1\right]g(t)=\left(\frac{d^{2}}{dt^{2}}+(2i-2)\frac{d}{dt}-2i\right)g(t)=1
\end{align*}
so that $g(t)=c$ for some constant $c\in\mathbb{C}$. Therefore, $g(t)=i/2$. A particular solution of $y$ would then be
\begin{align*}
y=\frac{i}{2}e^{it}=\frac{i}{2}(\cos t+i\sin t).
\end{align*}
Since $\sin t={\rm Im}(e^{it})$, then a particular solution to 
\begin{equation}
\frac{d^{2}y}{dt^{2}}-2\frac{dy}{dt}+1=\left(\frac{d^{2}}{dt}-2\frac{d}{dt}+1\right)y_{p}=\sin t
\end{equation}
is $y_{p}={\rm Im}(y)={\rm Im}(\frac{i}{2}(\cos t+i\sin t))=\frac{1}{2}\cos t$.
