Recreating a Loxodromic Spiral Grid Using Complex Analysis
Tags: Complex Functions , Loxodromic , Conformal Maps , Möbius transformations , MacOS Grapher
(Español: Creación de una cuadrícula espiral loxodrómica con funciones de variable compleja)
In this post, I will show how I recreated a beautiful figure with spirals from a math-inspired coloring book using complex functions and Möbius transformations.
Here is the figure:
Here is one of the way we colored them with my sons!
I find the figure mesmerizing with its slight lack of total symmetry, spirals that go in opposite directions, and intersecting bendy curves at right angles. Because of the right angles I guessed there should be a complex conformal map involved, and I wanted to figure out how it was constructed and what the equations for the functions that produced this curvy grid looked like.
According to the book, the figure shows the projection on to the 2D plane of the paths one follows on a sphere from the North Pole when heading south and a bit east at a constant angle (and perpendicular directions to those paths). The book does not provide many additional details, but this was enough to get started!
I searched around on the internet for a while and could not find good references, so I set out to figure it out myself and write this up. I thoroughly enjoyed figuring out the ideas and details involved, and came across many interesting facts and figures along the way. I hope you do too!
First piece: Spirals on a sphere (loxodromic spirals)
A loxodromic spiral, also known as a rhumb line or a loxodrome, is a curve on a sphere that cuts longitudes at the same angle. It is the path of a ship that maintains a constant compass direction.
A loxodromic spiral can also be pictured on a 2D plane by using stereographic projection. This projection maps the sphere to the plane by sending each point on the sphere to its “shadow” on the plane. The setup involves placing the sphere on top of the plane, with the South Pole touching the origin and the North Pole directly above it. A light source is placed at the top of the sphere. The “shadow” of a point is where the line from the North Pole to the point meets the plane.
Under stereographic projection, loxodromic spirals correspond to logarithmic spirals, which are incredibly interesting curves in their own right. They look like this:
A logarithmic spiral can be parameterized using complex numbers with an equation of the form $$z(t)= e^{at}e^{it},\qquad t\in\mathbb{R}$$ where $a$ is a constant that controls the winding. The points $z(t)$ trace out the spiral as $t$ varies from $-\infty$ to $\infty$. In $z(t)=e^{at}e^{it}$ the $e^{at}$ is the distance from the origin, which grows exponentially with $t$, and the $e^{it}$ is a rotation by $t$ radians (the pretty fact that in complex numbers multiplication by $e^{i\theta}$ corresponds to rotation by an angle $\theta$).
Here is an interactive graph.
- change $a$ to see how the spiral changes.
- change $T$ to see how the point $z(t)$ moves on the curve.
Curve $z(t)= e^{at}e^{it}$ for $0\leq t\leq T$:
Follow this link if the interactive does not load.
Note that most online plotters do not plot parametric curves which involve complex numbers, so to be able to plot these curves (for example, in Desmos in the interactive above) one needs to write out explicitly the real and imaginary components of $z(t)=x(t)+iy(t)$ and plot $(x(t),y(t))$ instead. In this case, $x(t)=e^{a t} \cos(t)$ and $y(t)= e^{a t} \sin(t)$.
Logarithmic spirals have many interesting properties. They have even been called “miraculous spirals” and “eternal lines”. See the Wikipedia article for more.
Second piece: Transforming a spiral that goes to infinity into a double spiral (Möbius transformations)
A loxodromic spiral on a 3D sphere goes from the North Pole to the South Pole. When we stereographically project it to the 2D plane, the North Pole becomes the “infinite point” which is infinitely far away from the origin and the projected spiral grows forever as if trying to reach it. To see the two poles as finite points in the 2D plane, we need to tilt the sphere.
We could do some 3D math to find the parametric equations of the tilted curve, and then the formulas for the projection, but we can also stay in the plane and use the very cool Möbius transformations.
Möbius transformations are special functions of the form
$$f(z) = \frac{az + b}{cz + d}$$
where $a, b, c, d$ are complex constants such that $ad - bc \neq 0$. Möbius transformations have the amazing property that they map circles and lines to circles and lines, and keep angles the same. They also correspond to motions and rotations of the sphere. Here is an example of a square grid transformed by a Möbius transformation (note that all lines and circles intersect at right angles):
If you want to know more about Möbius trasnformations, I highly recommend starting off by watching a gorgeous video that was made several years ago.
To see the North and South poles, we want a Möbius transformation that maps $z=0$ to $z=−1$ and $z=\infty$ to $z=1$ (they choice of $1$ and $-1$ is arbitrary, any two numbers will do). One such function is
$$f(z) = \frac{z - 1}{z + 1}$$
If we apply this function to a logarithmic spiral $z(t)$, we expect to get a double spiral that winds around $z=−1$ and $z=1$. The formula for the transformed spiral is $$ f(z(t)) = \frac{e^{at}e^{it} - 1}{e^{at}e^{it} + 1} $$
To plot it, we need to separate the real and imaginary parts. This is sort of painful to do by hand, but computers can do it easily! For example, WolframAlpha may give them to you if you follow this link. Either way, you get
$$f(z(t))=x(t)+iy(t)$$ where $$ x(t)=\frac{e^{2 a t} - 1}{e^{2 a t} + 2 e^{a t}\cos{t} + 1} $$ and $$ y(t)=\frac{2 e^{a t}\sin{t}}{e^{2 a t} + 2 e^{a t}\cos{t} + 1} $$ let’s plot it!
Follow this link if the interactive does not load.
Beautiful! Slide $a$ to change the “windiness” of this double spiral, and slide $T$ to see how it grows as $t$ changes.
We can simplify $x(t)$ and $y(t)$ using hyperbolic trig functions ($\sinh$ and $\cosh$): $$ x(t)=\frac{\sinh{a t}}{\cosh{a t} + \cos{t}}\qquad y(t)=\frac{\sin{t}}{\cosh{a t} + \cos{t}} $$
Third piece: A grid of double spirals
We can see the two centers of the spiral now! How about the grid?
We need two sets of spirals: one set winding in the same direction (like a spinning top), and another set winding in the opposite direction, so they cross at right angles.
Let’s start with the first set of spirals.
Set of spirals winding in the same direction
Rotating around the origin is easy with complex numbers! To rotate by an angle $b$, just multiply by $e^{ib}$. So, we can make a set of logarithmic spirals around the origin by taking one spiral $z(t)=e^{at}e^{it}$ and plotting its rotations. If we want $n$ “equally spaced” spirals, we can plot: $$ z(t),\quad e^{i\frac{2\pi}{n}}z(t),\quad e^{i2\frac{2\pi}{n}}z(t),\quad e^{i3\frac{2\pi}{n}}z(t),\quad \ldots,\quad e^{in\frac{2\pi}{n}}z(t)=z(t) $$
Here is the result for $n=4$, with 4 spirals. You can play around with the values of $a$ and $T$. Once again, the complicated formulas from the curves come from computing explicitly the real an complex parts of $z(t)=e^{at}e^{it}$, $e^{i\frac{\pi}{4}}z(t)$, $e^{i\frac{\pi}{2}}z(t)$, $e^{i\frac{3\pi}{4}}z(t)$.
Follow this link if the interactive does not load.
Now we can transform them with our Möbius transformation to get double spirals that twist around each other! Here is the figure:
The formulas for these spirals are more complicated, but the method to get them is simple: just transform the four logarithmic spirals with the Möbius transformation, and then find the real and imaginary parts to plot them.
We can now do many of them at once! See the figure with 10 double spirals.
Here is an interactive too. The parameter $n$ determines the number of spirals
Follow this link if the interactive does not load.
Opposite spirals that meet at right angles
Now on to the second task for our grid. We need a set of spirals winding in the opposite direction, so that the spirals always intersect at right angles with the other ones. Since Möbius transformations preserve angles, if we find a set of logarithmic spirals that intersect at right angles, then they Möbius transformations will also intersect at right angles. So all we need to do is find a family of logarithmic spirals that intersects at right angles to the other.
If we call the first spiral $$z_1(t)=e^{at}e^{it},$$ then $e^{-it}$ will correspond to rotation by $-t$ degrees, so a spiral with the same “windiness” but that that winds in the opposite direction is $$z_2(t)=e^{at}e^{-it}.$$
However, these two spirals do not intersect at right angles, even though they result in very pretty pictures! Here is one (plotting several spirals in each direction):
Pretty! Like sunflowers! But not at right angles!
We need to change the “$a$-parameter” for $z_2(t)$. Try it yourself in this interactive.
Change $a_2$ in the interactive below so that the families intersect at right angles.
Follow this link if the interactive does not load.
If you tried to find the $a_2$ above, you probably found that $a_2\approx 1.66$ when $a_1=0.6$. In fact, the exact value is $a_2=1/0.6=1.6666…$. In general, one needs $a_2=1/a_1$ so that the spirals intersect at right angles! (One can prove this with some complex-variable calculus that I leave for the end of this post).
Here is the figure of the exactly perpendicular grid with $a=0.6$ and $1/a$ for the opposite spirals.
Done! The final picture (and interactive)
We made a grid of right-angled logarithmic spirals. Now we use the Möbius magic to bend it!
Here it is:
And the following one is like the one in the coloring book (with 10 and 20 spirals in different directions – this is why it looks a bit off – but it is on purpose)
Here is the original one from the book (rotated)
Finally, here is the interactive. Enjoy!
Follow this link if the interactive does not load.
A closing note: A shout-out to MacOS Grapher
Once one figures something out in Math, it is very difficult to “unfigure it out”. Everything seems “clear” and “obvious” in hindsight!
But getting there is not so smooth. I had many trials and errors and failed attempts to make these figures, and the MacOS Grapher app was the best way to test things out.
So, here is a thank you to MacOS Grapher!
Mac OS Grapher allowed me to plot complex parametric plots of the form $f(t)=(az(t)+b)/(cz(t)+d)$ without having to figure out the real and imaginary parts (time-consuming algebra and prone to error). Basically allowed me to test out ideas quickly, to play around and experiment without getting bogged down with the Algebra.
It’s a little gem that comes free with every Mac.
Here is a screenshot of the app as I was working for this post. Note in the menu on the left how things make more sense – define the spiral, then apply the Möbius transformation with no need to do any messy algebra.
Appendix
Here is an explanation of why the winding parameter for perpendicular loxodromic spirals is $1/a$. There probably are more elegant explanations for this, but this is the one I came up with!
If we call the first spiral $$z_1(t)=e^{at}e^{it},$$ then we can change the $e^{it}$ to $e^{-it}$ to get a spiral that winds in the opposite direction, but we don’t know the “windiness parameter” that can make the intersection be right angles. So, let’s say $$z_2(t)=e^{h(a)t}e^{-it}$$ where $h(a)$ is the unknown windiness parameter for $z_2$, so that $z_1$ and $z_2$ intersect at right angles. How do we know that such an $h(a)$ exists? And if so, how do we find $h(a)$?
Well, we just assume such an $h(a)$ exists, and we try to figure out what it is! So, here it goes.
Say $z^{*}$ is a point at which the two spirals intersect. This corresponds to some value $t=t_1$ for $z_1$ and $t=t_2$ for $z_2$. In other words, $z_1(t_1)=z^{*}=z_2(t_2)$.
If we want them to be perpendicular, then the tangent vectors $z_1^\prime(t)$ and $z_2^\prime(t)$ must be perpendicular, so they must differ by a multiple of $i$ (since multiplication by $i$ corresponds to rotation by $90$ degrees). Thus, there must be some real $r\neq0$ for which $$ z_1^\prime(t_1)=ri\cdot z_2^\prime(t_2). $$
Now, $z_1^\prime(t)=(a+i)z_1(t)$ and $z_2^\prime(t)=(h(a)-i)z_2(t)$, so the above condition becomes $$ (a+i)z^{*}=ri(h(a)-i)z^{*}, $$ and cancelling the $z^{*}$, we find $$ a+i=ri(h(a)-i) $$ So, if the $h(a)$ we are looking for exists, it must satisfy the above equation for some real number $r$. We are almost there! If we equate the real and imaginary parts in this equation we see that $r=a$ and $h(a)=1/a$.
So, we conclude that $h(a)$ does exist, and it must be $1/a$.
In other words, the spiral perpendicular to $$z_1(t)=e^{at}e^{it},$$ is $$z_2(t)=e^{t/a}e^{-it}.$$
Done!