import stereo from from-wordpress
This commit is contained in:
parent
e4aa0dd8d9
commit
6a1c2d5689
405
posts/stereo/1/index.qmd
Normal file
405
posts/stereo/1/index.qmd
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
---
|
||||||
|
format:
|
||||||
|
html:
|
||||||
|
html-math-method: katex
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
Algebraic Rotations and Stereography
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Expressing rotation mathematically can be rather challenging, even in two dimensional space. Typically the subject is approached from complicated-looking rotation matrices, with the occasional accompanying comment about complex numbers. The challenge only increases when examining three dimensional space, where everyone has different ideas about the best implementations. In what follows, I attempt to provide a derivation of 2D and 3D rotations based in intuition and without the use of trigonometry.
|
||||||
|
|
||||||
|
|
||||||
|
Complex Numbers: 2D Rotations
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Multiplication between complex numbers is frequently analyzed as a combination of scaling (a ratio of two scales) and rotation (a point on the complex unit circle). However, the machinery used in these analyses usually expresses complex numbers in a polar form involving the complex exponential, concepts which leverage knowledge of trigonometry and some calculus. In fact, they obfuscate the algebraic properties of complex numbers when neither concept is truly necessary to understand points on the complex unit circle, or complex number multiplication in general.
|
||||||
|
|
||||||
|
|
||||||
|
### A review of complex multiplication
|
||||||
|
|
||||||
|
A complex number $z = a + bi$ multiplies with another complex number $w = c + di$ in the obvious way: by distributing over addition.
|
||||||
|
|
||||||
|
$$
|
||||||
|
zw = (a+bi)(c+di) = ac + bci + adi + bdi^2 = (ac -\ bd) + i(ad + bc)
|
||||||
|
$$
|
||||||
|
|
||||||
|
*z* also has associated to it a conjugate $z^* = a -\ bi$. The product $zz^*$ is the *norm* $a^2 + b^2$, a positive real quantity whose square root is typically called the *magnitude* of the complex number. Taking the square root is frequently unnecessary, as many of the properties of this quantity do not depend on this normalization. One such property is that for two complex numbers *z* and *w*, the norm of the product is the product of the norm.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
(zw)(zw)^* &= (ac -\ bd)^2 + (ad + bc)^2 \\
|
||||||
|
&= a^2c^2 -\ 2abcd + b^2d^2 + a^2d^2 + 2abcd + b^2c^2 \\
|
||||||
|
&= a^2c^2 + b^2d^2 + a^2d^2 + b^2c^2 = a^2(c^2 + d^2) + b^2(c^2 + d^2) \\
|
||||||
|
&= (a^2 + b^2)(c^2 + d^2)
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Conjugation also distributes over multiplication, and complex numbers possess multiplicative inverses. Also, the norm of the multiplicative inverse is the inverse of the norm.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
z^*w^* = (a -\ bi)(c -\ di) = ac -\ bci -\ adi + bdi^2 \\
|
||||||
|
= (ac -\ bd) -\ i(ad + bc) = (zw)^* \\
|
||||||
|
{1 \over z} = {z^* \over zz^*} = {a -\ bi \over a^2 + b^2} \\
|
||||||
|
\left({1 \over z}\right)
|
||||||
|
\left({1 \over z}\right)^*
|
||||||
|
= {1 \over zz^*} = {1 \over a^2 + b^2} \\
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
A final interesting note about complex multiplication is the product $z^*w$
|
||||||
|
|
||||||
|
$$
|
||||||
|
z^* w = (a -\ bi)(c + di) = ac -\ bci + adi -\ bdi^2 = (ac + bd) + i(ad -\ bc)
|
||||||
|
$$
|
||||||
|
|
||||||
|
The real part is the same as the dot product $(a, c) \cdot (b, d)$ and the imaginary part looks like the determinant of $\begin{pmatrix}a & b \\ c & d\end{pmatrix}$. This shows the inherent value of complex arithmetic, as both of these quantities have important interpretations in vector algebra.
|
||||||
|
|
||||||
|
|
||||||
|
### Onto the Circle
|
||||||
|
|
||||||
|
If $zz^* = a^2 + b^2 = 1$, then *z* lies on the complex unit circle. Since the norm is 1, a general complex number *w* has the same norm as the product *zw*. Thus, multiplication by *z* results in the rotation that maps 1 to *z*. But how do you get such a point on the unit circle?
|
||||||
|
|
||||||
|
Simple. There are four complex numbers directly related to any complex number *w* that are guaranteed to share its norm: $w, -w, w^*$, and $-w^*$. Therefore, dividing any of these numbers by any other of these numbers results in a complex number on the unit circle. Division by -*w* is boring and just results in -1. However, division by $w^*$ turns out to be important:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
z &= {w \over w^*} =
|
||||||
|
\left( {a + bi \over a -\ bi} \right) \left( {a + bi \over a + bi} \right) = 1 \\[8pt]
|
||||||
|
&= {(a^2 -\ b^2) + (2ab)i \over a^2 + b^2}
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Dividing the numerator and denominator of this expression through by $a^2$ yields an expression in $t = b/a$, where t can be interpreted as the slope of the line joining 0 and *w*.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
{(a^2 -\ b^2) + (2ab)i \over a^2 + b^2}
|
||||||
|
&= {1/a^2 \over 1/a^2} \cdot {(a^2 -\ b^2) + (2ab)i \over a^2 + b^2} \\
|
||||||
|
&= {(1 -\ b^2/a^2) + (2b/a)i \over 1 + b^2/a^2}
|
||||||
|
= {(1 -\ t^2) + (2t)i \over 1 + t^2} \\
|
||||||
|
&= {1 -\ t^2 \over 1 + t^2} + i{2t \over 1 + t^2} = z(t)
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Dividing the numerator and denominator of this expression through by $a^2$ yields an expression in $t = b/a$, where *t* can be interpreted as the slope of the line joining 0 and *w*.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
{(a^2 -\ b^2) + (2ab)i \over a^2 + b^2}
|
||||||
|
&= {1/a^2 \over 1/a^2} \cdot {(a^2 -\ b^2) + (2ab)i \over a^2 + b^2} \\
|
||||||
|
&= {(1 -\ b^2/a^2) + (2b/a)i \over 1 + b^2/a^2}
|
||||||
|
= {(1 -\ t^2) + (2t)i \over 1 + t^2} \\
|
||||||
|
&= {1 -\ t^2 \over 1 + t^2} + i{2t \over 1 + t^2} = z(t)
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Slopes range from $-\infty$ to $\infty$, which means that the variable *t* does as well. Moreover, if *z* is on the unit circle, then its reciprocal is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
{1 \over z} = {z^* \over zz^*} = z^*
|
||||||
|
$$
|
||||||
|
|
||||||
|
In other words, for points already on the unit circle, $z / z^* = z^2$ describes the rotation from 1 to $z^2$. This demonstrates the decomposition of the rotation into two parts. For a general complex number *w* which may not lie on the unit circle, multiplication by this number dilates the complex plane as well rotating 1 toward the direction of *w*. Then, division by $w^*$ undoes the dilation and performs the rotation again. The proper description of the rotation described by $w/w^*$ is the combination of these half steps.
|
||||||
|
|
||||||
|
|
||||||
|
### Two Halves, Twice Over
|
||||||
|
|
||||||
|
Plugging in some values for t reveals something else: $z(0) = 1 + 0i$, $z(1) = 0 + 1i$, and $z(-1) = 0 -\ 1i$. This shows that the semicircle in the right half-plane exists where $t \in (-1, 1)$. The other half of the circle comes from *t* with magnitude greater than 1. The point where $z(t) = -1$ does not properly exist unless it is allowed that $t = \pm \infty$.
|
||||||
|
|
||||||
|
Is it possible to get the other half into the nicer interval? No problem, just double the rotation.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
z(t)^2 &= (\Re[z]^2 -\ \Im[z]^2) + i(2\Re[z]\Im[z]) \\[8pt]
|
||||||
|
&= {(1 -\ t^2)^2 -\ (2t)^2 \over (1 + t^2)^2} + i{2(1 -\ t^2)(2t) \over (1 + t^2)^2} \\[8pt]
|
||||||
|
&= {1 -\ 6t^2 + t^4 \over 1 + 2t^2 + t^4}
|
||||||
|
+i {4t -\ 4t^3 \over 1 + 2t^2 + t^4} \\
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Now the entire circle fits in the interval $t \in (-1, 1)$, and $z(-1)^2 = z(1)^2 = -1$. This action of squaring *z* means that as *t* ranges from $-\infty$ to $\infty$, the point $z^2$ loops around the circle twice, since the rotation *z* is applied twice.
|
||||||
|
|
||||||
|
I'd now like to go on a brief tangent and compare these expressions to their transcendental trigonometric counterparts. Graphing the real and imaginary parts separately shows how much they resemble $\cos(\pi t)$ and $\sin(\pi t)$ around 0.
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
Incidentally, an approximation of a function as the ratio of two polynomials is called a [Padé approximant](https://en.wikipedia.org/wiki/Pad%C3%A9_approximant). Specifically, the real part (which approximates cosine) has order \[4/4\] and the imaginary part (which approximates sine) has order \[3/4\]. Ideally, the zeroes of the real part should occur at $t = \pm 1/2$, since $\cos(\pm \pi/2) = 0$. Instead, they occur at
|
||||||
|
|
||||||
|
$$
|
||||||
|
0 = 1 -\ 6t^2 + t^4 = (t^2 -\ 2t -\ 1)(t^2 + 2t -\ 1)
|
||||||
|
\implies t = \pm {1 \over \delta_s} = \pm(\sqrt 2 -\ 1) \approx \pm0.414
|
||||||
|
$$
|
||||||
|
|
||||||
|
With a bit of polynomial interpolation, this can be rectified. A cubic interpolation is given by:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
P(x) = ax^3 + bx^2 + cx + d \\
|
||||||
|
\begin{pmatrix}
|
||||||
|
1 & 0 & 0 & 0 \\
|
||||||
|
1 & 1/2 & 1/4 & 1/8 \\
|
||||||
|
1 & -1/2 & 1/4 & -1/8 \\
|
||||||
|
1 & 1 & 1 & 1 \\
|
||||||
|
\end{pmatrix} \begin{pmatrix}
|
||||||
|
d \\ c \\ b \\ a
|
||||||
|
\end{pmatrix} = \begin{pmatrix}
|
||||||
|
0 \\ \sqrt 2 -\ 1 \\ -\sqrt 2 + 1 \\ 1
|
||||||
|
\end{pmatrix} \\
|
||||||
|
\implies \begin{pmatrix}
|
||||||
|
d \\ c \\ b \\ a
|
||||||
|
\end{pmatrix} = \begin{pmatrix}
|
||||||
|
0 \\ -3 + 8\sqrt 2/3 \\ 0 \\ 4 -\ 8\sqrt 2/3 \end{pmatrix}
|
||||||
|
\implies P(x) \approx 0.229 x^3 + 0.771x
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
The error over the interval [-1, 1] in these approximations is around 1% (RMS).
|
||||||
|
::::
|
||||||
|
|
||||||
|
Notably, this interpolating polynomial is entirely odd, which gives it some symmetry about 0. Along with being a very good approximation, it has the feature that a rotation by an *n*^th^ of a turn is about $z(P(1/n))^2$. The approximation be improved further by taking *z* to higher powers and deriving another interpolating polynomial.
|
||||||
|
|
||||||
|
It is impossible to shrink this error to 0 because the derivative of the imaginary part at $t = 1$ would be $\pi$ with no error. But the imaginary part is a rational expression (technically with the interpolating polynomial, a ratio of two irrational numbers), so its derivative is also a rational expression. Since $\pi$ is transcendental, there must always be some error.
|
||||||
|
|
||||||
|
Even though it is arguably easier to interpret, there probably isn't a definite benefit to this approximation. For example,
|
||||||
|
|
||||||
|
- Padé approximants can be calculated directly from the power series for sine and cosine.
|
||||||
|
- There are no inverse functions like `acos` or `asin` to complement these approximations.
|
||||||
|
- This isn't that bad, since I have refrained from describing rotations with an angle. Even so, the inverse functions have their use cases.
|
||||||
|
- Trigonometric functions can be hardware-accelerated (at least in some FPUs).
|
||||||
|
- If no such hardware exists, approximations of `sin` and `cos` can be calculated by software beforehand and stored in a lookup table (which is also probably involved at some stage of the FPU).
|
||||||
|
|
||||||
|
Elaborating on the latter two points, using a lookup table means evaluation happens in roughly constant time. A best-case analysis of the above approximation, given some value *t* is
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\text{Expression} & \text{Additions} & \text{Multiplications} & \text{Divisions} \\ \hline
|
||||||
|
p = t \cdot (0.228763834 \cdot t \cdot t + 0.771236166) &
|
||||||
|
1 & 3 \\[4pt]
|
||||||
|
q = p \cdot p &
|
||||||
|
& 1 \\[4pt]
|
||||||
|
r = 1 + q &
|
||||||
|
1 \\[4pt]
|
||||||
|
c = {1 -\ q \over r} &
|
||||||
|
1 & & 1 \\[4pt]
|
||||||
|
s = {2 \cdot p \over r} &
|
||||||
|
2 & 1 & 1 \\[4pt]
|
||||||
|
real = c \cdot c -\ s \cdot s &
|
||||||
|
1 & 2 \\[4pt]
|
||||||
|
imag = 2 \cdot c \cdot s &
|
||||||
|
& 2 \\
|
||||||
|
\hline
|
||||||
|
\Sigma &
|
||||||
|
6 & 9 & 2 \\
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Or 17 FLOPs. On a more optimistic note, a Monte Carlo test of the above approximation on my computer yields promising results when compared with the GCC `libmath` implementations of sin and cos (also tested with `cexp`).
|
||||||
|
|
||||||
|
```{}
|
||||||
|
Timing for 100000 math.h sin and cos: 5409619ns
|
||||||
|
Timing for 100000 approximations: 2408645ns
|
||||||
|
Approximation faster, speedup: 3000974ns (2.25x)
|
||||||
|
Squared error in cosines:
|
||||||
|
Average: 0.000051 (0.713743% error)
|
||||||
|
Largest: 0.000174 (1.320551% error)
|
||||||
|
Input: 0.729202
|
||||||
|
Value: -0.659428
|
||||||
|
Approximation: -0.672634
|
||||||
|
Squared error in sines:
|
||||||
|
Average: 0.000070 (0.835334% error)
|
||||||
|
Largest: 0.000288 (1.698413% error)
|
||||||
|
Input: 0.729202
|
||||||
|
Value: 0.475669
|
||||||
|
Approximation: 0.458685
|
||||||
|
```
|
||||||
|
|
||||||
|
For the source which I used to generate this output, see the repository linked below.
|
||||||
|
|
||||||
|
Even though results can be inaccurate, this exercise in the algebraic manipulation of complex numbers is fairly interesting since it requires no calculus to define, unlike sine, cosine, and their Padé approximants (and to a degree, $\pi$).
|
||||||
|
|
||||||
|
|
||||||
|
From Circles to Spheres
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
The expression for complex points on the unit circle coincides with the stereographic projection of a circle. This method is achieved by selecting a point on the circle, fixing *t* along a line (such as the *y*-axis), and letting *t* range over all possible values.
|
||||||
|
|
||||||
|
![]()
|
||||||
|
|
||||||
|
The equations of the line and circle appear in the diagram above. Through much algebra, expressions for *x* and *y* in *t* can be formed.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
y &= t(x + 1) \\
|
||||||
|
1 &= x^2 + y^2 = x^2 + (tx + t)^2 \\
|
||||||
|
&= x^2 + t^2x^2 + 2t^2 x + t^2 \\
|
||||||
|
{1 \over t^2 + 1} -\ {t^2 \over t^2 + 1} &=
|
||||||
|
x^2 + {t^2 \over t^2 + 1} 2x \\
|
||||||
|
{1 -\ t^2 \over t^2 + 1} + \left( {t^2 \over t^2 + 1} \right)^2 &=
|
||||||
|
\left(x + {t^2 \over t^2 + 1} \right)^2 + {t^2 \over t^2 + 1} \\
|
||||||
|
{1 -\ t^4 \over (t^2 + 1)^2} + {t^4 \over (t^2 + 1)^2} &=
|
||||||
|
\left(x + {t^2 \over t^2 + 1} \right)^2 \\
|
||||||
|
{1 \over (t^2 + 1)^2} &=
|
||||||
|
\left(x + {t^2 \over t^2 + 1} \right)^2 \\
|
||||||
|
{1 \over t^2 + 1} &=
|
||||||
|
x + {t^2 \over t^2 + 1} \\
|
||||||
|
x &= {1 -\ t^2 \over 1 + t^2} \\
|
||||||
|
y &= t(x + 1) =
|
||||||
|
t\left( {1 -\ t^2 \over 1 + t^2} + {1 + t^2 \over 1 + t^2} \right) \\
|
||||||
|
&= {2t \over 1 + t^2}
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
These are exactly the same expressions which appear in the real and imaginary components of the ratio between $1 + ti$ and its conjugate. Compared to the algebra using complex numbers, this is quite a bit more work. Therefore, one might also ask whether, given a proper arithmetic setting, the projection of a sphere might be obtained in the same manner as the circle with respect to complex numbers.
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
What we are not doing: intersecting the sphere with a line through a pole and a point in the xy plane
|
||||||
|
:::
|
||||||
|
|
||||||
|
|
||||||
|
### Algebraic Projection
|
||||||
|
|
||||||
|
The simplest thing to do is try it out. Let's say an extended number $h = 1 + si + tj$ has a conjugate of $h^* = 1 -\ si -\ tj$. It's a bit of an assumption to be able to take the reciprocal of the latter (we don't know whether *i* and *j* create a field or division ring), but following our noses:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
{h \over h^*} = {1 + si + tj \over 1 -\ si -\ tj} =
|
||||||
|
\left({1 + si + tj \over 1 -\ si -\ tj}\right)
|
||||||
|
\left({1 + si + tj \over 1 + si + tj}\right) = \\[8pt] {
|
||||||
|
1 + si + tj + si + s^2i^2 + stij + tj + stji + t^2j^2
|
||||||
|
\over
|
||||||
|
1 -\ si -\ tj + si -\ s^2 i^2 -\ stij + tj -\ stji -\ t^2j^2
|
||||||
|
}
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
While there is some cancellation in the denominator, both products are rather messy. To get more cancellation, we apply some nice algebraic properties between *i* and *j*. For the $stij$ terms to cancel, we let i and j be *anticommutative*, meaning that $ij = -ji$. So that the denominator is totally real (and therefore can be guaranteed to divide), we also apply the constraint that $i^2$ and $j^2$ are both real. Then the expression becomes
|
||||||
|
|
||||||
|
$$
|
||||||
|
{1 + si + tj \over 1 -\ si -\ tj} =
|
||||||
|
{1 + s^2i^2 + t^2j^2 \over 1 -\ s^2 i^2 -\ t^2j^2} +
|
||||||
|
i{2s \over 1 -\ s^2 i^2 -\ t^2j^2} +
|
||||||
|
j{2t \over 1 -\ s^2 i^2 -\ t^2j^2}
|
||||||
|
$$
|
||||||
|
|
||||||
|
If it is chosen that $i^2 = j^2 = -1$, this produces the correct equations ([Wikipedia](https://en.wikipedia.org/wiki/Stereographic_projection#First_formulation)) parametrizing the unit sphere. One can also check that the squares of the real, *i*, and *j* components sum to 1.
|
||||||
|
|
||||||
|
If both *i* and *j* anticommute, then their product also anticommutes with both *i* and *j*.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\textcolor{red}{ij}j = -j\textcolor{red}{ij} ~,~
|
||||||
|
i\textcolor{red}{ij} = -\textcolor{red}{ij}i
|
||||||
|
$$
|
||||||
|
|
||||||
|
Calling this product *k* and noticing that $k^2 = (ij)(ij) = -ijji = i^2 = -1$, this completely characterizes the [quaternions](https://en.wikipedia.org/wiki/Quaternion).
|
||||||
|
|
||||||
|
Choosing different values for $i^2$ and $j^2$ yield different shapes than a sphere. If you know a little group theory, you might know there are only two nonabelian (noncommutative) groups of order 8: the [quaternion group](https://en.wikipedia.org/wiki/Quaternion_group) and the [dihedral group of degree 4](https://en.wikipedia.org/wiki/Examples_of_groups#dihedral_group_of_order_8). In the latter group, *j* and *k* are both imaginary, but square to 1 (*i* still squares to -1). I'm being a bit careless with the meanings of "1" and "-1" here, but these objects come from the additive structure of the algebra, rather than the multiplicative.
|
||||||
|
|
||||||
|
Changing the sign of one (or both) of the imaginary squares in the expression $h/h^*$ above switches the multiplicative structure from quaternions to the dihedral group. In this group, picking $i^2 = -j^2 = -1$ parametrizes a hyperboloid of one sheet, and picking $i^2 = j^2 = 1$ parametrizes a hyperboloid of two sheets.
|
||||||
|
|
||||||
|
|
||||||
|
Quaternions and Rotation
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Complex numbers are useful for describing 2D rotations and elegantly describe the stereographic projection of a circle. Consequently, since quaternions elegantly describe the stereographic projection of a sphere, they are useful for 3D rotations.
|
||||||
|
|
||||||
|
Since the imaginary units *i*, *j*, and *k* are anticommutative, a general quaternion does not commute with other quaternions like complex numbers do. This embodies a difficulty with 3D rotations in general: unlike 2D rotations, they do not commute.
|
||||||
|
|
||||||
|
Only three of the four components in a quaternion are necessary to describe a point in 3D space. The three imaginary axes are symmetric in some way (i.e., they all square to -1), so we use the *ijk* subspace. Quaternions in this subspace are called *vectors*. Another reason for using the *ijk* subspace comes from considering a point $u = ai + bj + ck$ on the unit sphere ($a^2 + b^2 + c^2 = 1$). Then the square of this point is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
u^2 &= (ai + bj + ck)(ai + bj + ck) \\
|
||||||
|
&= a^2i^2 + abij + acik + abji + b^2j^2 + bcjk + acki + bckj + c^2k^2 \\
|
||||||
|
&= (a^2 + b^2 + c^2)(-1) + ab(ij + ji) + ac(ik + ki) + bc(jk + kj) \\
|
||||||
|
&= -1 + 0 + 0 + 0
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
This property means that *u* behaves similarly to a typical imaginary unit. If we form pseudo-complex numbers of the form $a + b u$, then ${1 + tu \over 1 -\ tu} = \alpha + \beta u$ specifies *some kind of rotation* in terms of the parameter t. Identically as with complex numbers, the inverse rotation is the conjugate $1 -\ tu \over 1 + tu$.
|
||||||
|
|
||||||
|
Another useful feature of quaternion algebra deals with symmetry transformations of the imaginary units. If an imaginary unit (one of *i*, *j*, *k*) is left-multiplied by a quaternion $q$ and right-multiplied by its conjugate $q^*$, then the result is still imaginary. In other words, if p is a vector, then $qpq^*$ is also a vector since *i*, *j*, and *k* form a basis and multiplication distributes over addition. I will not demonstrate this fact, as it requires a large amount of algebra.
|
||||||
|
|
||||||
|
These two features combine to characterize a transformation for a vector quaternion. For a vector *p*, if $q_u(t)$ is a "rotation" as above for a point *u* on the unit sphere, then another vector (the image of *p*) can be described by
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
qpq^* = qpq^{-1}
|
||||||
|
= \left({1 + tu \over 1 -\ tu}\right) p \left({1 -\ tu \over 1 + tu}\right)
|
||||||
|
= (\alpha + \beta u)p(\alpha -\ \beta u) \\[4pt]
|
||||||
|
= (\alpha + \beta u)(\alpha p -\ \beta pu)
|
||||||
|
= \alpha^2 p -\ \alpha \beta pu + \alpha \beta up -\ \beta^2 upu
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
|
||||||
|
Testing a Transformation
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
If this transformation is a rotation, then it should recreate the 2D case which can be described more simply by complex numbers. For example, if $u = k$ and $p = xi + yj$, then this can be expanded as:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
qpq^{-1} &= (\alpha + \beta k)(xi + yj)(\alpha -\ \beta k) \vphantom{\over} \\
|
||||||
|
&= \alpha^2(xi + yj) -\ \alpha \beta (xi + yj)k + \alpha \beta k(xi + yj) -\ \beta^2 k(xi + yj)k
|
||||||
|
\vphantom{\over} \\
|
||||||
|
&= \alpha^2(xi + yj) -\ \alpha \beta(-xj + yi) + \alpha \beta(xj -\ yi) -\ \beta^2(xi + yj)
|
||||||
|
\vphantom{\over} \\
|
||||||
|
&= (\alpha^2 -\ \beta^2)(xi + yj) + 2\alpha \beta(xj - yi)
|
||||||
|
\vphantom{\over} \\
|
||||||
|
&= [(\alpha^2 -\ \beta^2)x -\ 2\alpha \beta y]i + [(\alpha^2 -\ \beta^2)y + 2\alpha \beta x]j
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
If *p* is rewritten as a vector (in the linear algebra sense), then this final expression can be rewritten as a linear transformation of *p*:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{pmatrix}
|
||||||
|
(\alpha^2 -\ \beta^2)x -\ 2 \alpha \beta y \\
|
||||||
|
(\alpha^2 -\ \beta^2)y + 2 \alpha \beta x
|
||||||
|
\end{pmatrix} =
|
||||||
|
\begin{pmatrix}
|
||||||
|
\alpha^2 -\ \beta^2 & -2\alpha \beta \\
|
||||||
|
2\alpha \beta & \alpha^2 -\ \beta^2
|
||||||
|
\end{pmatrix}
|
||||||
|
\begin{pmatrix} x \\ y \end{pmatrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
The matrix which appears above is the square of the matrix $\begin{pmatrix}\alpha & -\beta \\ \beta & \alpha \end{pmatrix}$. This is isomorphic to the complex number $\alpha + \beta i$. Since $\alpha$ and $\beta$ were chosen so to lie on the (pseudo-) complex unit circle, this means that the vector (*x*, *y*) is rotated by $\alpha + \beta i$ twice. This also demonstrates that u specifies the axis of rotation, or equivalently, the plane of a great circle. This means that the "some kind of rotation" specified by $q = {1 + tu \over 1 -\ tu}$ is a rotation around the great circle normal to *u*.
|
||||||
|
|
||||||
|
The double rotation resembles the half-steps of rotation in the complex numbers, where $1 + ti$ performs a dilation, ${1 \over 1 -\ ti}$ reverses it, and together they describe a rotation. Since quaternions do not commute, sandwiching *p* between *q* and its conjugate makes the algebra simpler. The product of a vector with itself should be totally real, as shown above (and equal to the negative of the norm of *p*, the sum of the squares of its components). The rotated *p* shares the same norm as *p*, so it should equal $p^2$. Indeed, this is the case, as
|
||||||
|
|
||||||
|
$$
|
||||||
|
(qpq^{-1})^2 = (qpq^{-1})(qpq^{-1}) = q p p q^{-1} = p^2 q q^{-1} = p^2
|
||||||
|
$$
|
||||||
|
|
||||||
|
As a final remark, due to rotation through quaternions being doubled, the interpolating polynomial used above to smooth out double rotations can also be used here. That is, $q_u(P(t))pq_u^{-1}(P(t))$ rotates *p* by (approximately) the fraction of a turn specified by t through the great circle which intersects the plane normal to *u*.
|
||||||
|
|
||||||
|
|
||||||
|
Closing
|
||||||
|
-------
|
||||||
|
|
||||||
|
It is difficult to find a treatment of rotations which does not hesitate to use the complex exponential $e^{ix} = \cos(x) + i \sin(x)$. The true criterion for rotations is simply that a point lies on the unit circle. Perhaps this contributes to why understanding the 3D situation with quaternions is challenging for many. Past the barrier to entry, I believe them to be rather intuitive. I have outlined some futher benefits of this approach in this post.
|
||||||
|
|
||||||
|
As a disclaimer, this post was inspired by [this video](https://www.youtube.com/watch?v=d4EgbgTm0Bg) by 3blue1brown on YouTube (at least subconsciously; I had not seen the video in years before checking that I wasn't just plagiarizing it). It *also* uses stereographic projections of the circle and sphere to describe rotations in the complex plane and quaternion vector space. However, I feel like it fails to provide an algebraic motivation for quaternions, or even stereography in the first place. Hopefully, my remarks on the algebraic approach can be used to augment the information in the video.
|
||||||
|
|
||||||
|
Diagrams created with GeoGebra. Repository with approximations (as well as GeoGebra files) available [here](https://github.com/queue-miscreant/approx-trig).
|
||||||
411
posts/stereo/2/index.qmd
Normal file
411
posts/stereo/2/index.qmd
Normal file
@ -0,0 +1,411 @@
|
|||||||
|
---
|
||||||
|
format:
|
||||||
|
html:
|
||||||
|
html-math-method: katex
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
Further Notes on Algebraic Stereography
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
In my previous post, I discussed the stereographic projection of a circle as it pertains to complex numbers, as well as its applications in 2D and 3D rotation. In an effort to document more interesting facts about this mathematical object (of which scarce information is immediately available online), I will now elaborate on more of its properties.
|
||||||
|
|
||||||
|
|
||||||
|
Chebyshev Polynomials
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
[Previously](), I derived the [Chebyshev polynomials](https://en.wikipedia.org/wiki/Chebyshev_polynomials) with the archetypal complex exponential. These polynomials express the sines and cosines of a multiple of an angle from the sine and cosine of the base angle.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
\cos(n\theta) = T_n(\cos(\theta)) \\
|
||||||
|
\sin(n\theta) = U_{n-1}(\cos(\theta)) \sin(\theta)
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Where $T_n(t)$ are Chebyshev polynomials of the first kind and $U_n(t)$ are those of the second kind. The complex exponential derivation begins by squaring and developing a second-order recurrence.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
(e^{i\theta})^2 &= (\cos + i\sin)^2 \\
|
||||||
|
&= \cos^2 + 2i\cos \cdot \sin -\ \sin^2 + (0 = \cos^2 + \sin^2 -\ 1) \\
|
||||||
|
&= 2\cos^2 + 2i\cos \cdot \sin -\ 1 \\
|
||||||
|
&= 2\cos \cdot (\cos + i\sin) -\ 1 \\
|
||||||
|
&= 2\cos(\theta)e^{i\theta} -\ 1 \\
|
||||||
|
(e^{i\theta})^{n+2} &= 2\cos(\theta)(e^{i\theta})^{n+1} -\ (e^{i\theta})^n
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
This recurrence relation can then be used to obtain the Chebyshev polynomials, and hence, the expressions using sine and cosine above. Presented this way with such a simple derivation, it appears as though these relationships are inherently trigonometric. However, these polynomials actually have *nothing* to do with sine and cosine. For one, they appear in graph theory, and for two, the importance of the complex exponential is overstated.
|
||||||
|
|
||||||
|
$e^{i\theta}$ really just specifies a point on the complex unit circle. This property is used on the second line to coax the equation into a quadratic in $e^{i\theta}$. This is also the *only* property upon which the recurrence depends; all else is algebraic manipulation.
|
||||||
|
|
||||||
|
|
||||||
|
### Back to the Stereograph
|
||||||
|
|
||||||
|
Knowing this, let's start over with the stereographic projection of the circle:
|
||||||
|
|
||||||
|
$$
|
||||||
|
o_1(t) = {1 + it \over 1 -\ it}
|
||||||
|
= {1 -\ t^2 \over 1 + t^2} + i {2t \over 1 + t^2}
|
||||||
|
= \text{c}_1 + i\text{s}_1
|
||||||
|
$$
|
||||||
|
|
||||||
|
The subscript "1" is because as *t* ranges over $(-\infty, \infty)$, a single loop around the circle is made. Thanks to the properties of complex numbers, it is impossible to grow the norm by exponentiating, and therefore impossible for points to stray from the unit circle. Thus, more loops can be made around the circle by raising this expression to higher powers:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
o_n &= (o_1)^n
|
||||||
|
= \left( {1 + it \over 1 -\ it} \right)^n \\
|
||||||
|
\text{c}_n + i\text{s}_n
|
||||||
|
&= (\text{c}_1 + i\text{s}_1)^n
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
This mirrors raising the complex exponential to a power, i.e., increasing the number of loops *it* makes in the interval $(-\pi, \pi)$. The final line is analogous to de Moivre's formula, but in a form where everything is a ratio of polynomials in *t*. This also means that the Chebyshev polynomials can be obtained directly from these rational expressions:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
o_2 = (o_1)^2 &= (\text{c}_1 + i\text{s}_1)^2 \\
|
||||||
|
&= \text{c}_1^2 + 2i\text{c}_1\text{s}_1 -\ \text{s}_1^2 +
|
||||||
|
(0 = \text{c}_1^2 + \text{s}_1^2 -\ 1) \\
|
||||||
|
&= 2\text{c}_1^2 + 2i\text{c}_1\text{s}_1 -\ 1 \\
|
||||||
|
&= 2\text{c}_1(\text{c}_1 + i\text{s}_1) -\ 1 \\
|
||||||
|
&= 2\text{c}_1 o_1 -\ 1 \\
|
||||||
|
o_2 \cdot (o_1)^n &= 2\text{c}_1 o_1 \cdot (o_1)^n -\ (o_1)^n \\
|
||||||
|
o_{n+2} &= 2\text{c}_1 o_{n+1} -\ o_n \\
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
This matches the earlier recurrence relation with the complex exponential and therefore the recurrence relation of the Chebyshev polynomials. This also means that the the rational functions obey the same relationship as sine and cosine
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{matrix}
|
||||||
|
\begin{gather}
|
||||||
|
\text{c}_n = T_n(\text{c}_1) \\
|
||||||
|
\text{s}_n = U_{n-1}(\text{c}_1) \text{s}_1
|
||||||
|
\end{gather} &
|
||||||
|
\text{where }
|
||||||
|
\text{c}_1 = {1 -\ t^2 \over 1 + t^2}, &
|
||||||
|
\text{s}_1 = {2t \over 1 + t^2}
|
||||||
|
\end{matrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Thus it is shown that the Chebyshev polynomials are tied to (coordinates on) circles, rather than explicitly to trigonometry. It is a bit strange that these polynomials are in terms of rational functions, but no stranger than them being in terms of *ir* rational functions like sine and cosine.
|
||||||
|
|
||||||
|
|
||||||
|
Calculus
|
||||||
|
--------
|
||||||
|
|
||||||
|
Since these functions behave similarly to sine and cosine, one might wonder about the nature of these expressions in the context of calculus. For comparison, the complex exponential (as it is a parallel construction) has a simple derivative:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
e^{it} &= \cos(t) + i\sin(t) \\
|
||||||
|
{d \over dt} e^{it} &= {d \over dt} \cos(t) + {d \over dt} i\sin(t) \\
|
||||||
|
i e^{it} &= -\sin(t) + i\cos(t) \\
|
||||||
|
i[\cos(t) + i\sin(t)] &\stackrel{\checkmark}{=} -\sin(t) + i\cos(t)
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
By applying the chain rule, one can easily differentiate the complex exponential. Since the exponential function is its own derivative, the expression acquires an imaginary coefficient through the chain rule. Meanwhile, the complex stereograph has derivative
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
{d \over dt} o_1(t) &= {d \over dt} {1 + it \over 1 -\ it}
|
||||||
|
= {i(1 -\ it) + i(1 + it) \over (1 -\ it)^2} \\
|
||||||
|
&= {2i \over (1 -\ it)^2}
|
||||||
|
= {2i(1 + it)^2 \over (1 + t^2)^2}
|
||||||
|
= {2i(1 -\ t^2 + 2it) \over (1 + t^2)^2} \\
|
||||||
|
&= {-4t \over (1 + t^2)^2} + i {2(1 -\ t^2) \over (1 + t^2)^2} \\
|
||||||
|
&= {-2 \over 1 + t^2}s_1 + i {2 \over 1 + t^2}c_1 \\
|
||||||
|
&= -(1 + c_1)s_1 + i(1 + c_1)c_1 \\
|
||||||
|
&= i(1 + c_1)o_1
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Just like the complex exponential, an imaginary coefficient falls out. However, the expression also accrues a $1 + c_1$ term, almost like an adjustment factor for its failure to be the complex exponential. Sine and cosine obey a simpler relationship with respect to the derivative, and thus need no adjustment.
|
||||||
|
|
||||||
|
|
||||||
|
Complex Analysis
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Since $o_n$ is a curve which loops around the unit circle *n* times, that possibly suits it to showing a simple result from complex analysis. Integrating along a contour which wraps around a sufficiently nice function's pole (i.e., where its magnitude grows without bound) yields a familiar value. This is easiest to see with $f(z) = 1 / z$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\oint_\Gamma {1 \over z} dz =
|
||||||
|
\int_a^b {\gamma'(t) \over \gamma(t)} dt
|
||||||
|
= 2\pi i
|
||||||
|
$$
|
||||||
|
|
||||||
|
In this example, $\Gamma$ loops once counterclockwise around the pole at *z* = 0; more loops will scale this by a factor according to the number of loops. Normally this is demonstrated with the complex exponential, but will $o_1$ work just as well? If $\Gamma$ is the unit circle, the integral is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\oint_\Gamma {1 \over z} dz =
|
||||||
|
\int_{-\infty}^\infty {o_1'(t) \over o_1(t)} dt
|
||||||
|
= \int_{-\infty}^\infty i(1 + c_1(t)) dt
|
||||||
|
= 2i\int_{-\infty}^\infty {1 \over 1 + t^2} dt
|
||||||
|
$$
|
||||||
|
|
||||||
|
If one has studied their integral identities, the indefinite version of the final integral will be obvious as $\arctan(t)$, which has horizontal asymptotes of $\pi / 2$ and $-\pi / 2$. Therefore, the value of the integral is indeed $2\pi i$.
|
||||||
|
|
||||||
|
If there are *n* loops, then naturally there are *n* of these $2\pi i$s. Fortunately, powers of *o* are more loops around the circle, and the chain and power rules can be used to show:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
{d \over dt} (o_1)^n = n(o_1)^{n-1} {d \over dt} o_1 \\ \\
|
||||||
|
\oint_\Gamma {1 \over z} dz =
|
||||||
|
\int_{-\infty}^\infty {n o_1(t)^{n-1} o_1'(t) \over o_1(t)^n} dt
|
||||||
|
= n \int_{-\infty}^\infty {o_1'(t) \over o_1(t)} dt
|
||||||
|
= 2 \pi i n
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
It is certainly possible to perform these contour integrals along straight lines; in fact, integrating along lines from 1 to *i* to -1 to -*i* similarly deals with an indefinite integral involving arctangent. However, the best one can do to construct more loops with lines is to count each line multiple times, which isn't extraordinarily convincing.
|
||||||
|
|
||||||
|
Perhaps the use of $\infty$ in the integral bounds is also unconvincing, but the integral can be shifted back into the realm of plausibility by considering simpler bounds on $o_2$:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
\oint_\Gamma {1 \over z} dz &=
|
||||||
|
\int_{-1}^1 {2 o_1(t) o_1'(t) \over o_1(t)^2} dt \\
|
||||||
|
&= 2 \int_{-1}^1 {o_1'(t) \over o_1(t)} dt \\
|
||||||
|
&= 2(2i\arctan(1) -\ 2i\arctan(-1)) \\
|
||||||
|
&= 2\pi i
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
This has an additional benefit: using the series form of $1 / (1 + t^2)$ and integrating, one obtains the series form of the arctangent. This series converges for $-1 \le t \le 1$, which happens to match the bounds of integration. The convergence of this series is fairly important, since it is tied to formulas for $\pi$, in particular [Leibniz's formula](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80).
|
||||||
|
|
||||||
|
Were one to integrate with the complex exponential, the bounds $(0, 2\pi)$ would be invoked, since at this point a full loop has been made. But think to yourself -- how do you know that $2\pi$ radians is equivalent to 0 radians? How do you know the period of the complex exponential? The result using stereography relies on neither of these prior results and is directly pinned to a formula for $\pi$ instead an apparent detour through the number e.
|
||||||
|
|
||||||
|
|
||||||
|
Polar Curves
|
||||||
|
------------
|
||||||
|
|
||||||
|
Polar coordinates are useful for expressing for which the distance from the origin is a function of the angle with respect to the positive *x*-axis. They can also be readily converted to parametric forms:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
r(\theta) &\Longleftrightarrow&
|
||||||
|
\begin{matrix}
|
||||||
|
x(\theta) = r \cos(\theta) \\
|
||||||
|
y(\theta) = r \sin(\theta)
|
||||||
|
\end{matrix}
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Polar curves frequently loop in on themselves, and so choosing appropriate bounds for $\theta$ (usually as multiples of $\pi$) is necessary for plotting. Evidently, this is due to the use of sine and cosine in the above parametrization. Fortunately, $s_n$ and $c_n$ (as shown by the calculus above) potentially have much simpler bounds. So what happens when one substitutes the rational functions in place of the trig ones?
|
||||||
|
|
||||||
|
|
||||||
|
### Polar Roses
|
||||||
|
|
||||||
|
[Polar roses](https://en.wikipedia.org/wiki/Rose_(mathematics)) are beautiful shapes which have a simple form when expressed in polar coordinates.
|
||||||
|
|
||||||
|
$$
|
||||||
|
r(\theta) = \cos \left( {p \over q} \cdot \theta \right)
|
||||||
|
$$
|
||||||
|
|
||||||
|
The ratio $p/q$ in least terms uniquely determines the shape of the curve.
|
||||||
|
|
||||||
|
If this weren't this post, you might assume this curve is transcendental since it uses cosine, but you probably know better at this point. The Chebyshev examples above demonstrate the resemblance between $c_n$ and $\cos(n\theta)$. The subscript of $c$ is easiest to work with as an integer, so let $q = 1$.
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
$$
|
||||||
|
x(t) = c_p(t) c_1(t) \qquad y(t) = c_p(t) s_1(t)
|
||||||
|
$$
|
||||||
|
|
||||||
|
will plot a $p/1$ polar rose as t ranges over $(-\infty, \infty)$. Since *t* never reaches infinity, a bite appears to be taken out of the graphs near (-1, 0).
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
$q = 1$ happens to match the subscript *c* term of *x* and *s* term of *y*, so one might wonder whether the other polar curves can be obtained by allowing it to vary as well. And you'd be right.
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
$$
|
||||||
|
x(t) = c_p(t) c_q(t) \qquad y(t) = c_p(t) s_q(t)
|
||||||
|
$$
|
||||||
|
|
||||||
|
will plot a $p/q$ polar rose as t ranges over $(-\infty, \infty)$.
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
Just as with the prior calculus examples, doubling all subscripts of *c* and s will only require t to range over $(-1, 1)$, which removes the ugly bite mark. Perhaps it is also slightly less satisfying, since the fraction $p/q$ directly appears in the typical polar incarnation with cosine. On the other hand, it exposes an important property of these curves: they are all rational.
|
||||||
|
|
||||||
|
This approach lends additional precision to a prospective pseudo-polar coordinate system. In the next examples, I will be using the following notation for compactness:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
R_n(t) = f(t) &\Longleftrightarrow&
|
||||||
|
\begin{matrix}
|
||||||
|
x(t) = f(t) c_n(t) \\
|
||||||
|
y(t) = f(t) s_n(t)
|
||||||
|
\end{matrix}
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
|
||||||
|
### Conic Sections
|
||||||
|
|
||||||
|
The polar equation for a conic section (with a particular unit length occurring somewhere) in terms of its eccentricity $\varepsilon$ is:
|
||||||
|
|
||||||
|
$$
|
||||||
|
r(\theta) = {1 \over 1 -\ \varepsilon \cos(\theta)}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Correspondingly, the rational polar form can be expressed as
|
||||||
|
|
||||||
|
$$
|
||||||
|
R_1(t) = {1 \over 1 -\ \varepsilon c_1}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Since polynomial arithmetic is (slightly) easier to work with than trigonometric identities, it is a matter of pencil-and-paper algebra to recover the implicit form from a parametric one.
|
||||||
|
|
||||||
|
|
||||||
|
#### Parabola ($|\varepsilon| = 1$)
|
||||||
|
|
||||||
|
The conic section with the simplest implicit equation is the parabola. Since $c_n$ is a simple ratio of polynomials in *t*, it is much simpler to recover the implicit equation. For $\varepsilon = 1$,
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
1 -\ c_1 &= 1 -\ {1 -\ t^2 \over 1 + t^2} = {2 t^2 \over 1 + t_1} \\
|
||||||
|
y &= {s_1 \over 1 -\ c_1} = {2t \over 1 + t^2} {1 + t^2 \over 2 t_1} = {1 \over t} \\
|
||||||
|
x &= {c_1 \over 1 -\ c_1} = {1 -\ t^2 \over 1 + t^2} \cdot {1 + t^2 \over 2 t^2} = {1 -\ t^2 \over 2t^2} \\
|
||||||
|
&= {1 \over 2t^2} -\ {1 \over 2} = {y^2 \over 2} -\ {1 \over 2}
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
*x* is a quadratic polynomial in *y*, so trivially the figure formed is a parabola. Technically it is missing the point where $y = 0 (t = \infty)$, and this is not a circumstance where using a higher $c_n$ would help. It is however, similar to the situation where we allow $o_1(\infty) = -1$, and an argument can be made to waive away any concerns one might have.
|
||||||
|
|
||||||
|
|
||||||
|
#### Ellipse ($|\varepsilon| < 1$)
|
||||||
|
|
||||||
|
Ellipses are next. The simplest fraction between zero and one is 1/2, so for $\varepsilon = 1/2$,
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
1 -\ {1 \over 2}c_1 &= 1 -\ {1 \over 2} \cdot {1 -\ t^2 \over 1 + t^2} = {3 t^2 + 1 \over 2 + 2t^2} \\
|
||||||
|
y &= {s_1 \over 1 -\ {1 \over 2}c_1} = {4t \over 3t^2 + 1} \\
|
||||||
|
x &= {c_1 \over 1 -\ {1 \over 2}c_1} = {2 -\ 2t^2 \over 3t^2 + 1} \\ \\
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
There isn't an obvious way to combine products of *x* and *y* into a single equation. However, we do know that such an equation must have total degree 2. Any monomial of degree 2 must has a squared denominator, but must be able to add with the lower-degree terms. Therefore, the numerator of the sum of these degree 2 terms has the (degree 1) denominator as a factor.
|
||||||
|
|
||||||
|
Since the coefficient of $t^4$ in $x^2$ is 4, it must be multiplied by a multiple of 3 (the coefficient of $t^2$ in the denominator) for any factorization to occur.
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
x^2 &= {4 -\ 8t^2 + 4t^4 \over (3t^2 + 1)^2} \qquad
|
||||||
|
y^2 = {16t^2 \over (3t^2 + 1)^2} \\ \\
|
||||||
|
3x^2 + 4y^2 &=
|
||||||
|
{12 -\ 24t^2 + 12t^4 + 64t^2 \over (3t^2 + 1)^2} \\
|
||||||
|
&= {12 -\ 40t^2 + 12t^4 \over (3t^2 + 1)^2} \\
|
||||||
|
&= {(4t^2 + 12) (3t^2 + 1) \over (3t^2 + 1)^2} \\
|
||||||
|
&= {4t^2 + 12 \over 3t^2 + 1}
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
The linear term *t* occurs nowhere in the result, so this is clearly some combination of *x* and a constant. By the previous line of thought, the constant term must be a multiple of 4, and picking the smallest option finally results in the implicit form:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
4 &= {4(3t^2 + 1) \over 3t^2 + 1} = {12t^2 + 4) \over 3t^2 + 1} \\
|
||||||
|
{4t^2 + 12 \over 3t^2 + 1} -\ 4 &= {8 -\ 8t^2 \over 3t^2 + 1} = 4x \\ \\
|
||||||
|
3x^2 + 4y^2 &= 4x + 4 \\
|
||||||
|
3x^2 + 4y^2 -\ 4x -\ 4 &= 0
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
Notably, the coefficients of x and y are 3 and 4; simultaneously, $o_1(\varepsilon) = o_1(1/2) = {3 \over 5} + i{4 \over 5}$. This binds together three concepts: the simplest case of the Pythagorean theorem, the 3-4-5 right triangle; the coefficients of the implicit form; and the role of eccentricity with respect to stereography.
|
||||||
|
|
||||||
|
|
||||||
|
#### Hyperbola ($|\varepsilon| > 1$)
|
||||||
|
|
||||||
|
As evidenced by the bound on the eccentricity above, hyperbolae are in some way the inverses of ellipses. Since $o_1(2)$ is a reflection of $o_1(1/2)$, you might think the implicit equation for $\varepsilon = 2$ to be the same, but with a flipped sign or two. Unfortunately, you'd be wrong.
|
||||||
|
|
||||||
|
:::: {layout-ncol = "2"}
|
||||||
|
::: {}
|
||||||
|
![]()
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: {}
|
||||||
|
$$
|
||||||
|
\begin{align*}
|
||||||
|
x &= {c_1 \over 1 -\ 2c_1} = {1 -\ t^2 \over 3t^2 -\ 1} \\
|
||||||
|
y &= {s_1 \over 1 -\ 2c_1} = {2t \over 3t^2 -\ 1} \\ \\
|
||||||
|
3x^2 -\ y^2 &= {3 -\ 6t^2 + 3t^4 -\ 4t^2 \over 3t^2 -\ 1} \\
|
||||||
|
&= {3 -\ 10t^2 + 3t^4 \over 3t^2 -\ 1} \\
|
||||||
|
&= {(t^2 -\ 3)(3t^2 -\ 1) \over (3t^2 -\ 1)^2 } \\
|
||||||
|
&= {t^2 -\ 3 \over 3t^2 -\ 1 } \\
|
||||||
|
&= {3t^2 -\ 1 + t^2 -\ 3 \over 3t^2 -\ 1 } -\ 1 \\
|
||||||
|
&= {4t^2 -\ 4 \over 3t^2 -\ 1 } -\ 1
|
||||||
|
= -4x -\ 1
|
||||||
|
\end{align*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
$$
|
||||||
|
3x^2 -\ y^2 + 4x + 1 = 0
|
||||||
|
$$
|
||||||
|
:::
|
||||||
|
::::
|
||||||
|
|
||||||
|
At the very least, the occurrences of 1 in the place of 4 have a simple explanation: 1 = 4 - 3. This reinforces the previous example's link to the Pythagorean triple 3-4-5.
|
||||||
|
|
||||||
|
|
||||||
|
### Archimedean Spiral
|
||||||
|
|
||||||
|
Arguably the simplest (non-circular) polar curve is $r(\theta) = \theta$. This is also the unit [Archimedean spiral](https://en.wikipedia.org/wiki/Archimedean_spiral). Since the curve is defined by a constant turning, this is a natural application of the properties of sine and cosine. The closest equivalent in rational polar coordinates is $R_1(t) = t$. But this can be converted to an implicit form:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{gather*}
|
||||||
|
x = tc_1 \qquad y = ts_1 \\ \\
|
||||||
|
x^2 + y^2 = t^2(c_1^2 + s_1^2) = t^2\\
|
||||||
|
y = {2t^2 \over 1 + t^2} = {2(x^2 + y^2) \over 1 + (x^2 + y^2)} \\ \\
|
||||||
|
(1 + x^2 + y^2)y = 2(x^2 + y^2)
|
||||||
|
\end{gather*}
|
||||||
|
$$
|
||||||
|
|
||||||
|
The curve produced by this equation is a [right strophoid](https://mathworld.wolfram.com/RightStrophoid.html) with a node at (0, 1) and asymptote $y = 2$. This form suggests something interesting about this curve: it approximates the Archimedean spiral (specifically the one with polar equation $r(\theta) = \theta/2$). Indeed, the sequence of curves with parametrization $R_n(t) = 2nt$ approximate the (unit) spiral for larger *n*, as can be seen in the following video.
|
||||||
|
|
||||||
|
![]()
|
||||||
|
|
||||||
|
Since R necessarily defines a rational curve, the curves will never be equal, just as any stretching of $c_n$ will never exactly become cosine.
|
||||||
|
|
||||||
|
|
||||||
|
Closing
|
||||||
|
-------
|
||||||
|
|
||||||
|
There is nothing wrong with using sine, cosine, the exponential function, or any of the entailing math, especially in a calculus setting. The benefit to using these functions is their constant "velocity" around the circle as their parameter varies continuously. Indeed, velocity, change, and continuity are some of the concepts which calculus deals with in the first place. Further, nearly every modern scientific calculator in the world features buttons for trigonometric functions.
|
||||||
|
|
||||||
|
We can however be misled by their apparent omnipresence. Stereographic projection has been around for *millennia*; just because Newton invented calculus 3.5 centuries ago does not mean every formula needs to be rewritten in its language. For example (and as previously mentioned), the Chebyshev polynomials are tied to the multiplication of two complex numbers whose norm cannot grow. This explanation requires only an understanding of complex number arithmetic, and not of trigonometry and dividing angles. Many other instances of sine and cosine merely rely on a number (or ratio) of loops around a circle, rather than their properties in calculus, and for these instances it will obviously do to "stay rational".
|
||||||
|
|
||||||
|
One of my favorite things to plot as a kid were polar roses, so it was somewhat of a shock to see that they are, in fact, rational curves. On the other hand, their rationality follows immediately from the rationality of the circle (which itself follows from the existence of Pythagorean triples). If I were more experienced with manipulating Chebyshev polynomials or willing to set up a linear system in (way too) many terms, I might have considered attempting to find an implicit form for them as well. However, only the latter approach would involve polynomial arithmetic and therefore be relevant to the contents of this post.
|
||||||
|
|
||||||
|
Diagrams created with Sympy and Matplotlib.
|
||||||
Loading…
x
Reference in New Issue
Block a user