I missed Tau day, which was the 28th of June. However, I’ve been thinking about the intersection of Tau, complex numbers, code libraries and Javascript in analytics for a while now, and this seemed like a good chance to explore one of my favorite topics: Tauism. — Kurt Cagle
One of the things that most young mathematicians (think eight years old or so) learn is that pie are square, a fact which is immediately refuted with the confused observation “No they’re not! Pies are round!” Later, of course, they discover algebra and geometry, where in fact it is proven demonstrably that, well, the circumference of a circle and the area of the same circle are related by two simple equations:
C=2πr
and
A=πr^2
The first law was at least known at the time of Euclid, though it would be a few centuries later that Archimedes actually calculated the ratio of the diameter (twice the radius) to the circumference to be roughly 3 1/7 (though in fact, he was able to get it right to within eight digits eventually, in Greek numeric notation). However, it would be early in the eighteen century AD that Welsh mathematician William Jones would use the Greek letter π (pi) for this particular ratio.
The great mathematician Leonhard Euler would eventually pull together the use of π, the base of the natural logarithms (e, approximately 2.71828) and the square root of negative one (called i) into one of the more fundamental equations of mathematics:
e^(πi) = -1
For the next three hundred years, π would reign supreme in mathematics as perhaps the single most well known constant ever. However, for several years, Euler debated whether to use π to indicate the circumference of a circle divided by the diameter (a ratio of about 3.1415927…) or to indicate the circumference divided by the ratio (a ratio of 6.2831854…). His decision, ultimately, to go with the former may have complicated mathematics far more than he’d planned.
In 2010, mathematician Michael Hartl wrote a paper that would eventually become known as the Tau Manifesto, in which he proposed using the letter tau (τ) for the ratio of the circumference divided by radius, the aforementioned 6.28 value. His arguments were actually quite compelling:
- One τ is precisely one turn around a circle, or one revolution (360°). τ/2 is half a circle or 180°, τ/4 is one fourth of a circle, or 90° and so forth. Compare this with 2π, π, and π/2 respectively. In general, this becomes the same as C= τr, as opposed to C= xn—
- Euler’s equation (which laid the foundation for complex numbers), can be expressed with τ as:
e^(τi) = 1
- Similarly, the area of a circle takes on the same characteristics as other power laws in mathematics and physics:
A = \dfrac{1}{2} \tau r^2; E= \dfrac{1}{2} m v^2;
A=(1/2)τr^2 ; E = (1/2) mv^2
Where it really shines, however, is in areas such as trigonometry and complex matrix algebra. For instance, if you had trigonometric functions built around τ, you can state that
e^(iθ) = cos(θ) + i sin(θ), where 0 < θ < τ
This equation makes it clear that a quarter of the way through a revolution, the equation has the value +i, at halfway it’s -1, at 3/4 of the revolution, the equation is –i, and at one full revolution you’re right back to where you started. It also highlights the close association between exponential functions and rotations.
This becomes especially useful in gaming and 3D applications, in which the square root of -1 (the i part) is treated as an axis of rotation. In three dimensions, you end up with three such axes: i, j, and k. These are known as quaternions. If each of these are used to describe a complex number (such as 0.5 + 0.866i) on the unit sphere (a great circle), then by performing a rotation on that circle (from 0 to 1 τ ), you can position that object precisely along that rotation. Camera operators (and pilots) understand these three dimensions as pitch, yaw and roll.
These quaternions become especially important when dealing with rigging in three-dimensional work, involving vectors connecting end to end. These are also known as gimbals, again from the camera mounts that allow for orienting in any dimension. While in data science this can be done using matrix transformations, quaternion calculations are often faster and less time consuming to set up.
The skeleton of a 3D figure is made up of vectors, with quaternions acting as gimbals at the joints to help move the figure around.
A Library For Tau Based Complex Number Operations
The value of Tau (and the relationship between Tau revolutions and complex numbers, inspired me to write a small Javascript library that both defined some Tau helper functions (the Tau class, made up exclusively of static) and an immutable TauComplex class that was built specifically with Tau revolutions in mind. These scripts are available at https://github.com/kurtcagle/tau.
The complex class is reasonably complete for complex number manipulation, including handling addition and multiplication of complex numbers, creating complex conjugates, moduli, and equations for rotating, scaling and translating such numbers in the complex plane. A test script (TauTest.js) illustrates how these functions are invoked:
with this test script generating the following output :
c1: 1 + 2i
c2: -2 + 1i
c3: -1 + 3i
c4: 0 - 1i
modulus of c3: 3.1622776601683795
modulus squared of c3: 10
theta of c3: 0.30120819117478337
conjugate of c3: -1 - 3i
c1 + c2: -1 + 3i
c1 * c2: -4 - 3i
c1 ^ 2: -3 + 4i
c1 ^ 3: -11 - 2i
1 / c1: 0.2 - 0.4i
c1 / c3: 0.5 - 0.5i
exp(c5): -1.92 + 1.92i
c1 scale 2: 2 + 4i
c1 translate 2,3: 3 + 5i
c4 rotate 0/12 or 0: 0 - 1i
c4 rotate 1/12 or 30: 0.5 - 0.866i
c4 rotate 2/12 or 60: 0.866 - 0.5i
c4 rotate 3/12 or 90: 1 - 0i
c4 rotate 4/12 or 120: 0.866 + 0.5i
c4 rotate 5/12 or 150: 0.5 + 0.866i
c4 rotate 6/12 or 180: 0 + 1i
c4 rotate 7/12 or 210: -0.5 + 0.866i
c4 rotate 8/12 or 240: -0.866 + 0.5i
c4 rotate 9/12 or 270: -1 + 0i
c4 rotate 10/12 or 300: -0.866 - 0.5i
c4 rotate 11/12 or 330: -0.5 - 0.866i
c4 rotate 12/12 or 360: 0 - 1i
Complex Array: 1 + 0i,0 + 1i,-1 + 0i,0 - 1i
One of the critical points about this library is that the complex numbers are meant to be treated as immutable, with any operation on a complex number generating a new complex number. For instance, if you wanted to add three complex numbers, you’d create an expression such as:
const c6 = TauComplex.sum(c1,c2,c3) => c6 = Sum of (c1,c2,c3): -2 + 6i
Complex numbers factor heavily in both pure and applied mathematics, and can be proved to be the largest complete set of numbers – you cannot construct another space of numbers that cannot be decomposed into complex numbers. Additionally, the equations used to create approximations of surfaces, known as the Taylor Series, makes extensive use of complex numbers.
There is one final point to be made in this particular article. There is a tendency to look at either Python or R when dealing with mathematics, but it’s worth noting that it is perfectly possible to create mathematics libraries and classes in JavaScript as well. Indeed, Javascript contains its own equivalents of both Pandas (Danfo.js) and NumPy (nympy.js), two of the foundational classes, and Google’s TensorFlow library has been ported over to Javascript as well (primarily around the node.js version). In some cases, Javascript is even faster than Python in the analytics space, especially given recent optimizations for handling binary data types.