contour

Deriving the Green’s functions for the 1D wave equation.

October 13, 2025 math and physics play , , , , , , , , ,

[Click here for a PDF version of this (and previous) post]

Having had trouble verifying the 2D Green’s function, let’s try deriving them ourselves.

Setup.

Let’s try solving the forced wave equation
\begin{equation}\label{eqn:waveEquationGreens:860}
\lr{ \spacegrad^2 – \inv{c^2}\frac{\partial^2}{\partial t^2} } f(x,t) = g(x,t),
\end{equation}
using Fourier transform pairs
\begin{equation}\label{eqn:waveEquationGreens:880}
\begin{aligned}
F(\Bx, t) &= \inv{\lr{\sqrt{2 \pi}}^{N+1}} \int e^{j \Bk \cdot \Bx + j \omega t} \hat{F}(\Bk, \omega) d^N \Bk d\omega \\
\hat{F}(\Bk, \omega) &= \inv{\lr{\sqrt{2 \pi}}^{N+1}} \int e^{-j \Bk \cdot \Bx – j \omega t} F(\Bx, t) d^N \Bx dt.
\end{aligned}
\end{equation}
We can now transform \ref{eqn:waveEquationGreens:860}, expressing \(f, g\) in terms of their transforms
\begin{equation}\label{eqn:waveEquationGreens:900}
\lr{ \lr{ j \Bk}^2 – \lr{ j \omega }^2/c^2 } \hat{f} = \hat{g},
\end{equation}
or
\begin{equation}\label{eqn:waveEquationGreens:920}
\hat{f} = \frac{\hat{g}}{(\omega/c)^2 – \Bk^2},
\end{equation}
or
\begin{equation}\label{eqn:waveEquationGreens:940}
\begin{aligned}
f(\Bx, t)
&= \inv{\lr{\sqrt{2 \pi}}^{N+1}} \int e^{j \Bk \cdot \Bx + j \omega t} \frac{\hat{g}(\Bk, \omega)}{(\omega/c)^2 – \Bk^2} d^N \Bk d\omega \\
&= \inv{\lr{2 \pi}^{N+1}} \int e^{j \Bk \cdot \Bx + j \omega t} \frac{g(\Bx’, t’)}{(\omega/c)^2 – \Bk^2} d^N \Bk d\omega e^{-j \Bk \cdot \Bx’ – j \omega t’} d^N \Bx’ dt’ \\
&=
\int d^N \Bx’ dt’ g(\Bx’, t’) G(\Bx, \Bx’, t, t’),
\end{aligned}
\end{equation}
where
\begin{equation}\label{eqn:waveEquationGreens:960}
G(\Bx, \Bx’, t, t’)
=
\inv{\lr{2 \pi}^{N+1}} \int d^N \Bk d\omega \frac{e^{j \Bk \cdot (\Bx-\Bx’) + j \omega (t- t’)}}{(\omega/c)^2 – \Bk^2}.
\end{equation}

Evaluating the 1D Green’s function

For the 1D case we have
\begin{equation}\label{eqn:waveEquationGreens:980}
G(\Bx, \Bx’, t, t’)
=
\inv{\lr{2 \pi}^2} \int dk d\omega \frac{e^{j k (x-x’) + j \omega (t- t’)}}{(\omega/c)^2 – k^2}
\end{equation}
Let’s write \( u = x – x’ \), and \( \tau = t – t’ \), and displace the poles by an imaginary offset \( j \epsilon \)
\begin{equation}\label{eqn:waveEquationGreens:1000}
G_\epsilon(u, \tau)
=
-\inv{\lr{2 \pi}^2} \int dk d\omega \frac{e^{j k u + j \omega \tau }}{\lr{ k – \lr{ \omega/c + j \epsilon}}\lr{ k + \lr{ \omega/c + j \epsilon }}}.
\end{equation}

Let’s start by assuming that \( \epsilon > 0 \). When \( u > 0 \), we can use a upper half plane contour in the k-plane, enclosing \( \omega/c + j \epsilon \), to find
\begin{equation}\label{eqn:waveEquationGreens:1020}
\begin{aligned}
G_\epsilon(u, \tau)
&=
-\frac{2 \pi j}{\lr{2 \pi}^2} \int d\omega \evalbar{\frac{e^{j k u + j \omega \tau }}{k + \lr{ \omega/c + j \epsilon }}}{k = \omega/c + j \epsilon} \\
&=
\frac{1}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau + u/c)}}{\omega/c + j \epsilon }.
\end{aligned}
\end{equation}
However, for \( u < 0 \) we need the lower half plane contour that encloses \( -\omega/c - j \epsilon \). Our residue calculation is \begin{equation}\label{eqn:waveEquationGreens:1040} \begin{aligned} G_\epsilon(u, \tau) &= -\frac{-2 \pi j}{\lr{2 \pi}^2} \int d\omega \evalbar{\frac{e^{j k u + j \omega \tau }}{k - \lr{ \omega/c + j \epsilon }}}{k = -\omega/c - j \epsilon} \\ &= \frac{1}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau - u/c)}}{\omega/c + j \epsilon }. \end{aligned} \end{equation} Merging the two cases, we have \begin{equation}\label{eqn:waveEquationGreens:1060} \begin{aligned} G_\epsilon(u, \tau) &= \frac{1}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau + \Abs{u}/c)}}{\omega/c + j \epsilon } \\ &= \frac{c}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau + \Abs{u}/c)}}{\omega + j \epsilon c } \\ \end{aligned} \end{equation} This can be integrated in the \(\omega\)-plane, with the pole at \( -j \epsilon c \). For \( \tau + \Abs{u}/c > 0 \), we need an upper half plane infinite semicircular contour, but have no enclosed pole. For \( \tau + \Abs{u}/c < 0 \), we have \begin{equation}\label{eqn:waveEquationGreens:1080} \begin{aligned} G_\epsilon(u, \tau) &= \frac{c (-2 \pi j)}{4 \pi j} \evalbar{ e^{j \omega (\tau + \Abs{u}/c)}}{\omega = -j \epsilon c} \\ &= -\frac{c}{2}, \end{aligned} \end{equation} (in the limit.) Putting both pieces together, we have found the advanced Green's function for the 1D wave equation \begin{equation}\label{eqn:waveEquationGreens:1100} \boxed{ G(u, \tau) = -\frac{c}{2} \Theta(-\tau - \Abs{u}/c). } \end{equation} Having found the advanced solution with a positive pole displacement, it is reasonable to assume that we will get the retarded solution, with a negative pole displacement \( \epsilon < 0 \). This time, the upper half plane infinite semicircular contour encloses the \( -\omega/c -j \epsilon \) pole, and the lower half plane contour encloses the \( \omega/c + j \epsilon \) pole. This gives, us, for \( u > 0 \)
\begin{equation}\label{eqn:waveEquationGreens:1120}
\begin{aligned}
G_\epsilon(u, \tau)
&=
-\frac{2 \pi j}{\lr{2 \pi}^2} \int d\omega \evalbar{\frac{e^{j k u + j \omega \tau }}{k – \lr{ \omega/c + j \epsilon }}}{k = -\omega/c – j \epsilon} \\
&=
-\frac{1}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau – u/c)}}{\omega/c + j \epsilon } \\
&=
-\frac{c}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau – u/c)}}{\omega – (-j \epsilon c) } \\
&=
-\frac{2 \pi j c}{4 \pi j} \evalbar{e^{j \omega (\tau – u/c)}}{\omega = -j \epsilon c } \Theta(\tau – u/c) \\
&=
-\frac{c}{2} \Theta(\tau – u/c),
\end{aligned}
\end{equation}
and for \( u < 0 \) \begin{equation}\label{eqn:waveEquationGreens:1140} \begin{aligned} G_\epsilon(u, \tau) &= -\frac{-2 \pi j}{\lr{2 \pi}^2} \int d\omega \evalbar{\frac{e^{j k u + j \omega \tau }}{k + \lr{ \omega/c + j \epsilon }}}{k = \omega/c + j \epsilon} \\ &= \frac{1}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau + u/c)}}{\omega/c + j \epsilon } \\ &= \frac{c}{4 \pi j} \int d\omega \frac{e^{j \omega (\tau + u/c)}}{\omega - (-j \epsilon c) } \\ &= -\frac{-2 \pi j c}{4 \pi j} \evalbar{e^{j \omega (\tau + u/c)}}{\omega = -j \epsilon c } \Theta(\tau + u/c) \\ &= -\frac{c}{2} \Theta(\tau + u/c). \end{aligned} \end{equation} Combining the two cases, we've found the retarded solution \begin{equation}\label{eqn:waveEquationGreens:1160} \boxed{ G(u, \tau) = -\frac{c}{2} \Theta(\tau - \Abs{u}/c). } \end{equation} This matches Grok's claim (which we also verified.)

The convolution integrals.

Let’s write out the convolution integrals for fun. They are
\begin{equation}\label{eqn:waveEquationGreens:1180}
f(x,t) = -\frac{c}{2}
\int_{-\infty}^\infty dt’
\int_{-\infty}^\infty dx’
\Theta(\pm(t – t’) – \Abs{x – x’}/c) g(x’, t’).
\end{equation}

For the retarded case, we need only evaluate the step over the region
\begin{equation}\label{eqn:waveEquationGreens:1220}
t – t’ – \Abs{x – x’}/c > 0,
\end{equation}
or
\begin{equation}\label{eqn:waveEquationGreens:1240}
t – \Abs{x – x’}/c > t’.
\end{equation}
For the advanced case, we want the restriction
\begin{equation}\label{eqn:waveEquationGreens:1260}
-t + t’ – \Abs{x – x’}/c > 0,
\end{equation}
or
\begin{equation}\label{eqn:waveEquationGreens:1280}
t’ > t + \Abs{x – x’}/c,
\end{equation}
so the retarded convolution is
\begin{equation}\label{eqn:waveEquationGreens:1300}
f(x,t) = -\frac{c}{2}
\int_{-\infty}^\infty dx’
\int_{-\infty}^{t – \Abs{x – x’}/c} dt’
g(x’, t’),
\end{equation}
and the advanced convolution is
\begin{equation}\label{eqn:waveEquationGreens:1320}
f(x,t) = -\frac{c}{2}
\int_{-\infty}^\infty dx’
\int_{t + \Abs{x – x’}/c}^\infty dt’
g(x’, t’).
\end{equation}

TODO.

Next up will be an attempt to find the 2D Green’s function, and then for good measure, we should try to find the 3D case ourselves.

A generalized Gaussian integral.

July 26, 2025 math and physics play , , , , , , ,

[Click here for a PDF version of this post]

Here’s another problem from [1]. The point is to show that
\begin{equation}\label{eqn:generalizedGaussian:20}
G(x,x’,\tau) = \inv{2\pi} \int_{-\infty}^\infty e^{i k\lr{ x – x’ } } e^{-k^2 \tau} dk,
\end{equation}
has the value
\begin{equation}\label{eqn:generalizedGaussian:40}
G(x,x’,\tau) = \inv{\sqrt{4 \pi \tau} } e^{-\lr{ x – x’}^2/4 \tau },
\end{equation}
not just for real \(\tau\), but also for purely imaginary \(\tau\).

Real case.

The authors claim the real case is easy, but I don’t think the real case is that trivial. The trivial part is basically just completing the square. Writing \( x – x ‘ = \Delta x \), that is
\begin{equation}\label{eqn:generalizedGaussian:60}
\begin{aligned}
-k^2 \tau + i k\lr{ x – x’ }
&=
-\tau \lr{ k^2 – i k \Delta x/\tau } \\
&=
-\tau \lr{ \lr{ k – i \Delta x/2\tau }^2 – \lr{ – i \Delta x/2\tau }^2 } \\
&=
-\tau \lr{ \lr{ k – i \Delta x/2\tau }^2 + \lr{ \Delta x/2\tau }^2 }.
\end{aligned}
\end{equation}
So we have
\begin{equation}\label{eqn:generalizedGaussian:80}
G(x,x’,\tau) = \inv{2\pi} e^{-(\Delta x/2)^2/\tau} \int_{-\infty}^\infty e^{-\tau \lr{ k – i \Delta x/2\tau }^2 } dk.
\end{equation}
Let’s call the integral factor part of this \( I \)
\begin{equation}\label{eqn:generalizedGaussian:100}
I = \int_{-\infty}^\infty e^{-\tau \lr{ k – i \Delta x/2\tau }^2 } dk.
\end{equation}
However, making a change of variables makes this an integral over a complex path
\begin{equation}\label{eqn:generalizedGaussian:120}
I = \int_{-\infty – i \Delta x/2\tau }^{\infty – i \Delta x/2\tau} e^{-\tau k^2 } dk.
\end{equation}
If you are lazy you could say that \( \pm \infty \) adjusted by a constant, even if that constant is imaginary, leaves the integration limits unchanged. That’s clearly true if the constant is real, but I don’t think it’s that obvious if the constant is imaginary.

To answer that question more exactly, let’s consider the integral
\begin{equation}\label{eqn:generalizedGaussian:140}
0 = I + J + K + L = \oint e^{-\tau z^2} dz,
\end{equation}
where the path is illustrated in fig. 1.

fig. 1. Contour for the Gaussian.

Since there are no enclosed poles, we have
\begin{equation}\label{eqn:generalizedGaussian:160}
I = \int_{-\infty}^\infty e^{-\tau k^2 } dk + K + L,
\end{equation}
where
\begin{equation}\label{eqn:generalizedGaussian:180}
\begin{aligned}
K &= \int_{- i \Delta x/2\tau}^0 e^{-\tau z^2} dz \\
L &= \int_0^{- i \Delta x/2\tau} e^{-\tau z^2} dz.
\end{aligned}
\end{equation}
We see now that we see perfect cancellation of \( K \) and \( L \), which justifies the change of variables, and the corresponding integration limits.

We can use the usual trick to evaluate \( I^2 \), to find
\begin{equation}\label{eqn:generalizedGaussian:200}
\begin{aligned}
I^2
&=
\int_{-\infty}^\infty e^{-\tau k^2 } dk
\int_{-\infty}^\infty e^{-\tau m^2 } dm \\
&=
2 \pi \int_0^\infty r e^{-\tau r^2} r dr \\
&=
2 \pi \evalrange{ – \frac{e^{-\tau r^2}}{-2 \tau} }{0}{\infty} \\
&=
\frac{\pi}{\tau}.
\end{aligned}
\end{equation}

So, for real values of \( \tau \) we have
\begin{equation}\label{eqn:generalizedGaussian:220}
G(x,x’,\tau) = \inv{2\pi} \sqrt{\frac{\pi}{\tau}}e^{-(\Delta x/2)^2/\tau},
\end{equation}
as expected.

Imaginary case.

For the imaginary case, let \( \tau = i \alpha \). Let’s recomplete the square from scratch with this substitution
\begin{equation}\label{eqn:generalizedGaussian:240}
\begin{aligned}
-k^2 i \alpha + i k \Delta x
&=
– i \alpha \lr{ k^2 – \frac{i k \Delta x}{i \alpha} } \\
&=
– i \alpha \lr{ k^2 – \frac{k \Delta x}{\alpha} } \\
&=
– i \alpha \lr{ \lr{ k – \frac{\Delta x}{2 \alpha} }^2 – \lr{ \frac{\Delta x}{2 \alpha} }^2 }.
\end{aligned}
\end{equation}
So we have
\begin{equation}\label{eqn:generalizedGaussian:260}
\begin{aligned}
G(x,x’,\tau)
&= \inv{2\pi} e^{i \alpha(\Delta x/2\alpha)^2} \int_{-\infty}^\infty e^{- i \alpha \lr{ k – \frac{\Delta x}{2 \alpha } }^2 } dk \\
&= \inv{\sqrt{\pi^2 \alpha}} e^{- (\Delta x)^2/4\tau} \int_0^\infty e^{- i m^2 } dm.
\end{aligned}
\end{equation}
This time we can make a \( m = \sqrt{\alpha} \lr{k – \frac{\Delta x}{2 \alpha }} \) change of variables, but don’t have to worry about imaginary displacements of the integration limits.

The task is now reduced to the evaluation of an imaginary Gaussian like integral, and we are given the hint integrate \( e^{-z^2} \) over a pie shaped contour fig. 2.

fig. 2. Pie shaped integration contour.

Over \( I \) we set \( z = x, x \in [0, R] \), over \( J \), we set \( z = R e^{i\theta}, \theta \in [0, \pi/4] \), and on \( K \) we set \( z = u e^{i\pi/4}, u \in [R, 0] \). Since there are no enclosed poles we have
\begin{equation}\label{eqn:generalizedGaussian:280}
\begin{aligned}
0 &= I + J + K \\
&= \int_0^R e^{- x^2} dx + \int_0^{\pi/4} e^{-R^2 e^{2 i \theta} } i R e^{i\theta} d\theta – \int_0^R e^{-i u^2 } e^{i \pi/4} du.
\end{aligned}
\end{equation}
In the limit we have
\begin{equation}\label{eqn:generalizedGaussian:300}
\begin{aligned}
\int_0^\infty e^{-i u^2 } du
&= e^{-i\pi/4} \int_0^\infty e^{- x^2} dx + L \\
&= e^{-i\pi/4} \sqrt{\pi}/2 + L,
\end{aligned}
\end{equation}
where
\begin{equation}\label{eqn:generalizedGaussian:320}
L = \lim_{R\rightarrow \infty} e^{-i\pi/4} \int_0^{\pi/4} e^{-R^2 e^{2 i \theta} } i R e^{i\theta} d\theta.
\end{equation}
We hope that this is zero in the limit, but showing this requires a bit of care around the \( \pi/4 \) endpoint. We start with
\begin{equation}\label{eqn:generalizedGaussian:340}
\begin{aligned}
\Abs{L}
&\le \lim_{R\rightarrow \infty} \int_0^{\pi/4} R e^{-R^2 \cos\lr{2 \theta} } d\theta \\
&= \lim_{R\rightarrow \infty} \inv{2} \int_{\pi/4 – \epsilon/2}^{\pi/4} R e^{-R^2 \cos\lr{2 \theta} } (2 d\theta),
\end{aligned}
\end{equation}
Now we make a change of variables
\begin{equation}\label{eqn:generalizedGaussian:360}
t = \frac{\pi}{2} – 2 \theta.
\end{equation}
At the limits we have
\begin{equation}\label{eqn:generalizedGaussian:380}
\begin{aligned}
t(\pi/4 – \epsilon/2) &= \epsilon \\
t(\pi/4) &= 0.
\end{aligned}
\end{equation}
Also,
\begin{equation}\label{eqn:generalizedGaussian:400}
\begin{aligned}
\cos\lr{ 2 \theta }
&= \textrm{Re} \lr{ e^{2 i \theta} } \\
&= \textrm{Re} \lr{ e^{i \lr{\pi/2 – t} } } \\
&= \textrm{Re} \lr{ i e^{-i t } } \\
&= \sin t,
\end{aligned}
\end{equation}
so
\begin{equation}\label{eqn:generalizedGaussian:420}
\Abs{L} \le \lim_{R\rightarrow \infty} \inv{2} \int_0^\epsilon R e^{-R^2 \sin t} dt.
\end{equation}
Since we have forced \( t \) small, we can use the small angle approximation for the sine
\begin{equation}\label{eqn:generalizedGaussian:440}
\begin{aligned}
\int_0^\epsilon R e^{-R^2 \sin t} dt
&\approx
\int_0^\epsilon R e^{-R^2 t} dt \\
&= \evalrange{ \inv{-2 R} e^{-R^2 t} }{0}{\epsilon} \\
&= \frac{ 1 – e^{-R^2 \epsilon }}{2 R}.
\end{aligned}
\end{equation}
The numerator goes to zero for either \( \epsilon \rightarrow 0 \), or \( R \rightarrow \infty \), and the denominator to infinity, so we have the desired zero in the limit. This means that
\begin{equation}\label{eqn:generalizedGaussian:460}
\begin{aligned}
G(x,x’,\tau)
&= \frac{e^{-i\pi/4}}{\sqrt{4 \pi \alpha}} e^{- (\Delta x)^2/4\tau} \\
&= \frac{1}{\sqrt{4 \pi i \alpha}} e^{- (\Delta x)^2/4\tau} \\
&= \frac{1}{\sqrt{4 \pi \tau}} e^{- (\Delta x)^2/4\tau},
\end{aligned}
\end{equation}
as expected.

A fun application, also noted in the problem, is that we can decompose the imaginary integral
\begin{equation}\label{eqn:generalizedGaussian:480}
\int_{-\infty}^\infty e^{-i u^2} du = \sqrt{\pi} e^{-i\pi/4},
\end{equation}
into real and imaginary parts, to find
\begin{equation}\label{eqn:generalizedGaussian:500}
\int_{-\infty}^\infty \cos u^2 du = \int_{-\infty}^\infty \sin u^2 du = \sqrt{\frac{\pi}{2}}.
\end{equation}
Despite being real valued integrals, it it not at all obvious how one would go about finding those without these contour integration tricks.

References

[1] F.W. Byron and R.W. Fuller. Mathematics of Classical and Quantum Physics. Dover Publications, 1992.