﻿ Vector, the Journal of the British APL Association

## Volumes

British APL Association

Archive articles posted online on request: ask the archivist.

Volume 24, No.1

• Proof for author
• 0.2

# by William R. Jones & Cliff Reiter (jonesw@lafayette.edu and reiterc@lafayette.edu)

Abstract Cauchy’s Integral theorem guarantees that certain complex integrals along closed paths are zero. This means that the intermediate values of ‘partial path integrals’ themselves form paths. We explore the marvelous variety of curves that arise this way using J’s excellent facilities for complex arithmetic and plotting.

## Introduction

A.L. Cauchy (1789-1857) was the founder of complex integration theory. He made hundreds of contributions to various branches of mathematics and mathematical physics. A brief biography of Cauchy may be found in [1,2] and a detailed discussion of his mathematical work on complex functions appears in . Some modern books on complex analysis include [3,7]

His theorem called the Cauchy Integral Theorem tells us that the integral of a well-behaved complex function around a well-behaved closed path in the complex plane is zero. Such integrals are called ‘path integrals’ and we write the conclusion of the theorem as follows. A closed path begins and ends at the same point. Here the closed path is well-behaved if it is a loop around some region in the complex plane and it should be ‘rectifiable’ (have a sense of length). Suffice it to say circles, ellipses, and squares are well-behaved, but a Koch snowflake  is not (it has fractal dimension, not a finite length). Here well-behaved functions are analytic on and inside of the closed path. Suffice it to say that polynomials, the sine, cosine and the exponential are well-behaved (analytic everywhere). Even rational functions are well-behaved so long as the zeros of their denominators do not appear on or inside the closed path.

We consider in this note the set of values assumed by integrals over the course of the path of integration. In each example we approximate integrals of a given function over increasingly longer portions of a given path of integration. We plot the set of values of these ‘partial-path integrals’ and call the result a Cauchy curve. The Cauchy Integral Theorem assures that these Cauchy curves begin and end at zero (thus forming closed paths themselves); along the way, however, marvelous variety can occur.

We feel that the resulting curves are interesting for their complexities, novelties, and simple beauty. Moreover, these curves give a different way of looking at analytic functions. This note investigates Cauchy curves using J’s excellent facilities for complex arithmetic, plots, and adverbs. The inclusion of complex arithmetic can be seen in the original dictionary of J . There is recent documentation of J’s complex number operations at  and a recent Vector article includes .

## First example

For our first example our closed path of integration is the unit circle in the complex plane. We use the fact that the complex function runs once around the complex unit circle for 0 ≤t ≤ 2π. Here we look numerically at stepping around the circle in three steps and then graphically consider 10000 steps.

```   require 'plot'

r=: ^@j.

r steps 0 2p1 3   NB. sin 2r3p1 is 0.866025
1 _0.5j0.866025 _0.5j_0.866025 1j_2.44929e_16

\$C=: r steps 0 2p1 10000
10001
```

Since we usually want circles to look round, we define a utility to make plots with aspect ratio one and we thicken the curves slightly.

```   cplot=: 'Aspect 1;pensize 2'&plot

cplot C
```

That plot is shown in Figure 1. Figure 1. The unit complex circle centered at `0j0`.

For our first example of a Cauchy curve, we will let f(z) = 1+3z3 and use the `C` defined above for the closed path of integration. The 10001 complex numbers in `C` represent the ‘z’ values in the path integral that we are estimating. We compute dz by taking differences with the verb `diff`, defined below. We use the function `midpt` to find the points between the `z` values and evaluate `f` at those points (the ‘midpoint rule’ for integration gives quite good numerical approximations). Thus, dz is `diff C` in J while f(z) is `f mdpt C`. The integral sign means ‘limit of sums’, so we approximate it by using a sum as follows in J.

```   diff=: }. - }:

mdpt=: [: -: }. + }:

f=: 1 + 3 * ^&3

+/(f mdpt C) * diff C
1.19488e_14j_3.08564e_15
```

The result should be zero by Cauchy’s theorem; it is near 0 to 13 decimal places. To get the Cauchy curve in the above situation we just replace the sum `+/` with a list of partial sums `+/\` and plot the result.

```   cplot +/\(f mdpt C) * diff C
```

The result is shown in Figure 2. This is our first Cauchy curve. Figure 2. Cauchy curve for f(z) = 1+3z3.

We note that in our computational point of view the curve `C` is given as a numeric list of points and therefore we find the midpoints numerically as above. The integrals could be made more accurate by using midpoints from the parameterization or using higher order integration methods such as Simpson’s rule. Since our purpose is plotting curves, 13 decimal places of accuracy are sufficient.

Also, technically we think of paths as beginning and ending at the same point and the first term in the partial sum is typically not zero, thus we pre-append a 0 to the list of partial sums to make the result a closed path in our sense. It is convenient to introduce an adverb `chycu` to compute these Cauchy curves. Its adverb argument is the function being integrated, the right argument is the closed path given as a list of approximating points. The dyad case uses `x&u` as the integrand and this will later be used to compute several curves for one plot.

```   chycu=: 1 : 0    NB. CAUchy cuRVE
0,+/\(u mdpt y) * diff y
:
x&u chycu y
)

cplot f chycu C
```

The above line duplicates Figure 2.

## Cauchy curves and magnitude

If we plot the Cauchy curve for a monomial `^&n` the result is a circle. Here, and in all the examples until the last section, we again use the unit circle around the origin as our path of integration.

```   cplot ^&5 chycu C    NB. Cauchy curve is a circle
```

However, the plot of the Cauchy curve as a circle is misleading since it wraps around several times. Any guess as to how many times it wraps? Here we define `cmplot` which shows the Cauchy curve along with the magnitudes of the points on the Cauchy curve plotted in the direction of the angle (`12 o.`) to the corresponding points on the closed path `C`.

```   cmplot=: 1 : 0
z=. u chycu y
opts=. 'pensize 2;aspect 1;penstyle 0 1'
opts plot z,:(|z)r. 12 o.y
)
^&5 cmplot C

^&5 cmplot sC=: r steps 0 2p1 100
```

Figure 3 shows such a plot with the unit circle `sC` having a small number of points so that the magnitude curve can be seen in dashed form. Figure 3. Cauchy curve and magnitude for f(z) = z5.

In general, `^&n` gives a circle that wraps n+1 times. If multiple terms are used (as in Figure 2) in the polynomial, the results can be quite complicated. For example, consider the Cauchy path with magnitude for f(z) = 1+9z8, shown in Figure 4.

```   (1+9*^&8) cmplot sC
``` Figure 4. Cauchy curve and magnitude for f(z) = 1+9z8.

## Rational functions

With rational functions we need to be careful. Here we consider the rational function given by the following. Notice that the roots of the denominator in the complex plane will be slightly larger than one in magnitude (about 1.00083), so the unit circle gets near, but does not reach or encompass the bad points.

```   f=:1 0 0 0 0 0 2&p.%1.01+^&12

lC=:r steps 0 2p1 30000

cplot f chycu lC
``` Figure 5. Cauchy curve for a rational function.

That path of integration is so near to bad points that we increased the number of steps on the unit circle to 30000 to avoid a rough appearance. This creates a curve with six heart shapes has a cute, simple appearance. This curve is very sensitive to parameters. What happens if you change the exponent 12 to 11 or 13? What happens if you vary the coefficient of the sixth power away from 2? These are worthwhile experiments for the reader to try. We offer a gallery of these variants and more at .

## Families of Cauchy curves

Next we consider families of Cauchy curves. The adverb `cfplot` takes a dyad `u` as its verb argument and produces the Cauchy curves for the functions `a&u` for each item `a` of `x`. Figure 6 shows the Cauchy curves (all circles here) arising from zn for 2 ≤ n ≤12.

```   require '~addons/media/image3/prevare.ijs'

cfplot=: 1 : 0
:
opts=. 'pensize 2;aspect 1;itemcolor '
opts=. opts,":,Hue steps 0 2r3 ,#x
opts plot x u chycu"_1 _ y
)

(2+i.11) (]^[) cfplot C
``` Figure 6. Cauchy curves from f(z) = zn.

Next we consider plots of for exponents a geometrically distributed near 12.

```   fh6=: 1 0 0 0 0 0 2&p.@] % 1.01+]^[

lC=: r steps 0 2p1 30000

({.,{:)a=: 12*1.07^ steps 0 0.36 100
12 12.2959

a fh6 cfplot lC
``` Figure 7. Cauchy curves from `fh6`.

Next we look at the Cauchy curves from the family of functions f(z) = cos(a z2). The result is shown in Figure 8.

```   ({.,{:) a=: 4*0.9^steps 0 1 50
4 3.6

a cos@:([**:@]) cfplot C
``` Figure 8. Cauchy curves from f(z) = cos(a z2).

Several other plots of families of Cauchy curves may be found in the gallery 

## Alternate closed paths of integration

In this last section we note that we need not restrict ourselves to using the unit circle `C` as our closed path for the integration. We consider below examples using a square and an ellipse. The square has vertices at `_1j_1`, `1j_1`, `1j1` and `_1j1`.

```   pp=: 2 : '(m&*@-.+n&*)@(1&|)'

ss=: _1j_1 pp  1j_1

ee=: 1j_1 pp  1j1

nn=: 1j1  pp _1j1

ww=: _1j1  pp _1j_1

rsq=: ss`ee`nn`ww@.(4|<.)"0

sq=: rsq steps 0 4 50000

(2+i.11) (]^[) cfplot sq
```

Figure 9 gives the Cauchy curves of f(z) = zn with a square as the closed path of integration. Compare to Figure 6. Figure 9. Cauchy curves from f(z) = zn on a square.

In Figure 10 we show the result of using a very mild ellipse (the ratio of the axes is 0.9) as the path of integration for the function `fh6`. Compare to Figure 7. Notice the hearts are gone. Cauchy curves are very sensitive to the path of integration.

```   \$ell=: (cos j. 0.9 * sin) steps 0 2p1 30000
30001

(12*1.07^ steps 0 0.5 100) fh6 cfplot ell
``` Figure 10. Cauchy curves from `fh6` on an ellipse..

```script began 14:23:00
caching off
debug mode off
cache time 3600 sec