# Residue Staircase

Wave · y = f(x, t)

`y = (p · ∫₀^(2 · π) (x² − x · cos(s))/(x² − 2x · cos(s) + 1) ds + q · ∫₀^(2 · π) (x² − 2x · cos(s))/(x² − 4x · cos(s) + 4) ds)/(2 · π)`

[Open in the app](https://www.wavelace.com/app#p=170) · [This page](https://www.wavelace.com/presets/residue-staircase)

### What it draws

The function is `f(z) = p/(z − 1) + q/(z − 2)`, with a pole at 1 and a pole at 2. The graph takes a circle `|z| = x` about the origin, integrates `f` once round it, and divides by `2πi`. The height is that number, plotted against the circle's radius `x`.

On the circle `z = x e^{is}`, so `dz = iz ds` and the `i` cancels. Each pole `a` leaves `(1/2π)∫ z/(z − a) ds`. Its imaginary part cancels round the circle, and its real part is the fraction inside each integral. Its denominator is `|z − a|²`.

### Why it steps

Cauchy's residue theorem says the integral round a closed curve is `2πi` times the sum of the residues of the poles inside it. The residue of `p/(z − 1)` at 1 is `p`, and of `q/(z − 2)` at 2 it is `q`.

So the height is 0 while the circle is smaller than 1, and nothing is inside. It is `p` once the circle takes in the pole at 1, and `p + q` once it takes in both. At the opening `p = q = 1` that is 0, 1 and 2: the staircase.

A negative `x` is the same circle started from the other side, which is why the left half mirrors the right.

### At the poles

When the circle runs through a pole the integral is not defined, since `|z − a|²` reaches 0. At exactly `x = 1` and `x = 2` the formula gives no value, and the graph has a gap.

Close by, the integrand is a sharp peak that the numerical integral cannot resolve. Within about 0.02 of each pole it swings past the step: 1.14 at `x = 1.01` where it should be 1.

### History

Augustin-Louis Cauchy developed the calculus of residues in the 1820s, from his integral theorem for a function with no poles inside the curve, whose integral is then 0.

### Try

- Drag `p` to −1. This is `f(z) = 1/((z − 1)(z − 2))`: the first step goes down to −1, and outside both poles the two residues cancel back to 0.
- Drag `p` to 0. The pole at 1 is gone, and so is its step: only the step at 2 is left.
- Set `p` to 2 and `q` to 0.5. The steps are 2 high and then 0.5 more, each the size of its residue.
- Press `Front` in the deck to see the staircase side on.

### Read more

- [Residue theorem](https://en.wikipedia.org/wiki/Residue_theorem)
- [Residue (complex analysis)](https://en.wikipedia.org/wiki/Residue_(complex_analysis))
- [Cauchy's integral theorem](https://en.wikipedia.org/wiki/Cauchy%27s_integral_theorem)
- [Contour integration](https://en.wikipedia.org/wiki/Contour_integration)
