| 1 |
% -*- mode: noweb; noweb-default-code-mode: R-mode; -*- |
| 2 |
\documentclass[nojss]{jss} |
| 3 |
|
| 4 |
\usepackage{dsfont} |
| 5 |
\usepackage{bbm} |
| 6 |
\usepackage{amsfonts} |
| 7 |
\usepackage{amsmath} |
| 8 |
\usepackage{amssymb} |
| 9 |
\usepackage{wasysym} |
| 10 |
\usepackage{wrapfig} |
| 11 |
\usepackage{tikz} |
| 12 |
\usetikzlibrary{calc,decorations.markings} |
| 13 |
|
| 14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 15 |
%% declarations for jss.cls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 17 |
|
| 18 |
|
| 19 |
%% just as usual |
| 20 |
\author{Robin K. S. Hankin} |
| 21 |
\title{Cauchy's integral theorem: a numerical perspective} |
| 22 |
%\VignetteIndexEntry{The residue theorem from a numerical perspective} |
| 23 |
%% for pretty printing and a nice hypersummary also set: |
| 24 |
%% \Plainauthor{Achim Zeileis, Second Author} %% comma-separated |
| 25 |
\Plaintitle{The residue theorem from a numerical perspective} |
| 26 |
|
| 27 |
|
| 28 |
%% for pretty printing and a nice hypersummary also set: |
| 29 |
\Plainauthor{Robin K. S. Hankin} |
| 30 |
|
| 31 |
%% an abstract and keywords |
| 32 |
|
| 33 |
\Abstract{Here I use the {\tt myintegrate()} function of the |
| 34 |
\pkg{elliptic} package to illustrate three classical theorems from |
| 35 |
analysis: Cauchy's integral theorem, the residue theorem, and |
| 36 |
Cauchy's integral formula. In all cases, numerical values agree |
| 37 |
with analytical results to within numerical precision. Some further |
| 38 |
work is suggested. |
| 39 |
} |
| 40 |
|
| 41 |
\Keywords{Residue theorem, Cauchy formula, Cauchy's integral formula, |
| 42 |
contour integration, complex integration, Cauchy's theorem} |
| 43 |
|
| 44 |
|
| 45 |
\Keywords{Elliptic functions, residue theorem, numerical integration, \proglang{R}} |
| 46 |
\Plainkeywords{Elliptic functions, residue theorem, numerical integration, R} |
| 47 |
|
| 48 |
%% publication information |
| 49 |
%% NOTE: This needs to filled out ONLY IF THE PAPER WAS ACCEPTED. |
| 50 |
%% If it was not (yet) accepted, leave them commented. |
| 51 |
\Volume{0} |
| 52 |
\Issue{0} |
| 53 |
% \Month{MONTH} |
| 54 |
\Year{0000} |
| 55 |
\Submitdate{0000-00-00} |
| 56 |
\Acceptdate{0000-00-00} |
| 57 |
%% \Repository{https://github.com/RobinHankin/elliptic} |
| 58 |
|
| 59 |
%% The address of (at least) one author should be given |
| 60 |
%% in the following format: |
| 61 |
\Address{ |
| 62 |
Robin K. S. Hankin\\ |
| 63 |
University of Stirling\\ |
| 64 |
Scotland\\ |
| 65 |
email: \email{[email protected]} |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
%% It is also possible to add a telephone and fax number |
| 70 |
%% before the e-mail in the following format: |
| 71 |
%% Telephone: +43/1/31336-5053 |
| 72 |
%% Fax: +43/1/31336-734 |
| 73 |
|
| 74 |
%% for those who use Sweave please include the following line (with % symbols): |
| 75 |
%% need no \usepackage{Sweave.sty} |
| 76 |
|
| 77 |
%% end of declarations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 78 |
|
| 79 |
\begin{document} |
| 80 |
|
| 81 |
<<requirepackage,echo=FALSE,print=FALSE>>= |
| 82 |
require(elliptic,quietly=TRUE) |
| 83 |
@ |
| 84 |
|
| 85 |
\setlength{\intextsep}{0pt} |
| 86 |
\begin{wrapfigure}{r}{0.2\textwidth} |
| 87 |
\begin{center} |
| 88 |
\includegraphics[width=1in]{\Sexpr{system.file("help/figures/elliptic.png",package="elliptic")}} |
| 89 |
\end{center} |
| 90 |
\end{wrapfigure} |
| 91 |
|
| 92 |
\section{Introduction} |
| 93 |
|
| 94 |
Cauchy's integral theorem and its corollaries are some of the most |
| 95 |
startling and fruitful ideas in the whole of mathematics. They place |
| 96 |
powerful constraints on analytical functions; and show that a |
| 97 |
function's local behaviour dictates its global properties. |
| 98 |
Cauchy's integral theorem may be used to prove the residue theorem and |
| 99 |
Cauchy's integral formula; these three theorems form a powerful and |
| 100 |
cohesive suite of results. |
| 101 |
|
| 102 |
In this short document I use numerical methods to illustrate and |
| 103 |
highlight some of their consequences for complex analysis. |
| 104 |
|
| 105 |
\subsection{Cauchy's integral theorem} |
| 106 |
|
| 107 |
Augustin-Louis Cauchy proved an early version of the integral theorem |
| 108 |
in 1814; it required that the function's derivative was continuous. |
| 109 |
This assumption was removed in 1900 by \'Edouard Goursat at the |
| 110 |
expense of a more difficult proof; the result is sometimes known as |
| 111 |
the Cauchy-Goursat theorem and is now a cornerstone of complex analysis. |
| 112 |
Formally, in modern notation, we have: |
| 113 |
|
| 114 |
\noindent {\bf Cauchy's integral theorem}. If $f(z)$ is holomorphic |
| 115 |
in a simply connected domain $\Omega\subset\mathbb{C}$, then for any |
| 116 |
closed contour $C$ in $\Omega$, |
| 117 |
|
| 118 |
$$\int_{C}f(z)\,dz=0.$$ |
| 119 |
\\ |
| 120 |
|
| 121 |
To demonstrate this theorem numerically, I will use the integration |
| 122 |
suite of functions provided with the \pkg{elliptic} package which |
| 123 |
perform complex integration of a function along a path specified |
| 124 |
either as a sequence of segments [{\tt integrate.segments()}] or a |
| 125 |
curve [{\tt integrate.contour()}]. |
| 126 |
|
| 127 |
Let us consider $f(z)=\exp z$, holomorphic over all of $\mathbb{C}$, |
| 128 |
and evaluate |
| 129 |
|
| 130 |
$$\oint_C f(z)\,dz$$ |
| 131 |
|
| 132 |
where $C$ is the square $0\longrightarrow 1\longrightarrow |
| 133 |
1+i\longrightarrow i\longrightarrow 0$ (figure~\ref{square}). Numerically: |
| 134 |
|
| 135 |
\begin{figure}\centering |
| 136 |
\begin{tikzpicture} |
| 137 |
% Axes |
| 138 |
\draw [help lines,->] (-1, 0) -- (2, 0); |
| 139 |
\draw [help lines,->] ( 0, -1) -- (0, 2); |
| 140 |
% Red path |
| 141 |
|
| 142 |
\begin{scope}[very thick,decoration={ |
| 143 |
markings, |
| 144 |
mark=at position 0.5 with {\arrow{>}}} |
| 145 |
] |
| 146 |
\draw[red,postaction={decorate}] (0,0)--(1,0) node[black, midway, below]{\tiny A}; |
| 147 |
\draw[red,postaction={decorate}] (1,0)--(1,1) node[black, midway, right]{\tiny B}; |
| 148 |
\draw[red,postaction={decorate}] (1,1)--(0,1) node[black, midway, above]{\tiny C}; |
| 149 |
\draw[red,postaction={decorate}] (0,1)--(0,0) node[black, midway, left]{\tiny D}; |
| 150 |
\end{scope} |
| 151 |
% The labels |
| 152 |
\node at ( 1.70, -0.2){$x$ }; |
| 153 |
\node at (-0.24, 1.7){$iy$}; |
| 154 |
|
| 155 |
\end{tikzpicture} |
| 156 |
\caption{A square contour integral \label{square} on the complex plane} |
| 157 |
\end{figure} |
| 158 |
|
| 159 |
<<>>= |
| 160 |
integrate.segments(exp, c(0, 1, 1+1i, 1i), close=TRUE) |
| 161 |
@ |
| 162 |
|
| 163 |
Above we see that the result is zero (to within numerical precision), |
| 164 |
in agreement with the integral theorem. It is interesting to consider |
| 165 |
each leg separately. We have |
| 166 |
|
| 167 |
$$ |
| 168 |
A=e-1\qquad B=e(e^i-1)\qquad C=-e^i(e-1)\qquad D=-(e^i-1) |
| 169 |
$$ |
| 170 |
|
| 171 |
And taking B as an example: |
| 172 |
|
| 173 |
<<>>= |
| 174 |
analytic <- exp(1)*(exp(1i)-1) |
| 175 |
numeric <- integrate.segments(exp, c(1, 1+1i), close=FALSE) |
| 176 |
c(analytic=analytic, numeric=numeric, difference=analytic-numeric) |
| 177 |
@ |
| 178 |
|
| 179 |
showing agreement to within numerical precision. |
| 180 |
|
| 181 |
\subsection{The residue theorem} |
| 182 |
|
| 183 |
{\bf residue theorem}. Given $U$, a simply connected open subset of |
| 184 |
$\mathbb{C}$, and a finite list of points $a_1,\ldots,a_n$. |
| 185 |
Suppose $f(z)$ is holomorphic on $U_0=U\setminus\left\lbrace |
| 186 |
a_1,\ldots a_n\right\rbrace$ and $\gamma$ is a closed rectifiable |
| 187 |
curve in $U_0$. Then |
| 188 |
|
| 189 |
$$\oint_\gamma f(z)\,dz = 2\pi i\sum_{k=1}^n |
| 190 |
\operatorname{I}(\gamma,a_k)\cdot\operatorname{Res}(f,a_k)$$ |
| 191 |
|
| 192 |
where $\operatorname{I}(\gamma,a_k)$ is the winding number of $\gamma$ |
| 193 |
about $a_k$ and $\operatorname{Res}(f,a_k)$ is the residue of $f$ at |
| 194 |
$a_k$. \\ |
| 195 |
|
| 196 |
The canonical, and simplest, application of this is to derive the log |
| 197 |
function by integrating $f(z)=1/z$ along the unit circle, as per |
| 198 |
figure \ref{circular}. Here the residue at the origin is 1, so the |
| 199 |
integral round the unit circle is, analytically, $2\pi i$. |
| 200 |
Numerically: |
| 201 |
|
| 202 |
<<>>= |
| 203 |
u <- function(x){exp(pi*2i*x)} |
| 204 |
udash <- function(x){pi*2i * exp(pi*2i*x)} |
| 205 |
|
| 206 |
analytic <- pi*2i |
| 207 |
numeric <- integrate.contour(function(z){1/z}, u, udash) |
| 208 |
c(analytic=analytic, numeric=numeric, difference=analytic-numeric) |
| 209 |
@ |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
\begin{figure}\centering |
| 214 |
\begin{tikzpicture} |
| 215 |
% Axes |
| 216 |
\draw [help lines,->] (-2, 0) -- (2, 0); |
| 217 |
\draw [help lines,->] ( 0, -2) -- (0, 2); |
| 218 |
|
| 219 |
% Red path |
| 220 |
|
| 221 |
\draw [ |
| 222 |
decoration = {markings, mark = at position 0 with {\arrow{>}}}, |
| 223 |
postaction = {decorate}, |
| 224 |
very thick, red] (0,0) circle (1cm); |
| 225 |
|
| 226 |
% The labels |
| 227 |
\node at ( 1.70, -0.2){$x$ }; |
| 228 |
\node at (-0.24, 1.7){$iy$}; |
| 229 |
|
| 230 |
\end{tikzpicture} |
| 231 |
\caption{A circular contour integral \label{circular} on the complex plane} |
| 232 |
\end{figure} |
| 233 |
|
| 234 |
|
| 235 |
again we see very close agreement. |
| 236 |
|
| 237 |
\subsection{Cauchy's integral formula} |
| 238 |
|
| 239 |
{\bf Cauchy's integral formula}. If $f(z)$ is analytic within and on |
| 240 |
a simple closed curve $C$ (assumed to be oriented anticlockwise) |
| 241 |
inside a simply-connected domain, and if $z_0$ is any point inside |
| 242 |
$C$, then |
| 243 |
|
| 244 |
$$f(z_0)=\frac{1}{2\pi i}\int_C\frac{f(z)\,dz}{z-z_0}.$$ |
| 245 |
|
| 246 |
|
| 247 |
We may use this to evaluate the Gauss hypergeometric function at a |
| 248 |
critical point. The Gauss hypergeometric function ${}_2F_1(a,b;c;z)$ |
| 249 |
is defined as |
| 250 |
|
| 251 |
$$1+\frac{ab}{c}\frac{z}{1!} + \frac{a(a+1)b(b+1)}{c(c+1)}\frac{z^2}{2!}+\cdots$$ |
| 252 |
|
| 253 |
Now, this series has a radius of convergence of |
| 254 |
1~\citep{abramowitz1965}; but the function is defined over the whole |
| 255 |
complex plane by analytic continuation~\citep{buhring1987}. The |
| 256 |
\pkg{hypergeo} package~\citep{hankin2015} evaluates ${}_2F_1(a,b;c;z)$ |
| 257 |
for different values of $z$ by applying a sequence of transformations |
| 258 |
to reduce $\left|z\right|$ to its minimum value; however, this process |
| 259 |
is ineffective for $z=\frac{1}{2}\pm i\sqrt{3}/2$, these points |
| 260 |
transforming to themselves. Numerically: |
| 261 |
|
| 262 |
<<showhypergeofail>>= |
| 263 |
library("hypergeo") |
| 264 |
z0 <- 1/2 + sqrt(3)/2i |
| 265 |
f <- function(z){hypergeo_powerseries(1/2, 1/3, 1/5, z)} |
| 266 |
f(z0) |
| 267 |
@ |
| 268 |
|
| 269 |
Above we see {\tt NA}, signifying failure to converge. However, the |
| 270 |
residue theorem may be used to evaluate ${}_2F_1$ at this point: |
| 271 |
|
| 272 |
<<>>= |
| 273 |
r <- 0.1 # radius of contour |
| 274 |
u <- function(x){z0 + r*exp(pi * 2i * x)} |
| 275 |
udash <- function(x){r * pi * (0+2i) * exp(pi * 2i * x)} |
| 276 |
(val_residue <- integrate.contour(function(z){f(z) / (z-z0)}, u, udash) / (pi*2i)) |
| 277 |
@ |
| 278 |
|
| 279 |
We can compare this value with that obtained by a more sophisticated |
| 280 |
[and computationally expensive] method, that of |
| 281 |
Gosper~\citep{hankin2015}: |
| 282 |
|
| 283 |
<<>>= |
| 284 |
(val_gosper <- hypergeo_gosper(1/2, 1/3, 1/5, z0)) |
| 285 |
abs(val_gosper - val_residue) |
| 286 |
@ |
| 287 |
|
| 288 |
Above we see reasonable numerical agreement. |
| 289 |
|
| 290 |
|
| 291 |
\section{Conclusions} |
| 292 |
|
| 293 |
The \pkg{elliptic} package includes a suite of functionality for |
| 294 |
complex integration using numerical methods and these are used to |
| 295 |
demonstrate Cauchy's integral theorem, the residue theorem, and |
| 296 |
Cauchy's integral formula. Numerical errors are generally small. |
| 297 |
|
| 298 |
\bibliography{elliptic} |
| 299 |
\end{document} |