Complex methods

By Max Kapur. Updated Apr. 18, 2020.

Principal reference: Y. D. Chong, Complex Methods for the Sciences.

In [93]:
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import quad

Contour integration example

Problem 8.3 is to calculate

$$I = \int_{-\infty}^\infty \frac {dx}{x^4 +1}$$

Making an analytic continuation, we see that

$$\int_\Gamma \frac {dz}{z^4 +1} = I + \int_\text{arc} \frac {dz}{z^4 +1}$$

where the arc is a semicircle about the origin in the upper complex halfplane. $\frac {1}{z^4 +1}$ tends to zero as $z \to \infty$, and the arc term is zero by Jordan’s lemma.

We evaluate the contour integral on the left using Cauchy’s integral theorem. Notice that

$$\begin{align} \frac {1}{z^4 +1} & = \frac{1}{ \left[z- \frac{\left(\sqrt{2}+ i\sqrt{2}\right)}{2}\right] \left[z- \frac{\left(-\sqrt{2}+ i\sqrt{2}\right)}{2}\right] \left[z- \frac{\left(-\sqrt{2}- i\sqrt{2}\right)}{2}\right] \left[z- \frac{\left(\sqrt{2} - i\sqrt{2}\right)}{2}\right]} \\ & = \frac{1}{ \left[z- e^{i\pi/4}\right] \left[z- e^{3i\pi/4}\right] \left[z+ e^{i\pi/4}\right] \left[z+ e^{3i\pi/4}\right]} \\ & = \frac{1}{ \left[z- z_1\right] \left[z- z_2\right] \left[z- z_3\right] \left[z- z_4\right]} \end{align}$$

where the four terms in the denominator correspond to the four complex fourth roots of $-1$. Those singular points, along with the contour we’ve chosen, are shown below.

In [90]:
fig, ax = plt.subplots(1,1, figsize = (12,7))

z = np.array([np.sqrt(.5) * (1+1j),np.sqrt(.5) *(-1+1j),np.sqrt(.5) *(-1-1j),np.sqrt(.5) * (1-1j)])
ax.scatter(z.real, z.imag)
for i, w in enumerate(z):
    ax.annotate(r'$z_{{{}}}$'.format(i+1),[ w.real+.1, w.imag], va = 'center')
    
curve = np.array([-5, 0])
curve = np.vstack([curve,np.array([[5*np.cos(t), 5*np.sin(t)] for t in np.linspace(0,np.pi, 50)])])
ax.plot(*curve.T, color='crimson')
ax.arrow(0,0,1e-5,0,head_width=(.2), ec=None, fc = 'crimson', lw=0)
ax.arrow(0,5,-1e-5,0,head_width=(.2), ec=None, fc = 'crimson', lw=0)

ax.axhline(0, color = 'black', lw=.5), ax.axvline(0, color = 'black', lw=.5)
ax.set_xlim(-5.5, 5.5), ax.set_ylim(-1.5, 5.5)
ax.set_xlabel('real'), ax.set_ylabel('imaginary')
ax.set_xticks([]), ax.set_yticks([])
Out[90]:
([], [])

The area enclosed by the contour is analytic everywhere except at the points $z_1$ and $z_2$. By Cauchy’s integral theorem,

$$\begin{align} \int_\Gamma \frac {dz}{z^4 +1} = I & = 2\pi i \Biggl( \text{Res}\bigl[f(z_1)\bigr]_{z=z_1} + \text{Res}\bigl[f(z_2)\bigr]_{z=z_2} \Biggr) \\ & = 2\pi i \Biggl( \Bigl[ \frac{1}{ \left(z- e^{3i\pi/4}\right) \left(z+ e^{i\pi/4}\right) \left(z+ e^{3i\pi/4}\right)} \Bigr]_{z=e^{t\pi /4}} + \Bigl[ \frac{1}{ \left(z- e^{i\pi/4}\right) \left(z+ e^{i\pi/4}\right) \left(z+ e^{3i\pi/4}\right)} \Bigr]_{z=e^{t\pi /4}} \Biggr) \\ & = 2\pi i \Biggl( \frac{1}{ \left(\sqrt{2}e^0\right) \left(2e^{i\pi/4}\right) \left(\sqrt{2}e^{i\pi/2}\right)} + \frac{1}{ \left(-\sqrt{2}e^0\right) \left(2e^{3i\pi/4}\right) \left(\sqrt{2}e^{i\pi/2}\right)} \Biggr) \\ & = 2\pi i \Biggl( \frac{1}{4 e^{i\pi /4} e^{i\pi /2}} - \frac{1}{4 e^{3i\pi /4} e^{i\pi /2}} \Biggr) \\ & = \frac{1}{2}\pi i \bigl(e^{i\pi /4} - e^{3i\pi /4} \bigr)e^{-i\pi /2} \\ & = \frac{1}{2}\pi i \left(\sqrt{2} \right)e^{-i\pi /2} \\ & = \frac{\pi}{\sqrt{2}}e^{i\pi/2 - i\pi/2} \\ & = \frac{\pi}{\sqrt{2}} \approx 2.221 \end{align}$$

Check:

In [94]:
def f(x): return 1 /(x**4 +1)
quad(f, -np.inf, np.inf)
Out[94]:
(2.2214414690791835, 4.477661903466016e-09)
In [95]:
!jupyter nbconvert complex.ipynb
[NbConvertApp] Converting notebook complex.ipynb to html
[NbConvertApp] Writing 309238 bytes to complex.html