How to solve a second order ODE with Dirac delta inhomogeneity? I am working with the following second order ODE
\begin{equation}
y''(x) - q² y(x) = F \delta(x - x_0)
\end{equation}
on the domain $-L/2$ to $+L/2$ without specifying any boundary conditions for now. The solution to this problem I found in the literature is
\begin{equation}
y(x) = A \cosh(qx) + B \sinh(qx) + \frac{F}{2q} e^{q|x-x_0|} .
\end{equation}
However, I can not reconstruct this result. I am not sure how to split the solution into two parts before and after the Dirac spike.
Here is how far I have come:
The solution to the homogeneous equation can be obtained from the Ansatz
\begin{equation}
y(x) = A e^{-qx} + B e^{qx} .
\end{equation}
For the non-homogeneous equation I try variation of parameters starting from
\begin{equation}
y(x) = C(x) e^{-qx} + D(x) e^{qx} .
\end{equation}
Plugging this Ansatz into the ODE and introducing the constrain $C'(x) e^{-qx} + D'(x) e^{qx} = 0$ allows me to solve for the coefficients $C'(x)$ and $D'(x)$
\begin{equation}
C'(x) = - \frac{F}{2q} \delta(x - x_0) e^{qx} \quad \text{and} \quad D'(x) = \frac{F}{2q} \delta(x - x_0) e^{-qx} .
\end{equation}
Integrating these equations then gives
\begin{equation}
C(x_0) = - \frac{F}{2q} e^{qx_0} \quad \text{and} \quad D(x_0) = \frac{F}{2q} e^{-qx_0},
\end{equation}
which do not depend on $x$ anymore, but only $x_0$. This can now be used to obtain the full solution to the ODE
\begin{equation}
y(x) = A e^{-qx} + B e^{qx} + \frac{F}{2q} \left( e^{q(x - x_0)} - e^{q(x_0 - x)} \right) .
\end{equation}
I think the homogeneous part of mine is somewhat similar to the solution from the literature. I am more concerned what I missed in constructing the last term. Does anyone have any ideas on this?
 A: Fourier transform is the most common way of dealing with a delta source :
$$
-k^2\hat{y}(k)-q^2\hat{y}(k)=F \verb+ +\Rightarrow\verb+ + \hat{y}(k) = -\frac{F}{k^2+q^2}
$$
and the inverse transform gives the desired result.

If you want to use the variation of parameters, note that when integrating $C'(x)$ :
$$
\begin{array}{rcl}
C(x)-C(-L/2) 
   &=& \displaystyle
    -\frac{F}{2q}\int_{-L/2}^xe^{qx'}\delta(x'-x_0)\,\mathrm{d}x' \\
   &\equiv& \displaystyle 
   -\frac{F}{2q}e^{qx_0}\int_{-L/2}^x\delta(x'-x_0)\,\mathrm{d}x' \\
   &=& \displaystyle 
   -\frac{F}{2q}e^{qx_0}(H(x-x_0)-H(-L/2-x_0))
\end{array}
$$
where $H = \delta'$ is the Heaviside function. The constant of integration $C(-L/2)$ can be assumed to be zero. Note that $H(-L/2-x_0) = 0$ since $-L/2 < x_0$. After calculating $D(x)$ in the same manner, you find the particular solution to be
$$
\begin{array}{rcl}
y_P(x) 
   &=& \displaystyle
   -\frac{F}{2q}e^{qx_0}H(x-x_0) \cdot e^{-qx} + \frac{F}{2q}e^{-qx_0}H(x-x_0) \cdot e^{qx} \\
   &=& \displaystyle
   \frac{F}{2q}\left(e^{q(x-x_0)}-e^{-q(x-x_0)}\right)H(x-x_0) \\
   &=& \displaystyle
   \frac{F}{q}\sinh(q(x-x_0))H(x-x_0)
\end{array}
$$
which is the required result.
