Solving wave equation using Laplace transform I want to solve the following wave equation using Laplace transform in $t$:
\begin{align*}
\text{PDE: }\frac {\partial^{2}}{\partial t^{2}}u-c^{2}\frac {\partial^{2}}{\partial x^{2}}u=q(x)e^{i\omega_{0}t},\text{ }-\infty<x<\infty,\text{ }t>0
\end{align*}
\begin{align*}
\text{BC: }u(x,t)\to 0\text{ as }x\to \pm\infty,\text{ }t>0
\end{align*}
\begin{align*}
\text{IC: }u(x,0)=0,\text{ }-\infty<x<\infty,\text{ }\frac {\partial}{\partial t}u(x,t)\Big\vert_{t=0}=0,\text{ }-\infty<x<\infty
\end{align*}
$q(x)$ is a localized function (vanishes at infinities). $\omega_{0}$ is a real given forcing frequency.

Use Laplace transform in $t$, we find it more convenient to write $s=-i\omega$.
\begin{align*}
\mathcal {L}\left(u\right)=\tilde{u}(x,s)=U(x,\omega)=\int_{0}^{\infty}u(x,t)e^{i\omega t}\, dt\text{ if Re}(s)>0\text{ or Im}(\omega)>0,
\end{align*}
where $u(x,t)$ is assumed to be one-sided, i.e., $u=0$ for $t<0$.
\begin{align*}
\mathcal {L}\left(e^{i\omega_{0}t}\right)=\int_{0}^{\infty}e^{i\left(\omega+\omega_{0}\right)t}\, dt=\frac {1}{i\left(\omega+\omega_{0}\right)}e^{i\left(\omega+\omega_{0}\right)t}\Big\vert_{0}^{\infty}=-\frac {1}{i\left(\omega+\omega_{0}\right)}.
\end{align*}
The PDE becomes an ODE:
\begin{align*}
\frac {d^2}{dx^{2}}U+k^{2}U=\frac {q(x)}{ic^{2}\left(\omega+\omega_{0}\right)},\text{ }k=\frac {\omega}{c}.
\end{align*}
The solution of the above equation consists of homogeneous plus a particular solution, i.e., $U(x,\omega)=U_{1}+U_{2}+U_{p}$, where $U_{1}=Ae^{ikx}$ and $U_{2}=Be^{-ikx}$. $U_{p}$ can be determined from variation of parameters:
\begin{align*}
U_{p}&=U_{1}\int_{0}^{x}\frac {-U_{2}\cdot\left(\frac {q(s)}{ic^{2}(\omega+\omega_{0})}\right)}{W(U_{1},U_{2})}\, ds+U_{2}\int_{0}^{x}\frac {U_{1}\cdot\left(\frac {q(s)}{ic^{2}(\omega+\omega_{0})}\right)}{W(U_{1},U_{2})}\, ds\\
&=-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{0}^{x}e^{ik(x-s)}q(s)\, ds+\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{0}^{x}e^{-ik(x-s)}q(s)\, ds.
\end{align*}
Thus, we get
\begin{align*}
U(x,\omega)=\left[A-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{0}^{x}e^{-iks}q(s)\, ds\right]e^{ikx}+\left[B+\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{0}^{x}e^{iks}q(s)\, ds\right]e^{-ikx}.
\end{align*}
Because of the given boundary condition, we require that as $x\to \infty$, $U(x,\omega)\to 0$, i.e.,
\begin{align*}
B=-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{0}^{\infty}e^{iks}q(s)\, ds.
\end{align*}
Similarly, we require that as $x\to-\infty$, $U(x,\omega)\to 0$ as well, i.e.,
\begin{align*}
A=-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{-\infty}^{0}e^{-iks}q(s)\, ds.
\end{align*}
Therefore, we get
\begin{align*}
U(x,\omega)=-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{-\infty}^{\infty}q(s)e^{ik\lvert x-s\rvert}\, ds.
\end{align*}
Therefore, we get
\begin{align*}
U(x,\omega)=-\frac {1}{2kc^{2}(\omega+\omega_{0})}\int_{-\infty}^{\infty}q(y)e^{ik\lvert x-y\rvert}\, dy=-\frac {1}{2c\omega(\omega+\omega_{0})}\int_{-\infty}^{\infty}q(y)e^{i\omega\frac {\lvert x-y\rvert}{c}}\, dy.
\end{align*}
Then the true solution can be obtained through inverse Laplace transform. Therefore, we have
\begin{align*}
u(x,t)&=\frac {1}{2\pi}\int_{-\infty+i\alpha}^{+\infty+i\alpha}e^{-i\omega t}\cdot \left(-\frac {1}{2c\omega(\omega+\omega_{0})}\int_{-\infty}^{\infty}q(y)e^{i\omega\frac {\lvert x-y\rvert}{c}}\, dy\right)\, d\omega\\
&=\frac {1}{4\pi c}\int_{-\infty+i\alpha}^{+\infty+i\alpha}-\frac {1}{\omega(\omega+\omega_{0})}\left(\int_{-\infty}^{\infty}q(y)e^{i\omega\left(\frac {\lvert x-y\rvert}{c}-t\right)}\, dy\right)\, d\omega\\
&=-\frac {1}{4\pi c}\int_{-\infty}^{+\infty}q(y)\left(\int_{-\infty+i\alpha}^{+\infty+i\alpha}\frac {1}{\omega(\omega+\omega_{0})}e^{i\omega\left(\frac {\lvert x-y\rvert}{c}-t\right)}\, d\omega\right)\, dy.
\end{align*}
When $\frac {\lvert x-y\rvert}{c}-t>0$, we close in the upper half plane, which gives $0$ since there's no singularity. When $\frac {\lvert x-y\rvert}{c}-t<0$, we close in the lower half plane, which gives $-2\pi i\left[\text{Res}(\omega=-\omega_{0})+\text{Res}(\omega=0)\right]$. We have
\begin{align*}
\text{Res}\left(\omega=0\right)=\frac {1}{\omega_{0}}e^{i\cdot 0\cdot\left(\frac {\lvert x-y\rvert}{c}-t\right)}=\frac {1}{\omega_{0}}.
\end{align*}
\begin{align*}
\text{Res}\left(\omega=-\omega_{0}\right)=-\frac {1}{\omega_{0}}e^{-i\omega_{0}\left(\frac {\lvert x-y\rvert}{c}-t\right)}.
\end{align*}
Therefore, the solution is given by
\begin{align*}
u(x,t)&=-\frac {1}{4\pi c}\int_{-\infty}^{+\infty}q(y)H\left(t-\frac {\lvert x-y\rvert}{c}\right)\frac {2\pi i}{\omega_{0}}\left(e^{-i\omega_{0}\left(\frac {\lvert x-y\rvert}{c}-t\right)}-1\right)\, dy\\
&=-\frac {i}{2c\omega_{0}}\int_{-\infty}^{+\infty}q(y)H\left(t-\frac {\lvert x-y\rvert}{c}\right)\left(e^{-i\omega_{0}\left(\frac {\lvert x-y\rvert}{c}-t\right)}-1\right)\, dy,
\end{align*}
where $H$ is the Heaviside function.
