How to solve this ODE? For a certain problem, I am trying to solve the ODE
$$\ddot{z}(t) - \omega^2 z(t)  = f_0 \Big(e^{-i(\omega+\delta)t}+e^{-i(\omega-\delta)t}\Big)$$ where $\omega$ is a real and $\delta$ is close to zero. I am pretty clueless what to do here, any hint would be appreciated. 
 A: You can do by the method of variation of parameters.
Equivalently you can also directly do by the Green's function. The Green's function of the equation $$\frac{d^2z}{dt^2} - \omega^2 z = f_0 \left( e^{-i \left( \omega + \delta \right) } + e^{-i \left( \omega - \delta \right) }\right)$$ is $$G(t) = \frac{e^{\omega |t|}}{2 \omega}$$
A: This is just to tell you that there is a general formula to solve the EDO 
$$y''+ay'+by=f(t),\quad y(t_0)=y_0,\ y'(t_0)=y_1.$$ 
I'll try to derive the formula as naturally as possible (without claiming to prove anything). 
First put the above EDO in the form 
$$y''-(\alpha+\beta)\,y'+\alpha\,\beta\,y=f(t),$$ 
where $\alpha$ and $\beta$ are complex numbers. The remainder of the euclidean division of a polynomial $P(X)$ by $(X-\alpha)(X-\beta)$ is 
$$\begin{cases}\displaystyle P(\alpha)\ \frac{X-\beta}{\alpha-\beta} 
+P(\beta)\ \frac{X-\alpha}{\beta-\alpha}&\text{if }\alpha\not=\beta\\ \\ 
P(\alpha)+P'(\alpha)\ (X-\alpha)&\text{if }\alpha=\beta. 
\end{cases}$$ 
If you replace formally $P(X)$ by $e^{tX}$ in the above expressions, you get 
$$\begin{cases}\displaystyle e^{\alpha t}\ \frac{X-\beta}{\alpha-\beta} 
+e^{\beta t}\ \frac{X-\alpha}{\beta-\alpha}&\text{if }\alpha\not=\beta\\ \\ 
e^{\alpha t}+t\ e^{\alpha t}\ (X-\alpha)&\text{if }\alpha=\beta. 
\end{cases}$$ 
If you write this polynomial in the form $g_0(t)+g_1(t)\ X$, you get 
$$g_0(t)=\begin{cases}\displaystyle\frac{\alpha\,e^{\beta t}
-\beta\,e^{\alpha t}}{\alpha-\beta}&\text{if }\alpha\not=\beta\\ \\ 
(1-\alpha\,t)\,e^{\alpha t}&\text{if }\alpha=\beta, 
\end{cases}$$ 
$$g_1(t)=
\begin{cases}
\displaystyle\frac{e^{\alpha t}-e^{\beta t}}{\alpha-\beta}&\text{if }\alpha\not=\beta\\ \\ 
t\,e^{\alpha t}&\text{if }\alpha=\beta. 
\end{cases}$$ 
Let $\alpha,\beta,y_0,y_1$ be complex numbers, let $t_0$ be a point in some open interval $J$, and let $f:J\to\mathbb C$ be continuous. Then the solution to 
$$y''-(\alpha+\beta)\,y'+\alpha\,\beta\,y=f(t),\quad y(t_0)=y_0,\ y'(t_0)=y_1$$ 
is 
$$y(t)=y_0\ g_0(t-t_0)+y_1\ g_1(t-t_0)+\int_{t_0}^tg_1(t-x)\,f(x)\ dx.$$ 
EDIT. Here is the (unrequested) solution to the general order $n$ linear ODE with constant coefficients. 
Let $P$ be a degree $n>0$ monic complex polynomial in the indeterminate $X$, let $f$ be a continuous function on the real line, and let $y_0,\dots y_{n-1}$ be complex numbers. The solution to the ODE 
$$P(d/d t)\ y=f(t),\quad y^{(k)}(0)=y_k\quad(0\le k < n)$$ 
is 
$$y(t)=\sum_{k=0}^{n-1}\ y_k\ g_k(t)+\int_0^t g_{n-1}(t-x)\ f(x)\ d x,$$
where the functions $g_k(t)$ can be computed as follows. 
Put $P=\prod_{j=1}^r(X-\lambda_j)^{m(j)}$ and $Q:=\sum_{k=0}^ng_k(t)X^k$. Then $Q$ is obtained by solving, thanks to Taylor's Formula, the congruences 
$$Q\equiv E_j\quad\bmod\quad(X-\lambda_j)^{m(j)},$$
for $j=1,\dots,r$, where we have set 
$$E_j:=\exp(\lambda_jt)\ \sum_{r=0}^{m(j)-1}\ \frac{t^r}{r!}\ (X-\lambda_j)^r.$$
More precisely, we have 
$$Q=\sum_{j=1}^r\ T_j\left(E_j\ \frac{(X-\lambda_j)^{m(j)}}{P}\right)\frac{P}{(X-\lambda_j)^{m(j)}}\quad,$$
where $T_j$ means "degree $<m(j)$ Taylor polynomial at $X=\lambda_j$".
