## Calculus of Residues

After blowing off the cobwebs after a couple of years I have been looking at some of the notes that I made some years back on some courses that I took at Warwick on Complex Analysis and Vector Analysis.

Integration has always been one of my favourite areas of mathematics. At A-Level I learned lots of different techniques for calculating some interesting integrals – but A-Level only just skims the surface when it comes to integration and it can be difficult for A-Level students (through no fault of their own) to appreciate the significance of integration. Integration by Parts, Integration by substitution and reduction formula are all great but there are still many integrals which require more advanced techniques to calculate. Contour integrals and the calculus of residues can often come to the rescue.

Contour integrals are a way of passing difficult integrals over a real-interval such as $$\int_{-\infty}^{\infty}\!{\dfrac{x^{2}}{1+x^{4}}\mathrm{d}x}$$ into the complex plane and taking advantage of the Cauchy integral theorem and the calculus of residues. I remember how it felt when I first learned the formula for integration by parts because it meant that I was able to find integrals that were previously impossible for me to calculate – even though I have done contour integrals before it has been very exciting for me to re-discover them. Looking through one of my books I came across this problem – show that for $a>1$

$$\int_{0}^{2\pi}\!\frac{\mathrm{sin}2\theta}{(a+\mathrm{cos}\theta)(a-\mathrm{sin}\theta)}\;\mathrm{d}\theta = -4\pi\left(1-\frac{2a\sqrt{a^{2}-1}}{2a^{2}-1}\right)$$

After spending a good deal of one of my afternoons wrestling with the algebra I managed to arrive at a solution which you can download here as a pdf. Here is a graph of the integrand in the case when $a=2$

As you can see from the diagram, the area bounded by the curve and the $x$-axis certainly exists but trying to calculate this integral using A-Level techniques is going to be incredibly difficult if not impossible (if anyone can do it then I would love to see the solution). Unfortunately there are and always will be integrals that cannot be calculated analytically – this is just the way it is and there is no getting around it but contour integrals certainly allows you to calculate a huge range of integrals that previously would have been seemingly impossible.

## Complex Plots in SAGE Math

After playing around with SAGE-Math over the last week I discovered that it is possible to plot complex-valued functions. Unfortunately complex functions are functions from $\mathbb{C}$ to $\mathbb{C}$ which means that unless you are pretty good at visualising things in four dimensions it can be tricky to visualise them. A function from $\mathbb{R}$ to $\mathbb{R}$ such as $y=x^{3}-5x^{2}+4x+14$, which is a function from a one-dimensional space to another one-dimensional space, can be displayed on the familiar two-dimensional $x$-$y$-axes as in the diagram below.

The graph of a cubic equation

However, with a function from $\mathbb{C}$ to $\mathbb{C}$ we are taking points from a two-dimensional space to another two-dimensional space so we would need four dimensions to plot the graph of the function. I don’t know about you but I’ve never really got the hang of seeing things in four dimensions so we have to have a different way of displaying the data. This is where SAGE comes in useful.

Here is a plot of the function $f(z)=\dfrac{z^{2}}{1+z^{4}}$ that I put into SAGE to plot.

Plot of a complex-valued function.

The code that I used to do this is surprisingly simple:

p = complex_plot(lambda z: (z^2)/(1+z^4), (-2, 2), (-2, 2));p

The plot shows what happens to each complex number after it has been transformed. The colours in the plot correspond to different behaviours of the function.

In the plot above, zero is the only point that is mapped by the function to zero – notice how the colours are quite dark near the origin; this means that these points are mapped to other points in the complex plane of small magnitudes. Darker colours correspond to points that are mapped to complex numbers of relatively small magnitudes and lighter shades represent points that are mapped to complex numbers of larger magnitudes. As you move out from the centre the colours become lighter and there are white spots at the points $\dfrac{1}{\sqrt{2}}(1+i), \dfrac{1}{\sqrt{2}}(1-i), \dfrac{1}{\sqrt{2}}(i-1), -\dfrac{1}{\sqrt{2}}(1+i)$ these are the singularities, or poles, of the function – these are the points that can be considered as being mapped to infinity.

The plot has a certain degree of symmetry – any points that are the same colour are mapped by the function to the same point. For example $z=1+\dfrac{3}{2}i$ and $z=-1-\dfrac{3}{2}i$ are mapped to the same point and are therefore the same colour on the plot. I’m sure that I will be able to use these plots in the future – here’s a few more that I managed to create of the functions $f(z)=\dfrac{\mathrm{sin}(3z)}{1+z^{4}},\; f(z)=z^{2}$ and $f(z)=\dfrac{z^{3}-3z^{2}+4}{z^{4}-2z^{2}+12}$