Monday 7 January 2013

Today I Learned: How to Plot a Doughnut

I lied.

I actually didn't learn this today, but a fair while back. Although I did kind of forget most of it, and had to figure it out today. So maybe I didn't lie in the title, but I lied in the first paragraph of this sentence. At least I didn't create a paradox.

The aim of this post is just to describe a way of deriving an implicit polynomial formula for high genus tori, much like how: \[x^2+y^2-1=0\] is an implicit formula for the unit circle. The main idea of the construction that we're going to use was taught to me by one of my ex-students: Andrew Elvey-Price. Drew, if you're reading this: do more geometry and less combinatorics. Music is also alright by me. =P

Let me just first show you what a genus \(3\) torus looks like:
Torus just means that it's sort of like the surface of a doughnut - a round thing with holes through it, and the genus just counts how many holes it's got. I've only really bothered to play around with genus \(3\) tori (plural of torus) today, but the ideas behind how I plotted this torus should work for any number of holes.

Let's start off with the scary part - let's see the actual formula used to describe the above surface: \begin{align*} (x^2+(y-2)^2-1)((x-\sqrt{3})^2+(y+1)^2-1)((x-\sqrt{3})^2+\\(y+1)^2-1)-0.001(x^2+y^2+7z^2)^5=0 \end{align*} Well, at least we can handle the right-hand side of this equation. Let's stare a bit harder at the left-hand side. The first thing that you should notice is that the big nasty first term on the top line is a product of three things that we should understand pretty well: \begin{align*} x^2+(y-2)^2-1,\; (x-\sqrt{3})^2+(y+1)^2-1 \text{ and }(x+\sqrt{3})^2+(y+1)^2-1 \end{align*} are just formulas for unit circles, respectively centered at \((0,2), (\sqrt{3},-1)\) and \((-\sqrt{3},-1)\). And here's the key idea that Andrew taught me: most of the time, when we we look at a formula like \[x^2+(y-2)^2-1=0,\] we pretty much just pay attention to the circle. But we really should think about the value that the LHS takes over the whole \(xy\)-plane: 

1. It's \(-\)ve inside the circle and \(+\) outside the circle. 
  
This means that the product of these three terms should be:

2.  \(-\)ve inside the three circles and \(+\) outside the three circles. Oh, and I should probably point out that it takes the value of \(0\) on the actual three circles.

Now let's think about adding something like... o, I dunno, \[-0.001(x^2+y^2)^5\] to the triple product. Well, we can see that this term is going to be negative, but it's only a little bit negative around the origin \((0,0)\), and gets really negative as we head outwards from the origin. So, basically, when you add it to the product of the three circles, near the origin it'll make the positive region from this product slightly smaller (but still positive). And as you head outwards, the value of this sum will get less and less positive, until it eventually hits \(0\).

3. So, the sum of the big triple product term and this \(-0.001(x^2+y^2)^5\) term is going to be \(0\) at three circular shaped regions close to the three unit circles that I keep (somewhat awkwardly) mentioning, as well as a big roundish region outside. here's a picture of what I'm talking about:

In the above diagram, the burgundy bits are positive, and the yellowy bits are negative, and that's what you get when you add two functions.

The reason that we added the \(-0.001(x^2+y^2)^5 \) term is because it's the \(z=0\) slice of the \[-0.001(x^2+y^2+7z^2)^5\] term in the defining (implicit) function of this surface. And the reason that we paid so much attention to it is because this is a part of how mathematicians actually draw a surface (or at least how we used to do it, before awesome computer programs like Mathematica and Matlab were around): we draw the curve for \(z=0\), and then change \(z\) to some other value nearby, like \(z=0.5\) and so forth, and slowly we build a cross section of our surface. Then we mesh all of those cross-sections together to form a pretty decent guess of what the surface actually looks like. Now, as we vary \(z\) away from \(0\), we see that
\[-0.001(x^2+y^2+7z^2)^5\] becomes much much more negative. What this does when you add it to the triple product term is that:


4. It  brings in the outside big circle, and makes the internal three circles larger, until these form regions merge up to form this Y-shaped boomerang thingy.
5. If you keep taking \(z\) farther away from \(0\), you'll find that this region keeps shrinking, until it eventually disappears.

So, with all that info, you should be able to build a picture like the one that I showed you at the start. Note that I had all of these random numbers like -0.001 and 7 hangin' around - that's just to tweak the formula so that the final shape looks nicer (well, actually, that's a bit of a lie - the 0.001 is sorta necessary, but I'll let you figure out why).

Now, having done all of this, I realised that I could, instead of using \[-0.001(x^2+y^2+7z^2)^5,\] maybe use a different function to draw a slightly differently shaped torus. My first idea is to use the three-leaf-clover curve given by something like: \[r=\cos(\frac{2\pi x}{3})+\sqrt{5},\] which is written in polar-coordinates, and to convert it back into \(x\) and \(y\). Doing so gave me this (after some playing around):

which kinda looks like a holey guitar pick. The formula for this one is a bit scarier than the last guy, it's: \begin{align*} (\frac{3}{2}x^2+(y-\frac{11}{5})^2-\frac{9}{5})\cdot (\frac{\sqrt{3}}{2}(x+\frac{11\sqrt{3}}{10})+\frac{1}{2}(y+\frac{11}{10}))^2\\+\frac{3}{2}(\frac{-1}{2}(x+\frac{11\sqrt{3}}{10})+\frac{\sqrt{3}}{2}(y+\frac{11}{10}))^2-\frac{9}{5})\cdot(\frac{\sqrt{3}}{2}(\frac{11\sqrt{3}}{10}-x)+\frac{1}{2}(y+\frac{11}{10}))^2\\+\frac{3}{2}(\frac{1}{2}(x-\frac{11\sqrt{3}}{10})+\frac{\sqrt{3}}{2}(y+\frac{11}{10})) ^2-\frac{9}{5})+5(x^2+y^2)^3\\-((y^3-x^2y)-(x^2+y^2)^2)^2-(4z^2+0.1(x^2+y^2))^6=0. \end{align*} And the last guy is a minor tweak of this formula, but there's no way I'm typing it all out. It's pretty similar to the above guy, but fluffier.
So ugh, there you go kids, go nuts drawing donuts.

No comments:

Post a Comment