diff --git a/_freeze/posts/math/chebyshev/1/index/execute-results/html.json b/_freeze/posts/math/chebyshev/1/index/execute-results/html.json
index abf3023..aaad622 100644
--- a/_freeze/posts/math/chebyshev/1/index/execute-results/html.json
+++ b/_freeze/posts/math/chebyshev/1/index/execute-results/html.json
@@ -1,8 +1,8 @@
{
- "hash": "2a7732da8eeb3c7a2eec0ae77f9ce94d",
+ "hash": "095ef08df3bca1341254e0ecfc029767",
"result": {
"engine": "jupyter",
- "markdown": "---\ntitle: \"Generating Polynomials, Part 1: Regular Constructibility\"\ndescription: |\n What kinds of regular polygons are constructible with compass and straightedge?\nformat:\n html:\n html-math-method: katex\ndate: \"2021-08-18\"\ndate-modified: \"2025-06-17\"\ncategories:\n - geometry\n - generating functions\n - algebra\n - python\n---\n\n\n\n\n\n[Recently](/posts/math/misc/platonic-volume), I used coordinate-free geometry to derive\n the volumes of the Platonic solids, a problem which was very accessible to the ancient Greeks.\nOn the other hand, they found certain problems regarding which figures can be constructed via\n compass and straightedge to be very difficult. For example, they struggled with problems\n like [doubling the cube](https://en.wikipedia.org/wiki/Doubling_the_cube)\n or [squaring the circle](https://en.wikipedia.org/wiki/Squaring_the_circle),\n which are known (through circa 19th century mathematics) to be impossible.\nHowever, before even extending planar geometry by a third dimension or\n calculating the areas of circles, a simpler problem becomes apparent.\nNamely, what kinds of regular polygons are constructible?\n\n\nRegular Geometry and a Complex Series\n-------------------------------------\n\nWhen constructing a regular polygon, one wants a ratio between the length of a edge\n and the distance from a vertex to the center of the figure.\n\n{.wide}\n\nIn a convex polygon, the total central angle is always one full turn, or 2π radians.\nThe central angle of a regular *n*-gon is ${2\\pi \\over n}$ radians,\n and the green angle above (which we'll call *θ*) is half of that.\nThis means that the ratio we're looking for is $\\sin(\\theta) = \\sin(\\pi / n)$.\nWe can multiply by *n* inside the function on both sides to give\n $\\sin(n\\theta) = \\sin(\\pi) = 0$.\nTherefore, constructing a polygon is actually equivalent to solving this equation,\n and we can rephrase the question as how to express $\\sin(n\\theta)$ (and $\\cos(n\\theta)$).\n\n\n### Complex Recursion\n\nThanks to [Euler's formula](https://en.wikipedia.org/wiki/Euler%27s_formula)\n and [de Moivre's formula](https://en.wikipedia.org/wiki/De_Moivre%27s_formula),\n the expressions we're looking for can be phrased in terms of the complex exponential.\n\n$$\n\\begin{align*}\n e^{i\\theta}\n &= \\text{cis}(\\theta) = \\cos(\\theta) + i\\sin(\\theta)\n & \\text{ Euler's formula}\n \\\\\n \\text{cis}(n \\theta) = e^{i(n\\theta)}\n &= e^{(i\\theta)n} = {(e^{i\\theta})}^n = \\text{cis}(\\theta)^n\n \\\\\n \\cos(n \\theta) + i\\sin(n \\theta)\n &= (\\cos(\\theta) + i\\sin(\\theta))^n\n & \\text{ de Moivre's formula}\n\\end{align*}\n$$\n\nDe Moivre's formula for $n = 2$ gives\n\n$$\n\\begin{align*}\n \\text{cis}(\\theta)^2\n &= (\\text{c} + i\\text{s})^2\n \\\\\n &= \\text{c}^2 + 2i\\text{cs} - \\text{s}^2 + (0 = \\text{c}^2 + \\text{s}^2 - 1)\n \\\\\n &= 2\\text{c}^2 + 2i\\text{cs} - 1\n \\\\\n &= 2\\text{c}(\\text{c} + i\\text{s}) - 1\n \\\\\n &= 2\\cos(\\theta)\\text{cis}(\\theta) - 1\n\\end{align*}\n$$\n\nThis can easily be massaged into a recurrence relation.\n\n$$\n\\begin{align*}\n \\text{cis}(\\theta)^2\n &= 2\\cos(\\theta)\\text{cis}(\\theta) - 1\n \\\\\n \\text{cis}(\\theta)^{n+2}\n &= 2\\cos(\\theta)\\text{cis}(\\theta)^{n+1} - \\text{cis}(\\theta)^n\n \\\\\n \\text{cis}((n+2)\\theta)\n &= 2\\cos(\\theta)\\text{cis}((n+1)\\theta) - \\text{cis}(n\\theta)\n\\end{align*}\n$$\n\nRecurrence relations like this one are powerful.\nThrough some fairly straightforward summatory manipulations,\n the sequence can be interpreted as the coefficients in a Taylor series,\n giving a [generating function](https://en.wikipedia.org/wiki/Generating_function).\nCall this function *F*. Then,\n\n$$\n\\begin{align*}\n \\sum_{n=0}^\\infty \\text{cis}((n+2)\\theta)x^n\n &= 2\\cos(\\theta) \\sum_{n=0}^\\infty \\text{cis}((n+1)\\theta) x^n\n - \\sum_{n=0}^\\infty \\text{cis}(n\\theta) x^n\n \\\\\n {F(x; \\text{cis}(\\theta)) - 1 - x\\text{cis}(\\theta) \\over x^2}\n &= 2\\cos(\\theta) {F(x; \\text{cis}(\\theta)) - 1 \\over x}\n - F(x; \\text{cis}(\\theta))\n \\\\[10pt]\n F - 1 - x\\text{cis}(\\theta)\n &= 2\\cos(\\theta) x (F - 1)\n - x^2 F\n \\\\\n F - 2\\cos(\\theta) x F + x^2 F\n &= 1 + x(\\text{cis}(\\theta) - 2\\cos(\\theta))\n \\\\[10pt]\n F(x; \\text{cis}(\\theta))\n &= {1 + x(\\text{cis}(\\theta) - 2\\cos(\\theta)) \\over\n 1 - 2\\cos(\\theta)x + x^2}\n\\end{align*}\n$$\n\nSince $\\text{cis}$ is a complex function, we can separate *F* into real and imaginary parts.\nConveniently, these correspond to $\\cos(n\\theta)$ and $\\sin(n\\theta)$, respectively.\n\n$$\n\\begin{align*}\n \\Re[ F(x; \\text{cis}(\\theta)) ]\n &= {1 + x(\\cos(\\theta) - 2\\cos(\\theta)) \\over 1 - 2\\cos(\\theta)x + x^2}\n \\\\\n &= {1 - x\\cos(\\theta) \\over 1 - 2\\cos(\\theta)x + x^2} = A(x; \\cos(\\theta))\n \\\\\n \\Im[ F(x; \\text{cis}(\\theta)) ]\n &= {x \\sin(\\theta) \\over 1 - 2\\cos(\\theta)x + x^2} = B(x; \\cos(\\theta))\\sin(\\theta)\n\\end{align*}\n$$\n\nIn this form, it becomes obvious that the even though the generating function *F* was originally\n parametrized by $\\text{cis}(\\theta)$, *A* and *B* are parametrized only by $\\cos(\\theta)$.\nExtracting the coefficients of *x* yields an expression for $\\cos(n\\theta)$ and $\\sin(n\\theta)$\n in terms of $\\cos(\\theta)$ (and in the latter case, a common factor of $\\sin(\\theta)$).\n\nIf $\\cos(\\theta)$ in *A* and *B* is replaced with the parameter *z*, then all trigonometric functions\n are removed from the equation, and we are left with only polynomials[^1].\nThese polynomials are [*Chebyshev polynomials*](https://en.wikipedia.org/wiki/Chebyshev_polynomial)\n *of the first (A) and second (B) kind*.\nIn actuality, the polynomials of the second kind are typically offset by 1\n (the x in the numerator of *B* is omitted).\nHowever, retaining this term makes indexing consistent between *A* and *B*\n (and will make things clearer later).\n\n[^1]:\n This can actually be observed as early as the recurrence relation.\n\n $$\n \\begin{align*}\n \\text{cis}(\\theta)^{n+2}\n &= 2\\cos(\\theta)\\text{cis}(\\theta)^{n+1} - \\text{cis}(\\theta)^n\n \\\\\n a_{n+2}\n &= 2 z a_{n+1} - a_n\n \\\\\n \\Re[ a_0 ]\n &= 1,~~ \\Im[ a_0 ] = 0\n \\\\\n \\Re[ a_1 ]\n &= z,~~ \\Im[ a_1 ] = 1 \\cdot \\sin(\\theta)\n \\end{align*}\n $$\n\n\nWe were primarily interested in $\\sin(n\\theta)$, so let's tabulate\n the first few polynomials of the second kind (at $z / 2$).\n\n::: {#tbl-chebyshevu .cell .plain tbl-cap='[OEIS A049310](http://oeis.org/A049310)' execution_count=3}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=2}\n*n* $[x^n]B(x; z / 2) = U_{n - 1}(z / 2)$ Factored\n----- --------------------------------------------- -------------------------------------------------------------------------------------------------\n0 $0$ $0$\n1 $1$ $1$\n2 $z$ $z$\n3 $z^{2} - 1$ $\\left(z - 1\\right) \\left(z + 1\\right)$\n4 $z^{3} - 2 z$ $z \\left(z^{2} - 2\\right)$\n5 $z^{4} - 3 z^{2} + 1$ $\\left(z^{2} - z - 1\\right) \\left(z^{2} + z - 1\\right)$\n6 $z^{5} - 4 z^{3} + 3 z$ $z \\left(z - 1\\right) \\left(z + 1\\right) \\left(z^{2} - 3\\right)$\n7 $z^{6} - 5 z^{4} + 6 z^{2} - 1$ $\\left(z^{3} - z^{2} - 2 z + 1\\right) \\left(z^{3} + z^{2} - 2 z - 1\\right)$\n8 $z^{7} - 6 z^{5} + 10 z^{3} - 4 z$ $z \\left(z^{2} - 2\\right) \\left(z^{4} - 4 z^{2} + 2\\right)$\n9 $z^{8} - 7 z^{6} + 15 z^{4} - 10 z^{2} + 1$ $\\left(z - 1\\right) \\left(z + 1\\right) \\left(z^{3} - 3 z - 1\\right) \\left(z^{3} - 3 z + 1\\right)$\n10 $z^{9} - 8 z^{7} + 21 z^{5} - 20 z^{3} + 5 z$ $z \\left(z^{2} - z - 1\\right) \\left(z^{2} + z - 1\\right) \\left(z^{4} - 5 z^{2} + 5\\right)$\n:::\n:::\n\n\nEvaluating the polynomials at $z / 2$ cancels the 2 in the denominator (and recurrence),\n making these expressions much simpler.\nThis evaluation has an interpretation in terms of the previous diagram --\n recall we used *half* the length of a side as a leg of the right triangle.\nFor a unit circumradius, the side length itself is then $2\\sin( {\\pi / n} )$.\nTo compensate for this doubling, the Chebyshev polynomial must be evaluated at half its normal argument.\n\n\n### Back on the Plane\n\nThe constructibility criterion is deeply connected to the Chebyshev polynomials.\nIn compass and straightedge constructions, one only has access to linear forms (lines)\n and quadratic forms (circles).\nThis means that a figure is constructible if and only if the root can be expressed using\n normal arithmetic (which is linear) and square roots (which are quadratic).\n\n\n#### Pentagons\n\nLet's look at a regular pentagon.\nThe relevant polynomial is\n\n$$\n[x^5]B ( x; z / 2 )\n = z^4 - 3z^2 + 1\n = (z^2 - z - 1) (z^2 + z - 1)\n$$\n\nAccording to how we derived this series, when $z = 2\\cos(\\theta)$, the roots of this polynomial\n correspond to when $\\sin(5\\theta) / \\sin(\\theta) = 0$.\nThis relation itself is true when $\\theta = \\pi / 5$, since $\\sin(5 \\pi / 5) = 0$.\n\nOne of the factors must therefore be the minimal polynomial of $2\\cos(\\pi / 5 )$.\nThe former happens to be correct correct, since $2\\cos( \\pi / 5 ) = \\varphi$, the golden ratio.\nNote that the second factor is the first evaluated at -*z*.\n\n\n#### Heptagons\n\nAn example of where constructability fails is for $2\\cos( \\pi / 7 )$.\n\n$$\n\\begin{align*}\n [x^7]B ( x; z / 2 )\n &= z^6 - 5 z^4 + 6 z^2 - 1\n \\\\\n &= ( z^3 - z^2 - 2 z + 1 ) ( z^3 + z^2 - 2 z - 1 )\n\\end{align*}\n$$\n\nWhichever is the minimal polynomial (the former), it is a cubic, and constructing\n a regular heptagon is equivalent to solving it for *z*.\nBut there are no (nondegenerate) cubics that one can produce via compass and straightedge,\n and all constructions necessarily fail.\n\n\n#### Decagons\n\nOne might think the same of $2\\cos(\\pi /10 )$\n\n$$\n\\begin{align*}\n [x^{10}]B ( x; z / 2 )\n &= z^9 - 8 z^7 + 21 z^5 - 20 z^3 + 5 z\n \\\\\n &= z ( z^2 - z - 1 )( z^2 + z - 1 )( z^4 - 5 z^2 + 5 )\n\\end{align*}\n$$\n\nThis expression also contains the polynomials for $2\\cos( \\pi / 5 )$.\nThis is because a regular decagon would contain two disjoint regular pentagons,\n produced by connecting every other vertex.\n\n\n\nThe polynomial which actually corresponds to $2\\cos( \\pi / 10 )$ is the quartic,\n which seems to suggest that it will require a fourth root and somehow decagons are not constructible.\nHowever, it can be solved by completing the square...\n\n$$\n\\begin{align*}\n z^4 - 5z^2 &= -5\n \\\\\n z^4 - 5z^2 + (5/2)^2 &= -5 + (5/2)^2\n \\\\\n ( z^2 - 5/2)^2 &= {25 - 20 \\over 4}\n \\\\\n ( z^2 - 5/2) &= {\\sqrt 5 \\over 2}\n \\\\\n z^2 &= {5 \\over 2} + {\\sqrt 5 \\over 2}\n \\\\\n z &= \\sqrt{ {5 + \\sqrt 5 \\over 2} }\n\\end{align*}\n$$\n\n...and we can breathe a sigh of relief.\n\n\nThe Triangle behind Regular Polygons\n------------------------------------\n\nPreferring *z* to be halved in $B(x; z/2)$ makes something else more evident.\nObserve these four rows of the Chebyshev polynomials\n\n::: {#fa18ec11 .cell .plain execution_count=4}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=3}\n*n* $[x^n]B(x; z / 2)$ *k* $[z^{k}][x^n]B(x; z / 2)$\n----- ------------------------------- ----- ---------------------------\n4 $z^{3} - 2 z$ 3 1\n5 $z^{4} - 3 z^{2} + 1$ 2 -3\n6 $z^{5} - 4 z^{3} + 3 z$ 1 3\n7 $z^{6} - 5 z^{4} + 6 z^{2} - 1$ 0 -1\n:::\n:::\n\n\nThe last column looks like an alternating row of Pascal's triangle\n (namely, ${n - \\lfloor {k / 2} \\rfloor - 1 \\choose k}(-1)^k$).\nThis resemblance can be made more apparent by listing the coefficients of the polynomials in a table.\n\n::: {#cc29c0f1 .cell .plain execution_count=5}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=4}\n n $z^9$ $z^8$ $z^7$ $z^6$ $z^5$ $z^4$ $z^3$ $z^2$ $z$ $1$\n--- ------------------------------ ------------------------------------ ------------------------------------- ----------------------------------- ----------------------------------- ----------------------------------- ------------------------------------ ------------------------------------- ------------------------------------- -------------------------------------\n 1 1\n 2 1 0\n 3 1 0 -1\n 4 1 0 -2 0\n 5 1 0 -3 0 1\n 6 1 0 -4 0 3 0\n 7 1 0 -5 0 6 0 -1\n 8 1 0 -6 0 10 0 -4 0\n 9 1 0 -7 0 15 0 -10 0 1\n 10 1 0 -8 0 21 0 -20 0 5 0\n:::\n:::\n\n\nThough they alternate in sign, the rows of Pascal's triangle appear along diagonals,\n which I have marked in rainbow.\nMeanwhile, alternating versions of the naturals (1, 2, 3, 4...),\n the triangular numbers (1, 3, 6, 10...),\n the tetrahedral numbers (1, 4, 10, 20...), etc.\n are present along the columns, albeit spaced out by 0's.\n\nThe relationship of the Chebyshev polynomials to the triangle is easier to see if\n the coefficient extraction of $B(x; z / 2)$ is reversed.\nIn other words, we extract *z* before extracting *x*.\n\n$$\n\\begin{align*}\n B(x; z / 2) &= {x \\over 1 - zx + x^2}\n = {x \\over 1 + x^2 - zx}\n = {x \\over 1 + x^2}\n \\cdot {1 \\over {1 + x^2 \\over 1 + x^2} - z{x \\over 1 + x^2}}\n \\\\[10pt]\n [z^n]B(x; z / 2) &= {x \\over 1 + x^2} [z^n] {1 \\over 1 - z{x \\over 1 + x^2}}\n = {x \\over 1 + x^2} \\left( {x \\over 1 + x^2} \\right)^n\n \\\\\n &= \\left( {x \\over 1 + x^2} \\right)^{n+1}\n = x^{n+1} (1 + x^2)^{-n - 1}\n \\\\\n &= x^{n+1} \\sum_{k=0}^\\infty {-n - 1 \\choose k}(x^2)^k\n \\quad \\text{Binomial theorem}\n\\end{align*}\n$$\n\nWhile the use of the binomial theorem is more than enough to justify\n the appearance of Pascal's triangle (along with explaining the 0's),\n I'll simplify further to explicitly show the alternating signs.\n\n$$\n\\begin{align*}\n {(-n - 1)_k} &= (-n - 1)(-n - 2) \\cdots (-n - k)\n \\\\\n &= (-1)^k (n + k)(n + k - 1) \\cdots (n + 1)\n \\\\\n &= (-1)^k (n + k)_k\n \\\\\n \\implies {-n - 1 \\choose k}\n &= {n + k \\choose k}(-1)^k\n \\\\[10pt]\n [z^n]B(x; z / 2)\n &= x^{n+1} \\sum_{k=0}^\\infty {n + k \\choose k} (-1)^k x^{2k}\n\\end{align*}\n$$\n\nSquinting hard enough, the binomial coefficient is similar to the earlier\n which gave the third row of Pascal's triangle.\nIf k is fixed, then this expression actually generates the antidiagonal entries\n of the coefficient table, which are the columns with uniform sign.\nThe alternation instead occurs between antidiagonals (one is all positive,\n the next is 0's, the next is all negative, etc.).\nThe initial $x^{n+1}$ lags these sequences so that they reproduce the triangle.\n\n\n### Imagined Transmutation\n\nThe generating function of the Chebyshev polynomials resembles other two term recurrences.\nFor example, the Fibonacci numbers have generating function\n\n$$\n\\sum_{n = 0}^\\infty \\text{Fib}_n x^n = {1 \\over 1 - x - x^2}\n$$\n\nThis resemblance can be made explicit with a simple algebraic manipulation.\n\n$$\n\\begin{align*}\n B(ix; -iz / 2)\n &= {1 \\over 1 -\\ (-i z)(ix) + (ix)^2}\n = {1 \\over 1 -\\ (-i^2) z x + (i^2)(x^2)}\n \\\\\n &= {1 \\over 1 -\\ z x -\\ x^2}\n\\end{align*}\n$$\n\nIf $z = 1$, these two generating functions are equal.\nThe same can be said for $z = 2$ with the generating function of the Pell numbers,\n and so on for higher recurrences (corresponding to metallic means) for higher integral *z*.\n\nIn terms of the Chebyshev polynomials, this series manipulation removes the alternation in\n the coefficients of $U_n$, restoring Pascal's triangle to its nonalternating form.\nRelated to the previous point, it is possible to find the Fibonacci numbers (Pell numbers, etc.)\n in Pascal's triangle, which you can read more about\n [here](http://users.dimi.uniud.it/~giacomo.dellariccia/Glossary/Pascal/Koshy2011.pdf).\n\n\nManipulating the Series\n-----------------------\n\nLook back to the table of $U_{n - 1}(z / 2)$ (@tbl-chebyshevu).\nWhen I brought up $U_{10 - 1}(z / 2)$ and decagons, I pointed out their relationship to pentagons\n as an explanation for why $U_{5 -\\ 1}(z / 2)$ appears as a factor.\nConveniently, $U_{2 -\\ 1}(z / 2) = z$ is also a factor, and 2 is likewise a factor of 10.\n\nThis pattern is present throughout the table; $n = 6$ contains factors for\n $n = 2 \\text{ and } 3$ and the prime numbers have no smaller factors.\nIf this observation is legitimate, call the newest term $f_n(z)$\n and denote $p_n(z) = U_{n -\\ 1}( z / 2 )$.\n\n\n### Factorization Attempts\n\nThe relationship between $p_n$ and the intermediate $f_d$, where *d* is a divisor of *n*,\n can be made explicit by a [Möbius inversion](https://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula).\n\n$$\n\\begin{align*}\n p_n(z) &= \\prod_{d|n} f_n(z)\n \\\\\n \\log( p_n(z) )\n &= \\log \\left( \\prod_{d|n} f_d(z) \\right)\n = \\sum_{d|n} \\log( f_d(z) )\n \\\\\n \\log( f_n(z) ) &= \\sum_{d|n} { \\mu \\left({n \\over d} \\right)}\n \\log( p_d(z) )\n \\\\\n f_n(z) &= \\prod_{d|n} p_d(z)^{ \\mu (n / d) }\n \\\\[10pt]\n f_6(z) = g_6(z)\n &= p_6(z)^{\\mu(1)}\n p_3(z)^{\\mu(2)}\n p_2(z)^{\\mu(3)}\n \\\\\n &= {p_6(z) \\over p_3(z) p_2(z)}\n\\end{align*}\n$$\n\nUnfortunately, it's difficult to apply this technique across our whole series.\nMöbius inversion over series typically uses more advanced generating functions such as\n [Dirichlet series](https://en.wikipedia.org/wiki/Dirichlet_series#Formal_Dirichlet_series)\n or [Lambert series](https://en.wikipedia.org/wiki/Lambert_series).\nHowever, naively reaching for these fails for two reasons:\n\n- We built our series of polynomials on a recurrence relation, and these series\n are opaque to such manipulations.\n- To do a proper Möbius inversion, we need these kinds of series over the *logarithm*\n of each polynomial (*B* is a series over the polynomials themselves).\n\nIgnoring these (and if you're in the mood for awful-looking math) you may note\n the Lambert equivalence[^2]:\n\n[^2]:\n This equivalence applies to other polynomial series obeying the same factorization rule\n such as the [cyclotomic polynomials](https://en.wikipedia.org/wiki/Cyclotomic_polynomial).\n\n$$\n\\begin{align*}\n \\log( p_n(z) )\n &= \\sum_{d|n} \\log( f_d(z) )\n \\\\\n \\sum_{n = 1}^\\infty \\log( p_n ) x^n\n &= \\sum_{n = 1}^\\infty \\sum_{d|n} \\log( f_d ) x^n\n \\\\\n &= \\sum_{k = 1}^\\infty \\sum_{m = 1}^\\infty \\log( f_m ) x^{m k}\n \\\\\n &= \\sum_{m = 1}^\\infty \\log( f_m ) \\sum_{k = 1}^\\infty (x^m)^k\n \\\\\n &= \\sum_{m = 1}^\\infty \\log( f_m ) {x^m \\over 1 - x^m}\n\\end{align*}\n$$\n\nEither way, the number-theoretic properties of this sequence are difficult to ascertain\n without advanced techniques.\nIf research has been done, it is not easily available in the OEIS.\n\n\n### Total Degrees\n\nIt can be also be observed that the new term is symmetric ($f(z) = f(-z)$), and is therefore\n either irreducible or the product of polynomial and its reflection (potentially negated).\nFor example,\n\n$$\np_9(z) = \\left\\{\n\\begin{matrix}\n (z - 1)(z + 1)\n & \\cdot\n & (z^3 - 3z - 1)(z^3 - 3z + 1)\n \\\\\n \\shortparallel && \\shortparallel\n \\\\\n f_3(z)\n & \\cdot\n & f_9(z)\n \\\\\n \\shortparallel && \\shortparallel\n \\\\\n g_3(z) \\cdot g_3(-z)\n & \\cdot\n & g_9(z) \\cdot -g_9(-z)\n\\end{matrix}\n\\right.\n$$\n\nThese factor polynomials $g_n$ are the minimal polynomials of $2\\cos( \\pi / n )$.\n\nMultiplying these minimal polynomials by their reflection can be observed in the Chebyshev polynomials\n for $n = 3, 5, 7, 9$, strongly implying that it occurs on the odd terms.\nAssuming this is true, we have\n\n$$\nf_n(z) = \\begin{cases}\n g_n(z) & \\text{$n$ is even}\n \\\\\n g_n(z)g_n(-z)\n & \\text{$n$ is odd and ${\\deg(f_n) \\over 2}$ is even}\n \\\\\n -g_n(z)g_n(-z)\n & \\text{$n$ is odd and ${\\deg(f_n) \\over 2}$ is odd}\n\\end{cases}\n$$\n\nWithout resorting to any advanced techniques, the degrees of $f_n$ are\n not too difficult to work out.\nThe degree of $p_n(z)$ is $n -\\ 1$, which is also the degree of $f_n(z)$ if *n* is prime.\nIf *n* is composite, then the degree of $f_n(z)$ is $n -\\ 1$ minus the degrees\n of the divisors of $n -\\ 1$.\nThis leaves behind how many numbers less than *n* are coprime to *n*.\nTherefore $\\deg(f_n) = \\phi(n)$, the\n [Euler totient function](https://en.wikipedia.org/wiki/Euler_totient_function) of the index.\n\nThe totient function can be used to examine the parity of *n*.\nIf *n* is odd, it is coprime to 2 and all even numbers.\nThe introduced factor of 2 to 2*n* removes the evens from the totient, but this is compensated by\n the addition of the odd multiples of old numbers coprime to *n* and new primes.\nThis means that $\\phi(2n) = \\phi(n)$ for odd *n* (other than 1).\n\nThe same argument can be used for even *n*: there are as many odd numbers from 0 to *n* as there are\n from *n* to 2*n*, and there are an equal number of numbers coprime to 2*n* in either interval.\nTherefore, $\\phi(2n) = 2\\phi(n)$ for even *n*.\n\nThis collapses all cases of the conditional factorization of $f_n$ into one,\n and the degrees of $g_n$ are\n\n$$\n\\begin{align*}\n \\deg( g_n(z) )\n &= \\begin{cases}\n \\deg( f_n(z) )\n = \\phi(n)\n & n \\text{ is even} & \\implies \\phi(n) = \\phi(2n) / 2\n \\\\\n \\deg( f_n(z) ) / 2\n = \\phi(n) / 2\n & n \\text{ is odd} & \\implies \\phi(n) / 2 = \\phi(2n) / 2\n \\end{cases}\n \\\\\n &= \\varphi(2n) / 2\n\\end{align*}\n$$\n\nThough they were present in the earlier Chebyshev table,\n the $g_n$ themselves are presented again, along with the expression for their degree\n\n::: {#94ab708c .cell .plain execution_count=6}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=5}\nn $\\varphi(2n)/2$ $g_n(z)$ Coefficient list, rising powers\n--- --------------------------------------- ------------------------- ---------------------------------------\n2 1 $z$ [0, 1]\n3 1 $z - 1$ [-1, 1]\n4 2 $z^{2} - 2$ [-2, 0, 1]\n5 2 $z^{2} - z - 1$ [-1, -1, 1]\n6 2 $z^{2} - 3$ [-3, 0, 1]\n7 3 $z^{3} - z^{2} - 2 z + 1$ [1, -2, -1, 1]\n8 4 $z^{4} - 4 z^{2} + 2$ [2, 0, -4, 0, 1]\n9 3 $z^{3} - 3 z - 1$ [-1, -3, 0, 1]\n9 3 $z^{3} - 3 z + 1$ [1, -3, 0, 1]\n10 4 $z^{4} - 5 z^{2} + 5$ [5, 0, -5, 0, 1]\n- [OEIS A055034](http://oeis.org/A055034) - [OEIS A187360](http://oeis.org/A187360)\n:::\n:::\n\n\nClosing\n-------\n\nMy initial jumping off point for writing this article was completely different.\nHowever, in the process of writing, its share of the article shrank and shrank until its\n introduction was only vaguely related to what preceded it.\nBut alas, the introduction via geometric constructions flows better coming off my\n [post about the Platonic solids](/posts/math/misc/platonic-volume).\nAlso, it reads better if I rely less on \"if you search for this sequence of numbers\"\n and more on how to interpret the definition.\n\nConsider reading [the follow-up](../2) to this post if you're interested in another way\n one can obtain the Chebyshev polynomials.\nI have since rederived the Chebyshev polynomials without the complex exponential,\n which you can read about in [this post](/posts/math/stereo/2).\n\nDiagrams created with GeoGebra.\n\n",
+ "markdown": "---\ntitle: \"Generating Polynomials, Part 1: Regular Constructibility\"\ndescription: |\n What kinds of regular polygons are constructible with compass and straightedge?\nformat:\n html:\n html-math-method: katex\ndate: \"2021-08-18\"\ndate-modified: \"2025-06-17\"\ncategories:\n - geometry\n - generating functions\n - algebra\n - python\n---\n\n\n\n\n\n[Recently](/posts/math/misc/platonic-volume), I used coordinate-free geometry to derive\n the volumes of the Platonic solids, a problem which was very accessible to the ancient Greeks.\nOn the other hand, they found certain problems regarding which figures can be constructed via\n compass and straightedge to be very difficult. For example, they struggled with problems\n like [doubling the cube](https://en.wikipedia.org/wiki/Doubling_the_cube)\n or [squaring the circle](https://en.wikipedia.org/wiki/Squaring_the_circle),\n which are known (through circa 19th century mathematics) to be impossible.\nHowever, before even extending planar geometry by a third dimension or\n calculating the areas of circles, a simpler problem becomes apparent.\nNamely, what kinds of regular polygons are constructible?\n\n\nRegular Geometry and a Complex Series\n-------------------------------------\n\nWhen constructing a regular polygon, one wants a ratio between the length of a edge\n and the distance from a vertex to the center of the figure.\n\n{.wide}\n\nIn a convex polygon, the total central angle is always one full turn, or 2π radians.\nThe central angle of a regular *n*-gon is ${2\\pi \\over n}$ radians,\n and the green angle above (which we'll call *θ*) is half of that.\nThis means that the ratio we're looking for is $\\sin(\\theta) = \\sin(\\pi / n)$.\nWe can multiply by *n* inside the function on both sides to give\n $\\sin(n\\theta) = \\sin(\\pi) = 0$.\nTherefore, constructing a polygon is actually equivalent to solving this equation,\n and we can rephrase the question as how to express $\\sin(n\\theta)$ (and $\\cos(n\\theta)$).\n\n\n### Complex Recursion\n\nThanks to [Euler's formula](https://en.wikipedia.org/wiki/Euler%27s_formula)\n and [de Moivre's formula](https://en.wikipedia.org/wiki/De_Moivre%27s_formula),\n the expressions we're looking for can be phrased in terms of the complex exponential.\n\n$$\n\\begin{align*}\n e^{i\\theta}\n &= \\text{cis}(\\theta) = \\cos(\\theta) + i\\sin(\\theta)\n & \\text{ Euler's formula}\n \\\\\n \\text{cis}(n \\theta) = e^{i(n\\theta)}\n &= e^{(i\\theta)n} = {(e^{i\\theta})}^n = \\text{cis}(\\theta)^n\n \\\\\n \\cos(n \\theta) + i\\sin(n \\theta)\n &= (\\cos(\\theta) + i\\sin(\\theta))^n\n & \\text{ de Moivre's formula}\n\\end{align*}\n$$\n\nDe Moivre's formula for $n = 2$ gives\n\n$$\n\\begin{align*}\n \\text{cis}(\\theta)^2\n &= (\\text{c} + i\\text{s})^2\n \\\\\n &= \\text{c}^2 + 2i\\text{cs} - \\text{s}^2 + (0 = \\text{c}^2 + \\text{s}^2 - 1)\n \\\\\n &= 2\\text{c}^2 + 2i\\text{cs} - 1\n \\\\\n &= 2\\text{c}(\\text{c} + i\\text{s}) - 1\n \\\\\n &= 2\\cos(\\theta)\\text{cis}(\\theta) - 1\n\\end{align*}\n$$\n\nThis can easily be massaged into a recurrence relation.\n\n$$\n\\begin{align*}\n \\text{cis}(\\theta)^2\n &= 2\\cos(\\theta)\\text{cis}(\\theta) - 1\n \\\\\n \\text{cis}(\\theta)^{n+2}\n &= 2\\cos(\\theta)\\text{cis}(\\theta)^{n+1} - \\text{cis}(\\theta)^n\n \\\\\n \\text{cis}((n+2)\\theta)\n &= 2\\cos(\\theta)\\text{cis}((n+1)\\theta) - \\text{cis}(n\\theta)\n\\end{align*}\n$$\n\nRecurrence relations like this one are powerful.\nThrough some fairly straightforward summatory manipulations,\n the sequence can be interpreted as the coefficients in a Taylor series,\n giving a [generating function](https://en.wikipedia.org/wiki/Generating_function).\nCall this function *F*. Then,\n\n$$\n\\begin{align*}\n \\sum_{n=0}^\\infty \\text{cis}((n+2)\\theta)x^n\n &= 2\\cos(\\theta) \\sum_{n=0}^\\infty \\text{cis}((n+1)\\theta) x^n\n - \\sum_{n=0}^\\infty \\text{cis}(n\\theta) x^n\n \\\\\n {F(x; \\text{cis}(\\theta)) - 1 - x\\text{cis}(\\theta) \\over x^2}\n &= 2\\cos(\\theta) {F(x; \\text{cis}(\\theta)) - 1 \\over x}\n - F(x; \\text{cis}(\\theta))\n \\\\[10pt]\n F - 1 - x\\text{cis}(\\theta)\n &= 2\\cos(\\theta) x (F - 1)\n - x^2 F\n \\\\\n F - 2\\cos(\\theta) x F + x^2 F\n &= 1 + x(\\text{cis}(\\theta) - 2\\cos(\\theta))\n \\\\[10pt]\n F(x; \\text{cis}(\\theta))\n &= {1 + x(\\text{cis}(\\theta) - 2\\cos(\\theta)) \\over\n 1 - 2\\cos(\\theta)x + x^2}\n\\end{align*}\n$$\n\nSince $\\text{cis}$ is a complex function, we can separate *F* into real and imaginary parts.\nConveniently, these correspond to $\\cos(n\\theta)$ and $\\sin(n\\theta)$, respectively.\n\n$$\n\\begin{align*}\n \\Re[ F(x; \\text{cis}(\\theta)) ]\n &= {1 + x(\\cos(\\theta) - 2\\cos(\\theta)) \\over 1 - 2\\cos(\\theta)x + x^2}\n \\\\\n &= {1 - x\\cos(\\theta) \\over 1 - 2\\cos(\\theta)x + x^2} = A(x; \\cos(\\theta))\n \\\\\n \\Im[ F(x; \\text{cis}(\\theta)) ]\n &= {x \\sin(\\theta) \\over 1 - 2\\cos(\\theta)x + x^2} = B(x; \\cos(\\theta))\\sin(\\theta)\n\\end{align*}\n$$\n\nIn this form, it becomes obvious that the even though the generating function *F* was originally\n parametrized by $\\text{cis}(\\theta)$, *A* and *B* are parametrized only by $\\cos(\\theta)$.\nExtracting the coefficients of *x* yields an expression for $\\cos(n\\theta)$ and $\\sin(n\\theta)$\n in terms of $\\cos(\\theta)$ (and in the latter case, a common factor of $\\sin(\\theta)$).\n\nIf $\\cos(\\theta)$ in *A* and *B* is replaced with the parameter *z*, then all trigonometric functions\n are removed from the equation, and we are left with only polynomials[^1].\nThese polynomials are [*Chebyshev polynomials*](https://en.wikipedia.org/wiki/Chebyshev_polynomial)\n *of the first (A) and second (B) kind*.\nIn actuality, the polynomials of the second kind are typically offset by 1\n (the x in the numerator of *B* is omitted).\nHowever, retaining this term makes indexing consistent between *A* and *B*\n (and will make things clearer later).\n\n[^1]:\n This can actually be observed as early as the recurrence relation.\n\n $$\n \\begin{align*}\n \\text{cis}(\\theta)^{n+2}\n &= 2\\cos(\\theta)\\text{cis}(\\theta)^{n+1} - \\text{cis}(\\theta)^n\n \\\\\n a_{n+2}\n &= 2 z a_{n+1} - a_n\n \\\\\n \\Re[ a_0 ]\n &= 1,~~ \\Im[ a_0 ] = 0\n \\\\\n \\Re[ a_1 ]\n &= z,~~ \\Im[ a_1 ] = 1 \\cdot \\sin(\\theta)\n \\end{align*}\n $$\n\n\nWe were primarily interested in $\\sin(n\\theta)$, so let's tabulate\n the first few polynomials of the second kind (at $z / 2$).\n\n::: {#tbl-chebyshevu .cell .plain tbl-cap='[OEIS A049310](http://oeis.org/A049310)' execution_count=2}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=2}\n*n* $[x^n]B(x; z / 2) = U_{n - 1}(z / 2)$ Factored\n----- --------------------------------------------- -------------------------------------------------------------------------------------------------\n0 $0$ $0$\n1 $1$ $1$\n2 $z$ $z$\n3 $z^{2} - 1$ $\\left(z - 1\\right) \\left(z + 1\\right)$\n4 $z^{3} - 2 z$ $z \\left(z^{2} - 2\\right)$\n5 $z^{4} - 3 z^{2} + 1$ $\\left(z^{2} - z - 1\\right) \\left(z^{2} + z - 1\\right)$\n6 $z^{5} - 4 z^{3} + 3 z$ $z \\left(z - 1\\right) \\left(z + 1\\right) \\left(z^{2} - 3\\right)$\n7 $z^{6} - 5 z^{4} + 6 z^{2} - 1$ $\\left(z^{3} - z^{2} - 2 z + 1\\right) \\left(z^{3} + z^{2} - 2 z - 1\\right)$\n8 $z^{7} - 6 z^{5} + 10 z^{3} - 4 z$ $z \\left(z^{2} - 2\\right) \\left(z^{4} - 4 z^{2} + 2\\right)$\n9 $z^{8} - 7 z^{6} + 15 z^{4} - 10 z^{2} + 1$ $\\left(z - 1\\right) \\left(z + 1\\right) \\left(z^{3} - 3 z - 1\\right) \\left(z^{3} - 3 z + 1\\right)$\n10 $z^{9} - 8 z^{7} + 21 z^{5} - 20 z^{3} + 5 z$ $z \\left(z^{2} - z - 1\\right) \\left(z^{2} + z - 1\\right) \\left(z^{4} - 5 z^{2} + 5\\right)$\n:::\n:::\n\n\nEvaluating the polynomials at $z / 2$ cancels the 2 in the denominator (and recurrence),\n making these expressions much simpler.\nThis evaluation has an interpretation in terms of the previous diagram --\n recall we used *half* the length of a side as a leg of the right triangle.\nFor a unit circumradius, the side length itself is then $2\\sin( {\\pi / n} )$.\nTo compensate for this doubling, the Chebyshev polynomial must be evaluated at half its normal argument.\n\n\n### Back on the Plane\n\nThe constructibility criterion is deeply connected to the Chebyshev polynomials.\nIn compass and straightedge constructions, one only has access to linear forms (lines)\n and quadratic forms (circles).\nThis means that a figure is constructible if and only if the root can be expressed using\n normal arithmetic (which is linear) and square roots (which are quadratic).\n\n\n#### Pentagons\n\nLet's look at a regular pentagon.\nThe relevant polynomial is\n\n$$\n[x^5]B ( x; z / 2 )\n = z^4 - 3z^2 + 1\n = (z^2 - z - 1) (z^2 + z - 1)\n$$\n\nAccording to how we derived this polynomial, when $z = 2\\cos(\\theta)$, the roots\n correspond to when $\\sin(5\\theta) / \\sin(\\theta) = 0$.\nThis relation itself is true when $\\theta = \\pi / 5$, since $\\sin(5 \\pi / 5) = 0$.\n\nOne of the factors must therefore be the minimal polynomial of $2\\cos(\\pi / 5 )$.\nThe former happens to be the correct choice, since $2\\cos( \\pi / 5 ) = \\varphi$, the golden ratio.\nNote that the second factor is the first evaluated at -*z*.\n\n\n#### Heptagons\n\nAn example where constructability fails is for $2\\cos( \\pi / 7 )$.\n\n$$\n\\begin{align*}\n [x^7]B ( x; z / 2 )\n &= z^6 - 5 z^4 + 6 z^2 - 1\n \\\\\n &= ( z^3 - z^2 - 2 z + 1 ) ( z^3 + z^2 - 2 z - 1 )\n\\end{align*}\n$$\n\nWhichever is the minimal polynomial (the former), it is a cubic, and constructing\n a regular heptagon is equivalent to solving it for *z*.\nBut there are no (nondegenerate) cubics that one can produce via compass and straightedge,\n and all constructions necessarily fail.\n\n\n#### Decagons\n\nOne might think the same of $2\\cos(\\pi /10 )$.\nThe relevant polynomial is:\n\n$$\n\\begin{align*}\n [x^{10}]B ( x; z / 2 )\n &= z^9 - 8 z^7 + 21 z^5 - 20 z^3 + 5 z\n \\\\\n &= z ( z^2 - z - 1 )( z^2 + z - 1 )( z^4 - 5 z^2 + 5 )\n\\end{align*}\n$$\n\nThis expression also contains the polynomials for $2\\cos( \\pi / 5 )$,\n since connecting every other vertex of a regular decagon produces\n two disjoint regular pentagons.\n\n\n\nThe polynomial which actually corresponds to $2\\cos( \\pi / 10 )$ is the quartic,\n which seems to suggest that it will require a fourth root and imply that decagons\n are somehow not constructible.\nHowever, it can be solved by completing the square...\n\n$$\n\\begin{align*}\n z^4 - 5z^2 &= -5\n \\\\\n z^4 - 5z^2 + (5/2)^2 &= -5 + (5/2)^2\n \\\\\n ( z^2 - 5/2)^2 &= {25 - 20 \\over 4}\n \\\\\n ( z^2 - 5/2) &= {\\sqrt 5 \\over 2}\n \\\\\n z^2 &= {5 \\over 2} + {\\sqrt 5 \\over 2}\n \\\\\n z &= \\sqrt{ {5 + \\sqrt 5 \\over 2} }\n\\end{align*}\n$$\n\n...and we can breathe a sigh of relief.\n\n\nThe Triangle behind Regular Polygons\n------------------------------------\n\nPreferring *z* to be halved in $B(x; z/2)$ makes something else more evident.\nObserve these four rows of the Chebyshev polynomials\n\n::: {#a8ed8c3d .cell .plain execution_count=3}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=3}\n*n* $[x^n]B(x; z / 2)$ *k* $[z^{k}][x^n]B(x; z / 2)$\n----- ------------------------------- ----- ---------------------------\n4 $z^{3} - 2 z$ 3 1\n5 $z^{4} - 3 z^{2} + 1$ 2 -3\n6 $z^{5} - 4 z^{3} + 3 z$ 1 3\n7 $z^{6} - 5 z^{4} + 6 z^{2} - 1$ 0 -1\n:::\n:::\n\n\nThe last column looks like an alternating row of Pascal's triangle\n (namely, ${n - \\lfloor {k / 2} \\rfloor - 1 \\choose k}(-1)^k$).\nThis resemblance can be made more apparent by listing the coefficients of the polynomials in a table.\n\n::: {#69ae8cab .cell .plain execution_count=4}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=4}\n n $z^9$ $z^8$ $z^7$ $z^6$ $z^5$ $z^4$ $z^3$ $z^2$ $z$ $1$\n--- ------------------------------ ------------------------------------ ------------------------------------- ----------------------------------- ----------------------------------- ----------------------------------- ------------------------------------ ------------------------------------- ------------------------------------- -------------------------------------\n 1 1\n 2 1 0\n 3 1 0 -1\n 4 1 0 -2 0\n 5 1 0 -3 0 1\n 6 1 0 -4 0 3 0\n 7 1 0 -5 0 6 0 -1\n 8 1 0 -6 0 10 0 -4 0\n 9 1 0 -7 0 15 0 -10 0 1\n 10 1 0 -8 0 21 0 -20 0 5 0\n:::\n:::\n\n\nThough they alternate in sign, the rows of Pascal's triangle appear along diagonals,\n which I have marked in rainbow.\nMeanwhile, alternating versions of the naturals (1, 2, 3, 4...),\n the triangular numbers (1, 3, 6, 10...),\n the tetrahedral numbers (1, 4, 10, 20...), etc.\n are present along the columns, albeit spaced out by 0's.\n\nThe relationship of the Chebyshev polynomials to the triangle is easier to see if\n the coefficient extraction of $B(x; z / 2)$ is reversed.\nIn other words, we extract *z* before extracting *x*.\n\n$$\n\\begin{align*}\n B(x; z / 2) &= {x \\over 1 - zx + x^2}\n = {x \\over 1 + x^2 - zx}\n = {x \\over 1 + x^2}\n \\cdot {1 \\over {1 + x^2 \\over 1 + x^2} - z{x \\over 1 + x^2}}\n \\\\[10pt]\n [z^n]B(x; z / 2) &= {x \\over 1 + x^2} [z^n] {1 \\over 1 - z{x \\over 1 + x^2}}\n = {x \\over 1 + x^2} \\left( {x \\over 1 + x^2} \\right)^n\n \\\\\n &= \\left( {x \\over 1 + x^2} \\right)^{n+1}\n = x^{n+1} (1 + x^2)^{-n - 1}\n \\\\\n &= x^{n+1} \\sum_{k=0}^\\infty {-n - 1 \\choose k}(x^2)^k\n \\quad \\text{Binomial theorem}\n\\end{align*}\n$$\n\nWhile the use of the binomial theorem is more than enough to justify\n the appearance of Pascal's triangle (along with explaining the 0's),\n I'll simplify further to explicitly show the alternating signs.\n\n$$\n\\begin{align*}\n {(-n - 1)_k} &= (-n - 1)(-n - 2) \\cdots (-n - k)\n \\\\\n &= (-1)^k (n + k)(n + k - 1) \\cdots (n + 1)\n \\\\\n &= (-1)^k (n + k)_k\n \\\\\n \\implies {-n - 1 \\choose k}\n &= {n + k \\choose k}(-1)^k\n \\\\[10pt]\n [z^n]B(x; z / 2)\n &= x^{n+1} \\sum_{k=0}^\\infty {n + k \\choose k} (-1)^k x^{2k}\n\\end{align*}\n$$\n\nSquinting hard enough, the binomial coefficient is similar to the earlier\n which gave the third row of Pascal's triangle.\nIf k is fixed, then this expression actually generates the antidiagonal entries\n of the coefficient table, which are the columns with uniform sign.\nThe alternation instead occurs between antidiagonals (one is all positive,\n the next is 0's, the next is all negative, etc.).\nThe initial $x^{n+1}$ lags these sequences so that they reproduce the triangle.\n\n\n### Imagined Transmutation\n\nThe generating function of the Chebyshev polynomials resembles other two term recurrences.\nFor example, the Fibonacci numbers have generating function\n\n$$\n\\sum_{n = 0}^\\infty \\text{Fib}_n x^n = {1 \\over 1 - x - x^2}\n$$\n\nThis resemblance can be made explicit with a simple algebraic manipulation.\n\n$$\n\\begin{align*}\n B(ix; -iz / 2)\n &= {1 \\over 1 -\\ (-i z)(ix) + (ix)^2}\n = {1 \\over 1 -\\ (-i^2) z x + (i^2)(x^2)}\n \\\\\n &= {1 \\over 1 -\\ z x -\\ x^2}\n\\end{align*}\n$$\n\nIf $z = 1$, these two generating functions are equal.\nThe same can be said for $z = 2$ with the generating function of the Pell numbers,\n and so on for higher recurrences (corresponding to metallic means) for higher integral *z*.\nIn fact, it is possible to find the Fibonacci numbers (Pell numbers, etc.)\n in Pascal's triangle, which you can read more about\n [here](http://users.dimi.uniud.it/~giacomo.dellariccia/Glossary/Pascal/Koshy2011.pdf).\n\nIn terms of the Chebyshev polynomials, this series manipulation removes the alternation in\n the coefficients of $U_n$, restoring Pascal's triangle to its nonalternating form.\n\n\nManipulating the Series\n-----------------------\n\nLook back to the table of $U_{n - 1}(z / 2)$ (@tbl-chebyshevu).\nWhen I brought up $U_{10 - 1}(z / 2)$ and decagons, I pointed out their relationship to pentagons\n as an explanation for why $U_{5 -\\ 1}(z / 2)$ appears as a factor.\nConveniently, $U_{2 -\\ 1}(z / 2) = z$ is also a factor, and 2 is likewise a factor of 10.\n\nThis pattern is present throughout the table; $n = 6$ contains factors for\n $n = 2 \\text{ and } 3$ and the prime numbers have no smaller factors.\nIf this observation is legitimate, call the newest term $f_n(z)$\n and denote $p_n(z) = U_{n -\\ 1}( z / 2 )$.\n\n\n### Factorization Attempts\n\nThe relationship between $p_n$ and the intermediate $f_d$, where *d* is a divisor of *n*,\n can be made explicit by a [Möbius inversion](https://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula).\n\n$$\n\\begin{align*}\n p_n(z) &= \\prod_{d|n} f_n(z)\n \\\\\n \\log( p_n(z) )\n &= \\log \\left( \\prod_{d|n} f_d(z) \\right)\n = \\sum_{d|n} \\log( f_d(z) )\n \\\\\n \\log( f_n(z) ) &= \\sum_{d|n} { \\mu \\left({n \\over d} \\right)}\n \\log( p_d(z) )\n \\\\\n f_n(z) &= \\prod_{d|n} p_d(z)^{ \\mu (n / d) }\n \\\\[10pt]\n f_6(z) = g_6(z)\n &= p_6(z)^{\\mu(1)}\n p_3(z)^{\\mu(2)}\n p_2(z)^{\\mu(3)}\n \\\\\n &= {p_6(z) \\over p_3(z) p_2(z)}\n\\end{align*}\n$$\n\nUnfortunately, it's difficult to apply this technique across our whole series.\nMöbius inversion over series typically uses more advanced generating functions such as\n [Dirichlet series](https://en.wikipedia.org/wiki/Dirichlet_series#Formal_Dirichlet_series)\n or [Lambert series](https://en.wikipedia.org/wiki/Lambert_series).\nHowever, naively reaching for these fails for two reasons:\n\n- We built our series of polynomials on a recurrence relation, and these series\n are opaque to such manipulations.\n- To do a proper Möbius inversion, we need these kinds of series over the *logarithm*\n of each polynomial (*B* is a series over the polynomials themselves).\n\nIgnoring these (and if you're in the mood for awful-looking math) you may note\n the Lambert equivalence[^2]:\n\n[^2]:\n This equivalence applies to other polynomial series obeying the same factorization rule\n such as the [cyclotomic polynomials](https://en.wikipedia.org/wiki/Cyclotomic_polynomial).\n\n$$\n\\begin{align*}\n \\log( p_n(z) )\n &= \\sum_{d|n} \\log( f_d(z) )\n \\\\\n \\sum_{n = 1}^\\infty \\log( p_n ) x^n\n &= \\sum_{n = 1}^\\infty \\sum_{d|n} \\log( f_d ) x^n\n \\\\\n &= \\sum_{k = 1}^\\infty \\sum_{m = 1}^\\infty \\log( f_m ) x^{m k}\n \\\\\n &= \\sum_{m = 1}^\\infty \\log( f_m ) \\sum_{k = 1}^\\infty (x^m)^k\n \\\\\n &= \\sum_{m = 1}^\\infty \\log( f_m ) {x^m \\over 1 - x^m}\n\\end{align*}\n$$\n\nEither way, the number-theoretic properties of this sequence are difficult to ascertain\n without advanced techniques.\nIf research has been done, it is not easily available in the OEIS.\n\n\n### Total Degrees\n\nIt can be also be observed that the new term is symmetric ($f(z) = f(-z)$), and is therefore\n either irreducible or the product of polynomial and its reflection (potentially negated).\nFor example,\n\n$$\np_9(z) = \\left\\{\n\\begin{matrix}\n (z - 1)(z + 1)\n & \\cdot\n & (z^3 - 3z - 1)(z^3 - 3z + 1)\n \\\\\n \\shortparallel && \\shortparallel\n \\\\\n f_3(z)\n & \\cdot\n & f_9(z)\n \\\\\n \\shortparallel && \\shortparallel\n \\\\\n g_3(z) \\cdot g_3(-z)\n & \\cdot\n & g_9(z) \\cdot -g_9(-z)\n\\end{matrix}\n\\right.\n$$\n\nThese factor polynomials $g_n$ are the minimal polynomials of $2\\cos( \\pi / n )$.\n\nMultiplying these minimal polynomials by their reflection can be observed in the Chebyshev polynomials\n for $n = 3, 5, 7, 9$, strongly implying that it occurs on the odd terms.\nAssuming this is true, we have\n\n$$\nf_n(z) = \\begin{cases}\n g_n(z) & \\text{$n$ is even}\n \\\\\n g_n(z)g_n(-z)\n & \\text{$n$ is odd and ${\\deg(f_n) \\over 2}$ is even}\n \\\\\n -g_n(z)g_n(-z)\n & \\text{$n$ is odd and ${\\deg(f_n) \\over 2}$ is odd}\n\\end{cases}\n$$\n\nWithout resorting to any advanced techniques, the degrees of $f_n$ are\n not too difficult to work out.\nThe degree of $p_n(z)$ is $n -\\ 1$, which is also the degree of $f_n(z)$ if *n* is prime.\nIf *n* is composite, then the degree of $f_n(z)$ is $n -\\ 1$ minus the degrees\n of the divisors of $n -\\ 1$.\nThis leaves behind how many numbers less than *n* are coprime to *n*.\nTherefore $\\deg(f_n) = \\phi(n)$, the\n [Euler totient function](https://en.wikipedia.org/wiki/Euler_totient_function) of the index.\n\nThe totient function can be used to examine the parity of *n*.\nIf *n* is odd, it is coprime to 2 and all even numbers.\nThe introduced factor of 2 to 2*n* removes the evens from the totient, but this is compensated by\n the addition of the odd multiples of old numbers coprime to *n* and new primes.\nThis means that $\\phi(2n) = \\phi(n)$ for odd *n* (other than 1).\n\nThe same argument can be used for even *n*: there are as many odd numbers from 0 to *n* as there are\n from *n* to 2*n*, and there are an equal number of numbers coprime to 2*n* in either interval.\nTherefore, $\\phi(2n) = 2\\phi(n)$ for even *n*.\n\nThis collapses all cases of the conditional factorization of $f_n$ into one,\n and the degrees of $g_n$ are\n\n$$\n\\begin{align*}\n \\deg( g_n(z) )\n &= \\begin{cases}\n \\deg( f_n(z) )\n = \\phi(n)\n & n \\text{ is even} & \\implies \\phi(n) = \\phi(2n) / 2\n \\\\\n \\deg( f_n(z) ) / 2\n = \\phi(n) / 2\n & n \\text{ is odd} & \\implies \\phi(n) / 2 = \\phi(2n) / 2\n \\end{cases}\n \\\\\n &= \\varphi(2n) / 2\n\\end{align*}\n$$\n\nThough they were present in the earlier Chebyshev table,\n the $g_n$ themselves are presented again, along with the expression for their degree\n\n::: {#tbl-cosinepolynomials .cell .plain execution_count=5}\n\n::: {.cell-output .cell-output-display .cell-output-markdown execution_count=5}\nn $\\varphi(2n)/2$ $g_n(z)$ Coefficient list, rising powers\n--- --------------------------------------- ------------------------- ---------------------------------------\n2 1 $z$ [0, 1]\n3 1 $z - 1$ [-1, 1]\n4 2 $z^{2} - 2$ [-2, 0, 1]\n5 2 $z^{2} - z - 1$ [-1, -1, 1]\n6 2 $z^{2} - 3$ [-3, 0, 1]\n7 3 $z^{3} - z^{2} - 2 z + 1$ [1, -2, -1, 1]\n8 4 $z^{4} - 4 z^{2} + 2$ [2, 0, -4, 0, 1]\n9 3 $z^{3} - 3 z - 1$ [-1, -3, 0, 1]\n9 3 $z^{3} - 3 z + 1$ [1, -3, 0, 1]\n10 4 $z^{4} - 5 z^{2} + 5$ [5, 0, -5, 0, 1]\n- [OEIS A055034](http://oeis.org/A055034) - [OEIS A187360](http://oeis.org/A187360)\n:::\n:::\n\n\nClosing\n-------\n\nMy initial jumping off point for writing this article was completely different.\nHowever, in the process of writing, its share of the article shrank and shrank until its\n introduction was only vaguely related to what preceded it.\nBut alas, the introduction via geometric constructions flows better coming off my\n [post about the Platonic solids](/posts/math/misc/platonic-volume).\nAlso, it reads better if I rely less on \"if you search for this sequence of numbers\"\n and more on how to interpret the definition.\n\nConsider reading [the follow-up](../2) to this post if you're interested in another way\n one can obtain the Chebyshev polynomials.\nI have since rederived the Chebyshev polynomials without the complex exponential,\n which you can read about in [this post](/posts/math/stereo/2).\n\nDiagrams created with GeoGebra.\n\n",
"supporting": [
"index_files/figure-html"
],
diff --git a/_freeze/posts/math/stereo/1/index/execute-results/html.json b/_freeze/posts/math/stereo/1/index/execute-results/html.json
index 7397bcf..d8ad828 100644
--- a/_freeze/posts/math/stereo/1/index/execute-results/html.json
+++ b/_freeze/posts/math/stereo/1/index/execute-results/html.json
@@ -1,8 +1,8 @@
{
- "hash": "a54f152d613af8d0723b2c5f1c17e58c",
+ "hash": "3d32cf613a58d732d069ef8def4a1e55",
"result": {
"engine": "jupyter",
- "markdown": "---\ntitle: \"Algebraic Rotations and Stereography\"\ndescription: |\n How do you rotate in 2D and 3D without standard trigonometry?\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2021-09-26\"\ndate-modified: \"2025-06-28\"\ncategories:\n - geometry\n - symmetry\n---\n\n\n\n\n\nExpressing rotation mathematically can be rather challenging, even in two dimensional space.\nTypically, the subject is approached from complicated-looking rotation matrices,\n with the occasional accompanying comment about complex numbers.\nThe challenge only increases when examining three dimensional space,\n where everyone has different ideas about the best implementations.\nIn what follows, I attempt to provide a derivation of 2D and 3D rotations based in intuition\n and without the use of trigonometry.\n\n\nComplex Numbers: 2D Rotations\n-----------------------------\n\nAs points in the plane, multiplication between complex numbers is frequently analyzed\n as a combination of scaling (a ratio of two scales) and rotation (a point on the complex unit circle).\nHowever, the machinery used in these analyses usually expresses complex numbers in a polar form\n involving the complex exponential.\nThis leverages prior knowledge of trigonometry and some calculus, and in fact obfuscates\n the algebraic properties of complex numbers.\nNeither concept is truly necessary to understand points on the complex unit circle,\n or complex number multiplication in general.\n\n\n### A review of complex multiplication\n\nA complex number $z = a + bi$ multiplies with another complex number\n $w = c + di$ in the obvious way: by distributing over addition.\n\n$$\nzw = (a + bi)(c + di) = ac + bci + adi + bdi^2 = (ac - bd) + i(ad + bc)\n$$\n\n*z* also has associated to it a conjugate $z^* = a - bi$.\nThe product $zz^*$ is the *norm* $a^2 + b^2$, a positive real quantity whose square root\n is typically called the *magnitude* of the complex number.\nTaking the square root is frequently unnecessary, as many of the properties of\n this quantity do not depend on this normalization.\n\nOne such property is that for two complex numbers *z* and *w*,\n the norm of the product is the product of the norm.\n\n$$\n\\begin{align*}\n (zw)(zw)^* &= (ac - bd)^2 + (ad + bc)^2\n \\\\\n &= a^2c^2 - 2abcd + b^2d^2 + a^2d^2 + 2abcd + b^2c^2\n \\\\\n &= a^2c^2 + b^2d^2 + a^2d^2 + b^2c^2\n = a^2(c^2 + d^2) + b^2(c^2 + d^2)\n \\\\\n &= (a^2 + b^2)(c^2 + d^2)\n\\end{align*}\n$$\n\nConjugation also distributes over multiplication, and complex numbers possess multiplicative inverses.\nAlso, the norm of the multiplicative inverse is the inverse of the norm.\n\n$$\n\\begin{gather*}\n z^*w^* = (a - bi)(c - di) = ac - bci - adi + bdi^2\n \\\\\n = (ac - bd) - i(ad + bc) = (zw)^{*}\n \\\\\n {1 \\over z} = {z^{*} \\over z z^{*}} = {a - bi \\over a^2 + b^2}\n \\\\[14pt]\n \\left({1 \\over z}\\right)\n \\left({1 \\over z}\\right)^{*}\n = {1 \\over zz^{*}} = {1 \\over a^2 + b^2}\n\\end{gather*}\n$$\n\nA final interesting note about complex multiplication is the product $z^{*} w$\n\n$$\nz^{*} w = (a - bi)(c + di) = ac - bci + adi - bdi^2 = (ac + bd) + i(ad - bc)\n$$\n\nThe real part is the same as the dot product $(a, c) \\cdot (b, d)$ and the imaginary part\n looks like the determinant of $\\begin{pmatrix}a & b \\\\ c & d\\end{pmatrix}$.\nThis shows the inherent value of complex arithmetic, as both of these quantities\n have important interpretations in vector algebra.\n\n\n### Onto the Circle\n\nIf $zz^{*} = a^2 + b^2 = 1$, then *z* lies on the complex unit circle.\nSince the norm is 1, a general complex number *w* has the same norm as its product with *z*, *zw*.\nSpecifically, if *w* is 1, multiplication by *z* can be seen as the rotation that maps 1 to *z*.\nBut how do you describe a point on the unit circle?\n\nSimple.\nFor any complex *w*, there are three other complex numbers that are guaranteed\n to share its norm: $-w, w^{*}$, and $-w^{*}$.\nDividing any one of these numbers by another results in a complex number on the unit circle.\nDividing *w* by -*w* is boring, since that just results in -1.\nHowever, division by $w^*$ turns out to be important:\n\n$$\n\\begin{align*}\n z &= {w \\over w^*} =\n \\left( {c + di \\over c - di} \\right)\n \\left( {c + di \\over c + di} \\right) = 1\n \\\\[8pt]\n &= {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n\\end{align*}\n$$\n\nDividing the numerator and denominator of this expression through by $c^2$ yields an expression\n in $t = d/c$, where t can be interpreted as the slope of the line joining 0 and *w*.\nSlopes range from $-\\infty$ to $\\infty$, which means that the variable *t* does as well.\n\n$$\n\\begin{align*}\n {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n &= {1/c^2 \\over 1/c^2} \\cdot {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n \\\\\n &= {(1 - d^2/c^2) + (2d/c)i \\over 1 + d^2/c^2}\n = {(1 - t^2) + (2t)i \\over 1 + t^2}\n \\\\\n &= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2} = z(t)\n\\end{align*}\n$$\n\nThis gives us a point *z* on the unit circle.\nIts reciprocal is:\n\n$$\n{1 \\over z} = {z^{*} \\over zz^{*}} = z^{*}\n$$\n\nApplying the same operation to *z* as we did to *w* gives us $z / z^{*} = z^2$,\n or as an action on points, the rotation from 1 to $z^2$.\n\nThis demonstrates the decomposition of the rotation into two parts.\nFor a general complex number *w* which may not lie on the unit circle, multiplication by\n this number dilates the complex plane as well rotating 1 toward the direction of *w*.\nThen, division by $w^{*}$ undoes the dilation and performs the rotation again.\nGeneral (i.e., non-unit) rotations *must* occur in pairs.\n\n\n### Two Halves, Twice Over\n\nPlugging in -1, 0, and 1 for *t* reveals some interesting behavior:\n $z(0) = 1 + 0i$, $z(1) = 0 + 1i$, and $z(-1) = 0 - 1i$.\nAssuming continuity, this shows that $t \\in (-1, 1)$ plots the semicircle in the right half-plane.\nThe other half of the circle comes from *t* with magnitude greater than 1,\n and the point where $z(t) = -1$ exists if we admit the extra point $t = \\pm \\infty$.\n\nIs it possible to get the other half into a nicer interval?\nNo problem, just double the rotation.\n\n$$\n\\begin{align*}\n z(t)^2 &= (\\Re[z]^2 - \\Im[z]^2) + i(2\\Re[z]\\Im[z])\n \\\\[8pt]\n &= {(1 - t^2)^2 - (2t)^2 \\over (1 + t^2)^2} + i{2(1 - t^2)(2t) \\over (1 + t^2)^2}\n \\\\[8pt]\n &= {1 - 6t^2 + t^4 \\over 1 + 2t^2 + t^4}\n + i {4t - 4t^3 \\over 1 + 2t^2 + t^4}\n\\end{align*}\n$$\n\nNow $z(-1)^2 = z(1)^2 = -1$ and the entire circle fits in the interval \\[-1, 1\\].\nThis action of squaring *z* means that as *t* ranges from $-\\infty$ to $\\infty$, the point\n $z^2$ loops around the circle twice, since the unit rotation *z* is applied twice.\n\n\n### Plotting Transcendence\n\nLet's go on a brief tangent and compare these expressions to their\n transcendental trigonometric counterparts.\nGraphing the real and imaginary parts separately shows how much they resemble\n $\\cos(\\pi t)$ and $\\sin(\\pi t)$ around zero[^1].\n\n[^1]: An approximation of a function as the ratio of two polynomials is called a\n [Padé approximant](https://en.wikipedia.org/wiki/Pad%C3%A9_approximant).\n Specifically, the real part (which approximates cosine) has order \\[4/4\\] and the imaginary part\n (which approximates sine) has order \\[3/4\\].\n\n::: {#129c8e7f .cell layout-ncol='2' execution_count=3}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\nIdeally, the zeroes of the real part should occur at $t = \\pm 1/2$, since $\\cos(\\pm \\pi/2) = 0$.\nInstead, they occur at\n\n$$\n\\begin{align*}\n 0 &= 1 - 6t^2 + t^4\n = (t^2 - 2t - 1)(t^2 + 2t - 1)\n \\\\\n &\\implies t = \\pm {1 \\over \\delta_s} = \\pm(\\sqrt 2 - 1) \\approx \\pm 0.414\n\\end{align*}\n$$\n\nWith a bit of polynomial interpolation, this can be rectified.\nA cubic interpolation between the expected and actual values is given by:\n\n$$\n\\begin{gather*}\n P(x) = ax^3 + bx^2 + cx + d\n \\\\\n \\begin{pmatrix}\n 1 & 0 & 0 & 0 \\\\\n 1 & 1/2 & 1/4 & 1/8 \\\\\n 1 & -1/2 & 1/4 & -1/8 \\\\\n 1 & 1 & 1 & 1\n \\end{pmatrix} \\begin{pmatrix}\n d \\\\\n c \\\\\n b \\\\\n a\n \\end{pmatrix} = \\begin{pmatrix}\n 0 \\\\\n \\sqrt 2 - 1 \\\\\n -\\sqrt 2 + 1 \\\\\n 1\n \\end{pmatrix}\n \\\\\n \\implies \\begin{pmatrix}\n d \\\\\n c \\\\\n b \\\\\n a\n \\end{pmatrix} = \\begin{pmatrix}\n 0 \\\\\n -3 + 8\\sqrt 2/3 \\\\\n 0 \\\\\n 4 - 8\\sqrt 2/3\n \\end{pmatrix}\n \\implies P(x) \\approx 0.229 x^3 + 0.771x\n\\end{gather*}\n$$\n\n::: {}\n\n::: {#92fceeac .cell layout-ncol='2' execution_count=4}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\nThe error over the interval \\[-1, 1\\] in these approximations is around 1% (RMS).\n:::\n\nNotably, this interpolating polynomial is entirely odd, which gives it some symmetry about 0.\nAlong with being a very good approximation, it has the feature that a rotation by an\n *n*^th^ of a turn is about $z(P(1/n))^2$.\nThe approximation be improved further by taking *z* to higher powers and deriving a higher-order\n interpolating polynomial.\n\nIt is impossible to shrink this error to 0 because the derivative of the imaginary part at\n $t = 1$ would be π.\nBut the imaginary part is a rational expression, so its derivative is also a rational expression.\nSince π is transcendental, there must always be some error[^2].\n\n[^2]: Even with the interpolating polynomial, the quantity is a ratio of two algebraic numbers,\n which is also algebraic and not transcendental.\n\nEven though it is arguably easier to calculate, there probably isn't a definite benefit to this approximation.\nFor example,\n\n- Other accurate approximants for sine and cosine can be calculated directly from their power series.\n- There are no inverse functions like `acos` or `asin` to complement these approximations.\n - This isn't that bad, since I have refrained from describing rotations with an angle\n (i.e., the quantity returned by these functions).\n Even so, the inverse functions have their use cases.\n- Trigonometric functions can be hardware-accelerated (at least in some FPUs).\n- If no such hardware exists, approximations of `sin` and `cos` can be calculated by software beforehand\n and stored in a lookup table (which is also probably involved at some stage of the FPU).\n\nElaborating on the latter two points, using a lookup table means evaluation happens in roughly constant time.\nA best-case analysis of the above approximation, given some value *t* is...\n\n\n| Expression | Additions | Multiplications | Divisions |\n|-----------------------------------------------------------|-----------|-----------------|-----------|\n| $p = t \\cdot (0.228763834 \\cdot t \\cdot t + 0.771236166)$ | 1 | 3 | |\n| $q = p \\cdot p$ | | 1 | |\n| $r = 1 + q$ | 1 | | |\n| $c = { 1 - q \\over r}$ | 1 | | 1 |\n| $s = { p + p \\over r}$ | 1 | | 1 |\n| real = $c \\cdot c - s \\cdot s$ | 1 | 2 | |\n| imag = $c \\cdot s + c \\cdot s$ | 1 | 1 | |\n| Total | 6 | 7 | 2 |\n\n...or 15 FLOPs.\n\nOn a more optimistic note, a Monte Carlo test of the above approximation on my computer yields\n promising results when compared with GCC's `libm` implementations of `sin`, `cos`, and `cexp`.\n\n::: {#50127cec .cell execution_count=5}\n\n::: {.cell-output .cell-output-display}\n```{=html}\n
Timing for 10000000 math.h sin and cos:\t2838358ns\nTiming for 10000000 approximations:\t1239784ns\nApproximation faster, speedup: 1598574ns (2.29x)\nSquared error in cosines (100000 runs): \n\tAverage: 0.000051 (0.713743% error)\n\tLargest: 0.000174 (1.320551% error)\n\t\tInput:\t\t0.729202\n\t\tValue:\t\t-0.659428\n\t\tApproximation:\t-0.672634\nSquared error in sines (100000 runs): \n\tAverage: 0.000070 (0.835334% error)\n\tLargest: 0.000288 (1.698413% error)\n\t\tInput:\t\t0.842206\n\t\tValue:\t\t0.475669\n\t\tApproximation:\t0.458685\n
\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```{=html}\nTiming for 10000000 complex.h cexp:\t4725615ns\nTiming for 10000000 approximations:\t1780325ns\nApproximation faster, speedup: 2945290ns (2.65x)\nSquared error in cosines (100000 runs): \n\tAverage: 0.000051 (0.713743% error)\n\tLargest: 0.000174 (1.320551% error)\n\t\tInput:\t\t0.729202\n\t\tValue:\t\t-0.659428\n\t\tApproximation:\t-0.672634\nSquared error in sines (100000 runs): \n\tAverage: 0.000070 (0.835334% error)\n\tLargest: 0.000288 (1.698413% error)\n\t\tInput:\t\t0.842206\n\t\tValue:\t\t0.475669\n\t\tApproximation:\t0.458685\n
\n```\n:::\n:::\n\n\nFor the source which I used to generate this output, see the repository linked at the bottom\n of this article.\n\nEven though results can be inaccurate, this exercise in the algebraic manipulation\n of complex numbers is fairly interesting since it requires no calculus to define,\n unlike sine, cosine, and their Padé approximants (and to a degree, π).\n\n\nFrom Circles to Spheres\n-----------------------\n\nThe expression for complex points on the unit circle coincides with the stereographic projection of a circle.\nThis method is achieved by selecting a point on the circle, fixing *t* along a line\n (such as the *y*-axis), and letting *t* range over all possible values.\n\n\n\nThe equations of the line and circle appear in the diagram above.\nThrough much algebra, expressions for *x* and *y* as functions of *t* can be formed.\n\n\n$$\n\\begin{align*}\n y &= t(x + 1)\n \\\\\n 1 &= x^2 + y^2 = x^2 + (tx + t)^2\n \\\\\n &= x^2 + t^2x^2 + 2t^2 x + t^2\n \\\\[14pt]\n {1 \\over t^2 + 1} -\\ {t^2 \\over t^2 + 1}\n &= x^2 + {t^2 \\over t^2 + 1} 2x\n \\\\\n {1 -\\ t^2 \\over t^2 + 1} + \\left( {t^2 \\over t^2 + 1} \\right)^2\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2 + {t^2 \\over t^2 + 1}\n \\\\\n {1 -\\ t^4 \\over (t^2 + 1)^2} + {t^4 \\over (t^2 + 1)^2}\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2\n \\\\\n {1 \\over (t^2 + 1)^2}\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2\n \\\\\n {1 \\over t^2 + 1}\n &= x + {t^2 \\over t^2 + 1}\n \\\\\n x &= {1 -\\ t^2 \\over 1 + t^2}\n \\\\\n y &= t(x + 1)\n = t\\left( {1 -\\ t^2 \\over 1 + t^2} + {1 + t^2 \\over 1 + t^2} \\right)\n \\\\\n &= {2t \\over 1 + t^2}\n\\end{align*}\n$$\n\nThese are exactly the same expressions which appear in the real and imaginary components\n of the ratio between $1 + ti$ and its conjugate.\n\nCompared to the algebra using complex numbers, this is quite a bit more work.\nOne might ask whether, given a proper arithmetic setting, this can be extended to three dimensions.\nIn other words, we want to find the projection of a sphere using some new number system\n analogously to the circle with respect to complex numbers.\n\n\n\n\n### Algebraic Projection\n\nThe simplest thing to do is try it out.\nLet's say an extended number $h = 1 + si + tj$ has a conjugate of $h^{*} = 1 - si - tj$.\nThen, following our noses[^3]:\n\n[^3]: We don't know whether *i* and *j* form a\n [field](https://en.wikipedia.org/wiki/Field_%28mathematics%29)\n or [division ring](https://en.wikipedia.org/wiki/Division_ring)),\n so it's a bit of an assumption for division to be possible.\n We'll ignore that.\n\n$$\n\\begin{gather*}\n {h \\over h^{*}} = {1 + si + tj \\over 1 - si - tj}\n = \\left({1 + si + tj \\over 1 - si - tj}\\right)\n \\left({1 + si + tj \\over 1 + si + tj}\\right)\n \\\\[8pt]\n = {\n 1 + si + tj + si + s^2i^2 + stij + tj + stji + t^2j^2\n \\over 1 - si - tj + si - s^2 i^2 - stij + tj - stji - t^2j^2\n }\n\\end{gather*}\n$$\n\nWhile there is some cancellation in the denominator, both products are rather messy.\nTo get more cancellation, we can add some nice algebraic properties between *i* and *j*.\nIf we let i and j be *anticommutative* (meaning that $ij = -ji$) then $stij$ cancels with $stji$.\nSo that the denominator is totally real (and therefore can be guaranteed to divide),\n we can also assert that $i^2$ and $j^2$ are both real.\nThen the expression becomes\n\n$$\n{1 + si + tj \\over 1 - si - tj}\n = {1 + s^2i^2 + t^2j^2 \\over 1 - s^2 i^2 - t^2 j^2}\n + i{2s \\over 1 - s^2 i^2 - t^2 j^2}\n + j{2t \\over 1 - s^2 i^2 - t^2 j^2}\n$$\n\nIf it is chosen that $i^2 = j^2 = -1$, this produces the correct equations parametrizing the unit sphere\n (see [Wikipedia](https://en.wikipedia.org/wiki/Stereographic_projection#First_formulation)).\n\n$$\n{h \\over h^{*}} = {1 - s^2 - t^2 \\over 1 + s^2 + t^2}\n + i{2s \\over 1 + s^2 + t^2}\n + j{2t \\over 1 + s^2 + t^2}\n$$\n\nOne can also check that this makes the squares of the real, *i*, and *j* components sum to 1.\n\nIf both *i* and *j* anticommute, then their product also anticommutes with both *i* and *j*.\n\n$$\n\\textcolor{red}{ij}j = -j\\textcolor{red}{ij}\n ~,~ i\\textcolor{red}{ij} = -\\textcolor{red}{ij}i\n$$\n\nCalling this product *k* and noticing that $k^2 = (ij)(ij) = -ijji = i^2 = -1$\n completely characterizes the [quaternions](https://en.wikipedia.org/wiki/Quaternion).\n\n\n### Other projections\n\nChoosing different values for $i^2$ and $j^2$ yield different shapes than a sphere.\nIf you know a little group theory, you might know there are only two nonabelian\n (noncommutative) groups of order 8:\n\n- the [quaternion group](https://en.wikipedia.org/wiki/Quaternion_group)\n- and the [\n dihedral group of degree 4\n ](https://en.wikipedia.org/wiki/Examples_of_groups#dihedral_group_of_order_8).\n\nIn the latter group, *j* and *k* are both imaginary, but square to 1 (*i* still squares to -1)[^4].\n\n[^4]: I'm being a bit careless with the meanings of \"1\" and \"-1\" here.\n Properly, these are the group identity and another group element which commutes with all others.\n\nChanging the sign of one (or both) of the imaginary squares in the expression $h / h^{*}$ above\n switches the multiplicative structure from quaternions to the dihedral group.\nIn this group, picking $i^2 = -j^2 = -1$ parametrizes a hyperboloid of one sheet,\n and picking $i^2 = j^2 = 1$ parametrizes a hyperboloid of two sheets.\n\n\nQuaternions and Rotation\n------------------------\n\nWe've already established that complex numbers are useful for describing 2D rotations.\nThey also elegantly describe the stereographic projection of a circle.\nConsequently, since quaternions elegantly describe the stereographic projection of a sphere,\n they are useful for 3D rotations.\n\nSince the imaginary units *i*, *j*, and *k* are anticommutative, a general quaternion does not\n commute with other quaternions like complex numbers do.\nThis embodies a difficulty with 3D rotations in general: unlike 2D rotations, they do not commute.\n\nOnly three of the four components in a quaternion are necessary to describe a point in 2D space.\nThe *ijk* subspace is ideal since the three imaginary axes are symmetric (i.e., they all square to -1).\nQuaternions in this subspace are called *vectors*.\nAnother reason for using the *ijk* subspace comes from considering a point\n $u = ai + bj + ck$ on the unit sphere ($a^2 + b^2 + c^2 = 1$).\nThen the square of this point is:\n\n$$\n\\begin{align*}\n u^2 &= (ai + bj + ck)(ai + bj + ck)\n \\\\\n &= a^2i^2 + abij + acik + abji + b^2j^2 + bcjk + acki + bckj + c^2k^2\n \\\\\n &= (a^2 + b^2 + c^2)(-1) + ab(ij + ji) + ac(ik + ki) + bc(jk + kj)\n \\\\\n &= -1 + 0 + 0 + 0\n\\end{align*}\n$$\n\nThis property means that *u* behaves similarly to a typical imaginary unit.\nIf we form pseudo-complex numbers of the form $a + b u$, then ${1 + tu \\over 1 - tu} = \\alpha + \\beta u$\n specifies *some kind* of rotation in terms of the parameter *t*.\nAs with complex numbers, the inverse rotation is the conjugate $1 - tu \\over 1 + tu$.\n\nAnother useful feature of quaternion algebra involves symmetry transformations of the imaginary units.\nIf an imaginary unit (one of *i*, *j*, *k*) is left-multiplied by a quaternion $q$\n and right-multiplied by its conjugate $q^{*}$, then the result is still imaginary.\nIn other words, if *p* is a vector, then $qpq^{*}$ is also a vector since\n *i*, *j*, and *k* form a basis and multiplication distributes over addition.\nI will not demonstrate this fact, as it requires a large amount of algebra.\n\nThese two features combine to characterize a transformation for a vector quaternion.\nFor a vector *p*, if $q_u(t)$ is a \"rotation\" as above for a point *u* on the unit sphere,\n then another vector (the image of *p*) can be described by\n\n$$\n\\begin{gather*}\n qpq^* = qpq^{-1}\n = \\left({1 + tu \\over 1 - tu}\\right) p \\left({1 - tu \\over 1 + tu}\\right)\n = (\\alpha + \\beta u)p(\\alpha - \\beta u)\n \\\\[4pt]\n = (\\alpha + \\beta u)(\\alpha p - \\beta pu)\n = \\alpha^2 p - \\alpha \\beta pu + \\alpha \\beta up - \\beta^2 upu\n\\end{gather*}\n$$\n\n\n### Testing a Transformation\n\n3D space contains 2D subspaces.\nIf this transformation is a rotation, then a 2D subspace will be affected in a way\n which can be described more simply by complex numbers.\nFor example, if $u = k$ and $p = xi + yj$, then this can be expanded as:\n\n$$\n\\begin{align*}\n qpq^{-1} &= (\\alpha + \\beta k)(xi + yj)(\\alpha - \\beta k)\n \\\\[10pt]\n &= \\alpha^2(xi + yj) - \\alpha \\beta (xi + yj)k + \\alpha \\beta k(xi + yj) - \\beta^2 k(xi + yj)k\n \\vphantom{\\over}\n \\\\[10pt]\n &= \\alpha^2(xi + yj) - \\alpha \\beta(-xj + yi) + \\alpha \\beta(xj - yi) - \\beta^2(xi + yj)\n \\\\[10pt]\n &= (\\alpha^2 - \\beta^2)(xi + yj) + 2\\alpha \\beta(xj - yi)\n \\\\[10pt]\n &= [(\\alpha^2 - \\beta^2)x - 2\\alpha \\beta y]i + [(\\alpha^2 - \\beta^2)y + 2\\alpha \\beta x]j\n\\end{align*}\n$$\n\nIf *p* is rewritten as a vector (in the linear algebra sense), then this final expression\n can be rewritten as a linear transformation of *p*:\n\n$$\n\\begin{align*}\n \\begin{pmatrix}\n (\\alpha^2 - \\beta^2)x - 2 \\alpha \\beta y \\\\\n (\\alpha^2 - \\beta^2)y + 2 \\alpha \\beta x\n \\end{pmatrix}\n &= \\begin{pmatrix}\n \\alpha^2 - \\beta^2 & -2\\alpha \\beta \\\\\n 2\\alpha \\beta & \\alpha^2 - \\beta^2\n \\end{pmatrix}\n \\begin{pmatrix}\n x \\\\\n y\n \\end{pmatrix}\n \\\\\n &= \\begin{pmatrix}\n \\alpha & -\\beta \\\\\n \\beta & \\alpha\n \\end{pmatrix}^2\n \\begin{pmatrix}\n x \\\\\n y\n \\end{pmatrix}\n\\end{align*}\n$$\n\nThe complex number $\\alpha + \\beta i$ is isomorphic to the matrix on the second line[^5].\nSince $\\alpha$ and $\\beta$ were chosen so to lie on \"a\" complex unit circle,\n this means that the vector (*x*, *y*) is rotated by $\\alpha + \\beta i$ twice.\nThis also demonstrates that *u* specifies the axis of rotation, or equivalently,\n the plane of a great circle.\nThis means that the \"some kind of rotation\" specified by *q* is a rotation around\n the great circle normal to *u*.\n\n[^5]: Observe this by comparing the entries of the square of the matrix and the square of the complex number.\n\nThe double rotation resembles the half-steps in the complex numbers,\n where $1 + ti$ performs a dilation, ${1 \\over 1 - ti}$ reverses it, and together they describe a rotation.\nThe form $qpq^{-1}$ is similar to this -- the $q$ on the left performs some transformation which is (partially)\n undone by the $q^{-1}$ on the right.\nIn this case, since *q*'s conjugate is its inverse and quaternions do not commute, the only thing to do without\n the transformation being trivial is to sandwich *p* between them.\n\nAs shown above, the product of a vector with itself should be totally real\n and equal to the negative of the norm of *p*, the sum of the squares of its components.\nThe rotated *p* shares the same norm as *p*, so it should equal $p^2$.\nIndeed, this is the case, as\n\n$$\n(qpq^{-1})^2 = (qpq^{-1})(qpq^{-1}) = q p p q^{-1} = p^2 q q^{-1} = p^2\n$$\n\nAs a final remark, due to rotation through quaternions being doubled, the interpolating polynomial\n used above to smooth out double rotations can also be used here.\nThat is, $q_u(P(t))pq_u^{-1}(P(t))$ rotates *p* by (approximately) the fraction of a turn specified\n by *t* through the great circle which intersects the plane normal to *u*.\n\n\nClosing\n-------\n\nIt is difficult to find a treatment of rotations which does not hesitate\n to use the complex exponential $e^{ix} = \\cos(x) + i \\sin(x)$.\nThe true criterion for rotations is simply that a point lies on the unit circle.\nPerhaps this contributes to why understanding the 3D situation with quaternions is challenging for many.\nPast the barrier to entry, I believe them to be rather intuitive.\nI have outlined some futher benefits of this approach in this post.\n\nAs a disclaimer, this post was (at least subconsciously) inspired by\n [this video](https://www.youtube.com/watch?v=d4EgbgTm0Bg) by 3blue1brown on YouTube\n (though I had not seen the video in years before checking that I wasn't just plagiarizing it).\nIt *also* uses stereographic projections of the circle and sphere to describe rotations\n in the complex plane and quaternion vector space.\nHowever, I feel like it fails to provide an algebraic motivation for quaternions,\n or even stereography in the first place.\nHopefully, my remarks on the algebraic approach can be used to augment the information in the video.\n\n\nDiagrams created with GeoGebra and Matplotlib.\nRepository with approximations (as well as GeoGebra files) available [here](https://github.com/queue-miscreant/approx-trig).\n\n",
+ "markdown": "---\ntitle: \"Algebraic Rotations and Stereography\"\ndescription: |\n How do you rotate in 2D and 3D without standard trigonometry?\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2021-09-26\"\ndate-modified: \"2025-06-28\"\ncategories:\n - geometry\n - symmetry\n---\n\n\n\n\n\nExpressing rotation mathematically can be rather challenging, even in two dimensional space.\nTypically, the subject is approached from complicated-looking rotation matrices,\n with the occasional accompanying comment about complex numbers.\nThe challenge only increases when examining three dimensional space,\n where everyone has different ideas about the best implementations.\nIn what follows, I attempt to provide a derivation of 2D and 3D rotations based in intuition\n and without the use of trigonometry.\n\n\nComplex Numbers: 2D Rotations\n-----------------------------\n\nAs points in the plane, multiplication between complex numbers is frequently analyzed\n as a combination of scaling (a ratio of two scales) and rotation (a point on the complex unit circle).\nHowever, the machinery used in these analyses usually expresses complex numbers in a polar form\n involving the complex exponential.\nThis leverages prior knowledge of trigonometry and some calculus, and in fact obfuscates\n the algebraic properties of complex numbers.\nNeither concept is truly necessary to understand points on the complex unit circle,\n or complex number multiplication in general.\n\n\n### A review of complex multiplication\n\nA complex number $z = a + bi$ multiplies with another complex number\n $w = c + di$ in the obvious way: by distributing over addition.\n\n$$\nzw = (a + bi)(c + di) = ac + bci + adi + bdi^2 = (ac - bd) + i(ad + bc)\n$$\n\n*z* also has associated to it a conjugate $z^* = a - bi$.\nThe product $zz^*$ is the *norm* $a^2 + b^2$, a positive real quantity whose square root\n is typically called the *magnitude* of the complex number.\nTaking the square root is frequently unnecessary, as many of the properties of\n this quantity do not depend on this normalization.\n\nOne such property is that for two complex numbers *z* and *w*,\n the norm of the product is the product of the norm.\n\n$$\n\\begin{align*}\n (zw)(zw)^* &= (ac - bd)^2 + (ad + bc)^2\n \\\\\n &= a^2c^2 - 2abcd + b^2d^2 + a^2d^2 + 2abcd + b^2c^2\n \\\\\n &= a^2c^2 + b^2d^2 + a^2d^2 + b^2c^2\n = a^2(c^2 + d^2) + b^2(c^2 + d^2)\n \\\\\n &= (a^2 + b^2)(c^2 + d^2)\n\\end{align*}\n$$\n\nConjugation also distributes over multiplication, and complex numbers possess multiplicative inverses.\nAlso, the norm of the multiplicative inverse is the inverse of the norm.\n\n$$\n\\begin{gather*}\n z^*w^* = (a - bi)(c - di) = ac - bci - adi + bdi^2\n \\\\\n = (ac - bd) - i(ad + bc) = (zw)^{*}\n \\\\\n {1 \\over z} = {z^{*} \\over z z^{*}} = {a - bi \\over a^2 + b^2}\n \\\\[14pt]\n \\left({1 \\over z}\\right)\n \\left({1 \\over z}\\right)^{*}\n = {1 \\over zz^{*}} = {1 \\over a^2 + b^2}\n\\end{gather*}\n$$\n\nA final interesting note about complex multiplication is the product $z^{*} w$\n\n$$\nz^{*} w = (a - bi)(c + di) = ac - bci + adi - bdi^2 = (ac + bd) + i(ad - bc)\n$$\n\nThe real part is the same as the dot product $(a, c) \\cdot (b, d)$ and the imaginary part\n looks like the determinant of $\\begin{pmatrix}a & b \\\\ c & d\\end{pmatrix}$.\nThis shows the inherent value of complex arithmetic, as both of these quantities\n have important interpretations in vector algebra.\n\n\n### Onto the Circle\n\nIf $zz^{*} = a^2 + b^2 = 1$, then *z* lies on the complex unit circle.\nSince the norm is 1, a general complex number *w* has the same norm as its product with *z*, *zw*.\nSpecifically, if *w* is 1, multiplication by *z* can be seen as the rotation that maps 1 to *z*.\nBut how do you describe a point on the unit circle?\n\nSimple.\nFor any complex *w*, there are three other complex numbers that are guaranteed\n to share its norm: $-w, w^{*}$, and $-w^{*}$.\nDividing any one of these numbers by another results in a complex number on the unit circle.\nDividing *w* by -*w* is boring, since that just results in -1.\nHowever, division by $w^*$ turns out to be important:\n\n$$\n\\begin{align*}\n z &= {w \\over w^*} =\n \\left( {c + di \\over c - di} \\right)\n \\left( {c + di \\over c + di} \\right) = 1\n \\\\[8pt]\n &= {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n\\end{align*}\n$$\n\nDividing the numerator and denominator of this expression through by $c^2$ yields an expression\n in $t = d/c$, where t can be interpreted as the slope of the line joining 0 and *w*.\nSlopes range from $-\\infty$ to $\\infty$, which means that the variable *t* does as well.\n\n$$\n\\begin{align*}\n {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n &= {1/c^2 \\over 1/c^2} \\cdot {(c^2 - d^2) + (2cd)i \\over c^2 + d^2}\n \\\\\n &= {(1 - d^2/c^2) + (2d/c)i \\over 1 + d^2/c^2}\n = {(1 - t^2) + (2t)i \\over 1 + t^2}\n \\\\\n &= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2} = z(t)\n\\end{align*}\n$$\n\nThis gives us a point *z* on the unit circle.\nIts reciprocal is:\n\n$$\n{1 \\over z} = {z^{*} \\over zz^{*}} = z^{*}\n$$\n\nApplying the same operation to *z* as we did to *w* gives us $z / z^{*} = z^2$,\n or as an action on points, the rotation from 1 to $z^2$.\n\nThis demonstrates the decomposition of the rotation into two parts.\nFor a general complex number *w* which may not lie on the unit circle, multiplication by\n this number dilates the complex plane as well rotating 1 toward the direction of *w*.\nThen, division by $w^{*}$ undoes the dilation and performs the rotation again.\nGeneral (i.e., non-unit) rotations *must* occur in pairs.\n\n\n### Two Halves, Twice Over\n\nPlugging in -1, 0, and 1 for *t* reveals some interesting behavior:\n $z(0) = 1 + 0i$, $z(1) = 0 + 1i$, and $z(-1) = 0 - 1i$.\nAssuming continuity, this shows that $t \\in (-1, 1)$ plots the semicircle in the right half-plane.\nThe other half of the circle comes from *t* with magnitude greater than 1,\n and the point where $z(t) = -1$ exists if we admit the extra point $t = \\pm \\infty$.\n\nIs it possible to get the other half into a nicer interval?\nNo problem, just double the rotation.\n\n$$\n\\begin{align*}\n z(t)^2 &= (\\Re[z]^2 - \\Im[z]^2) + i(2\\Re[z]\\Im[z])\n \\\\[8pt]\n &= {(1 - t^2)^2 - (2t)^2 \\over (1 + t^2)^2} + i{2(1 - t^2)(2t) \\over (1 + t^2)^2}\n \\\\[8pt]\n &= {1 - 6t^2 + t^4 \\over 1 + 2t^2 + t^4}\n + i {4t - 4t^3 \\over 1 + 2t^2 + t^4}\n\\end{align*}\n$$\n\nNow $z(-1)^2 = z(1)^2 = -1$ and the entire circle fits in the interval \\[-1, 1\\].\nThis action of squaring *z* means that as *t* ranges from $-\\infty$ to $\\infty$, the point\n $z^2$ loops around the circle twice, since the unit rotation *z* is applied twice.\n\n\n### Plotting Transcendence\n\nLet's go on a brief tangent and compare these expressions to their\n transcendental trigonometric counterparts.\nGraphing the real and imaginary parts separately shows how much they resemble\n $\\cos(\\pi t)$ and $\\sin(\\pi t)$ around zero[^1].\n\n[^1]: An approximation of a function as the ratio of two polynomials is called a\n [Padé approximant](https://en.wikipedia.org/wiki/Pad%C3%A9_approximant).\n Specifically, the real part (which approximates cosine) has order \\[4/4\\] and the imaginary part\n (which approximates sine) has order \\[3/4\\].\n\n::: {#736d8514 .cell layout-ncol='2' execution_count=3}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\nIdeally, the zeroes of the real part should occur at $t = \\pm 1/2$, since $\\cos(\\pm \\pi/2) = 0$.\nInstead, they occur at\n\n$$\n\\begin{align*}\n 0 &= 1 - 6t^2 + t^4\n = (t^2 - 2t - 1)(t^2 + 2t - 1)\n \\\\\n &\\implies t = \\pm {1 \\over \\delta_s} = \\pm(\\sqrt 2 - 1) \\approx \\pm 0.414\n\\end{align*}\n$$\n\nWith a bit of polynomial interpolation, this can be rectified.\nA cubic interpolation between the expected and actual values is given by:\n\n$$\n\\begin{gather*}\n P(x) = ax^3 + bx^2 + cx + d\n \\\\\n \\begin{pmatrix}\n 1 & 0 & 0 & 0 \\\\\n 1 & 1/2 & 1/4 & 1/8 \\\\\n 1 & -1/2 & 1/4 & -1/8 \\\\\n 1 & 1 & 1 & 1\n \\end{pmatrix} \\begin{pmatrix}\n d \\\\\n c \\\\\n b \\\\\n a\n \\end{pmatrix} = \\begin{pmatrix}\n 0 \\\\\n \\sqrt 2 - 1 \\\\\n -\\sqrt 2 + 1 \\\\\n 1\n \\end{pmatrix}\n \\\\\n \\implies \\begin{pmatrix}\n d \\\\\n c \\\\\n b \\\\\n a\n \\end{pmatrix} = \\begin{pmatrix}\n 0 \\\\\n -3 + 8\\sqrt 2/3 \\\\\n 0 \\\\\n 4 - 8\\sqrt 2/3\n \\end{pmatrix}\n \\implies P(x) \\approx 0.229 x^3 + 0.771x\n\\end{gather*}\n$$\n\n::: {}\n\n::: {#ea83d5ac .cell layout-ncol='2' execution_count=4}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\nThe error over the interval \\[-1, 1\\] in these approximations is around 1% (RMS).\n:::\n\nNotably, this interpolating polynomial is entirely odd, which gives it some symmetry about 0.\nAlong with being a very good approximation, it has the feature that a rotation by an\n *n*^th^ of a turn is about $z(P(1/n))^2$.\nThe approximation be improved further by taking *z* to higher powers and deriving a higher-order\n interpolating polynomial.\n\nIt is impossible to shrink this error to 0 because the derivative of the imaginary part at\n $t = 1$ would be π.\nBut the imaginary part is a rational expression, so its derivative is also a rational expression.\nSince π is transcendental, there must always be some error[^2].\n\n[^2]: Even with the interpolating polynomial, the quantity is a ratio of two algebraic numbers,\n which is also algebraic and not transcendental.\n\nEven though it is arguably easier to calculate, there probably isn't a definite benefit to this approximation.\nFor example,\n\n- Other accurate approximants for sine and cosine can be calculated directly from their power series.\n- There are no inverse functions like `acos` or `asin` to complement these approximations.\n - This isn't that bad, since I have refrained from describing rotations with an angle\n (i.e., the quantity returned by these functions).\n Even so, the inverse functions have their use cases.\n- Trigonometric functions can be hardware-accelerated (at least in some FPUs).\n- If no such hardware exists, approximations of `sin` and `cos` can be calculated by software beforehand\n and stored in a lookup table (which is also probably involved at some stage of the FPU).\n\nElaborating on the latter two points, using a lookup table means evaluation happens in roughly constant time.\nA best-case analysis of the above approximation, given some value *t* is...\n\n\n| Expression | Additions | Multiplications | Divisions |\n|-----------------------------------------------------------|-----------|-----------------|-----------|\n| $p = t \\cdot (0.228763834 \\cdot t \\cdot t + 0.771236166)$ | 1 | 3 | |\n| $q = p \\cdot p$ | | 1 | |\n| $r = 1 + q$ | 1 | | |\n| $c = { 1 - q \\over r}$ | 1 | | 1 |\n| $s = { p + p \\over r}$ | 1 | | 1 |\n| real = $c \\cdot c - s \\cdot s$ | 1 | 2 | |\n| imag = $c \\cdot s + c \\cdot s$ | 1 | 1 | |\n| Total | 6 | 7 | 2 |\n\n...or 15 FLOPs.\n\nOn a more optimistic note, a Monte Carlo test of the above approximation on my computer yields\n promising results when compared with GCC's `libm` implementations of `sin`, `cos`, and `cexp`.\n\n::: {#346f2f31 .cell execution_count=5}\n\n::: {.cell-output .cell-output-display}\n```{=html}\nTiming for 10000000 math.h sin and cos:\t2822266ns\nTiming for 10000000 approximations:\t1223832ns\nApproximation faster, speedup: 1598434ns (2.31x)\nSquared error in cosines (100000 runs): \n\tAverage: 0.000051 (0.713743% error)\n\tLargest: 0.000174 (1.320551% error)\n\t\tInput:\t\t0.729202\n\t\tValue:\t\t-0.659428\n\t\tApproximation:\t-0.672634\nSquared error in sines (100000 runs): \n\tAverage: 0.000070 (0.835334% error)\n\tLargest: 0.000288 (1.698413% error)\n\t\tInput:\t\t0.842206\n\t\tValue:\t\t0.475669\n\t\tApproximation:\t0.458685\n
\n```\n:::\n\n::: {.cell-output .cell-output-display}\n```{=html}\nTiming for 10000000 complex.h cexp:\t2864133ns\nTiming for 10000000 approximations:\t1321049ns\nApproximation faster, speedup: 1543084ns (2.17x)\nSquared error in cosines (100000 runs): \n\tAverage: 0.000051 (0.713743% error)\n\tLargest: 0.000174 (1.320551% error)\n\t\tInput:\t\t0.729202\n\t\tValue:\t\t-0.659428\n\t\tApproximation:\t-0.672634\nSquared error in sines (100000 runs): \n\tAverage: 0.000070 (0.835334% error)\n\tLargest: 0.000288 (1.698413% error)\n\t\tInput:\t\t0.842206\n\t\tValue:\t\t0.475669\n\t\tApproximation:\t0.458685\n
\n```\n:::\n:::\n\n\nFor the source which I used to generate this output, see the repository linked at the bottom\n of this article.\n\nEven though results can be inaccurate, this exercise in the algebraic manipulation\n of complex numbers is fairly interesting since it requires no calculus to define,\n unlike sine, cosine, and their Padé approximants (and to a degree, π).\n\n\nFrom Circles to Spheres\n-----------------------\n\nThe expression for complex points on the unit circle coincides with the stereographic projection of a circle.\nThis method is achieved by selecting a point on the circle, fixing *t* along a line\n (such as the *y*-axis), and letting *t* range over all possible values.\n\n\n\nThe equations of the line and circle appear in the diagram above.\nThrough much algebra, expressions for *x* and *y* as functions of *t* can be formed.\n\n\n$$\n\\begin{align*}\n y &= t(x + 1)\n \\\\\n 1 &= x^2 + y^2 = x^2 + (tx + t)^2\n \\\\\n &= x^2 + t^2x^2 + 2t^2 x + t^2\n \\\\[14pt]\n {1 \\over t^2 + 1} -\\ {t^2 \\over t^2 + 1}\n &= x^2 + {t^2 \\over t^2 + 1} 2x\n \\\\\n {1 -\\ t^2 \\over t^2 + 1} + \\left( {t^2 \\over t^2 + 1} \\right)^2\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2 + {t^2 \\over t^2 + 1}\n \\\\\n {1 -\\ t^4 \\over (t^2 + 1)^2} + {t^4 \\over (t^2 + 1)^2}\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2\n \\\\\n {1 \\over (t^2 + 1)^2}\n &= \\left(x + {t^2 \\over t^2 + 1} \\right)^2\n \\\\\n {1 \\over t^2 + 1}\n &= x + {t^2 \\over t^2 + 1}\n \\\\\n x &= {1 -\\ t^2 \\over 1 + t^2}\n \\\\\n y &= t(x + 1)\n = t\\left( {1 -\\ t^2 \\over 1 + t^2} + {1 + t^2 \\over 1 + t^2} \\right)\n \\\\\n &= {2t \\over 1 + t^2}\n\\end{align*}\n$$\n\nThese are exactly the same expressions which appear in the real and imaginary components\n of the ratio between $1 + ti$ and its conjugate.\n\nCompared to the algebra using complex numbers, this is quite a bit more work.\nOne might ask whether, given a proper arithmetic setting, this can be extended to three dimensions.\nIn other words, we want to find the projection of a sphere using some new number system\n analogously to the circle with respect to complex numbers.\n\n\n\n\n### Algebraic Projection\n\nThe simplest thing to do is try it out.\nLet's say an extended number $h = 1 + si + tj$ has a conjugate of $h^{*} = 1 - si - tj$.\nThen, following our noses[^3]:\n\n[^3]: We don't know whether *i* and *j* form a\n [field](https://en.wikipedia.org/wiki/Field_%28mathematics%29)\n or [division ring](https://en.wikipedia.org/wiki/Division_ring)),\n so it's a bit of an assumption for division to be possible.\n We'll ignore that.\n\n$$\n\\begin{gather*}\n {h \\over h^{*}} = {1 + si + tj \\over 1 - si - tj}\n = \\left({1 + si + tj \\over 1 - si - tj}\\right)\n \\left({1 + si + tj \\over 1 + si + tj}\\right)\n \\\\[8pt]\n = {\n 1 + si + tj + si + s^2i^2 + stij + tj + stji + t^2j^2\n \\over 1 - si - tj + si - s^2 i^2 - stij + tj - stji - t^2j^2\n }\n\\end{gather*}\n$$\n\nWhile there is some cancellation in the denominator, both products are rather messy.\nTo get more cancellation, we can add some nice algebraic properties between *i* and *j*.\nIf we let *i* and *j8 be *anticommutative* (meaning that $ij = -ji$) then $stij$ cancels with $stji$.\nSo that the denominator is totally real (and therefore can be guaranteed to divide),\n we can also assert that $i^2$ and $j^2$ are both real.\nThen the expression becomes\n\n$$\n{1 + si + tj \\over 1 - si - tj}\n = {1 + s^2i^2 + t^2j^2 \\over 1 - s^2 i^2 - t^2 j^2}\n + i{2s \\over 1 - s^2 i^2 - t^2 j^2}\n + j{2t \\over 1 - s^2 i^2 - t^2 j^2}\n$$\n\nIf it is chosen that $i^2 = j^2 = -1$, this produces the correct equations parametrizing the unit sphere\n (see [Wikipedia](https://en.wikipedia.org/wiki/Stereographic_projection#First_formulation)).\n\n$$\n{h \\over h^{*}} = {1 - s^2 - t^2 \\over 1 + s^2 + t^2}\n + i{2s \\over 1 + s^2 + t^2}\n + j{2t \\over 1 + s^2 + t^2}\n$$\n\nOne can also check that this makes the squares of the real, *i*, and *j* components sum to 1.\n\nIf both *i* and *j* anticommute, then their product also anticommutes with both *i* and *j*.\n\n$$\n\\textcolor{red}{ij}j = -j\\textcolor{red}{ij}\n ~,~ i\\textcolor{red}{ij} = -\\textcolor{red}{ij}i\n$$\n\nCalling this product *k* and noticing that $k^2 = (ij)(ij) = -ijji = i^2 = -1$\n completely characterizes the [quaternions](https://en.wikipedia.org/wiki/Quaternion).\n\n\n### Other projections\n\nChoosing different values for $i^2$ and $j^2$ yield different shapes than a sphere.\nIf you know a little group theory, you might know there are only two nonabelian\n (noncommutative) groups of order 8:\n\n- the [quaternion group](https://en.wikipedia.org/wiki/Quaternion_group)\n- and the [\n dihedral group of degree 4\n ](https://en.wikipedia.org/wiki/Examples_of_groups#dihedral_group_of_order_8).\n\nIn the latter group, *j* and *k* are both imaginary, but square to 1 (*i* still squares to -1)[^4].\n\n[^4]: I'm being a bit careless with the meanings of \"1\" and \"-1\" here.\n Properly, these are the group identity and another group element of order 2 which commutes with all others.\n\nChanging the sign of one (or both) of the imaginary squares in the expression $h / h^{*}$ above\n switches the multiplicative structure from quaternions to the dihedral group.\nIn this group, picking $i^2 = -j^2 = -1$ parametrizes a hyperboloid of one sheet,\n and picking $i^2 = j^2 = 1$ parametrizes a hyperboloid of two sheets.\n\n\nQuaternions and Rotation\n------------------------\n\nWe've already established that complex numbers are useful for describing 2D rotations.\nThey also elegantly describe the stereographic projection of a circle.\nConsequently, since quaternions elegantly describe the stereographic projection of a sphere,\n they are useful for 3D rotations.\n\nSince the imaginary units *i*, *j*, and *k* are anticommutative, a general quaternion does not\n commute with other quaternions like complex numbers do.\nThis embodies a difficulty with 3D rotations in general: unlike 2D rotations, they do not commute.\n\nOnly three of the four components in a quaternion are necessary to describe a point in 2D space.\nThe *ijk* subspace is ideal since the three imaginary axes are symmetric (i.e., they all square to -1).\nQuaternions in this subspace are called *vectors*.\nAnother reason for using the *ijk* subspace comes from considering a point\n $u = ai + bj + ck$ on the unit sphere ($a^2 + b^2 + c^2 = 1$).\nThen the square of this point is:\n\n$$\n\\begin{align*}\n u^2 &= (ai + bj + ck)(ai + bj + ck)\n \\\\\n &= a^2i^2 + abij + acik + abji + b^2j^2 + bcjk + acki + bckj + c^2k^2\n \\\\\n &= (a^2 + b^2 + c^2)(-1) + ab(ij + ji) + ac(ik + ki) + bc(jk + kj)\n \\\\\n &= -1 + 0 + 0 + 0\n\\end{align*}\n$$\n\nThis property means that *u* behaves similarly to a typical imaginary unit.\nIf we form pseudo-complex numbers of the form $a + b u$, then ${1 + tu \\over 1 - tu} = \\alpha + \\beta u$\n specifies *some kind* of rotation in terms of the parameter *t*.\nAs with complex numbers, the inverse rotation is the conjugate $1 - tu \\over 1 + tu$.\n\nAnother useful feature of quaternion algebra involves symmetry transformations of the imaginary units.\nIf an imaginary unit (one of *i*, *j*, *k*) is left-multiplied by a quaternion $q$\n and right-multiplied by its conjugate $q^{*}$, then the result is still imaginary.\nIn other words, if *p* is a vector, then $qpq^{*}$ is also a vector since\n *i*, *j*, and *k* form a basis and multiplication distributes over addition.\nI will not demonstrate this fact, as it requires a large amount of algebra.\n\nThese two features combine to characterize a transformation for a vector quaternion.\nFor a vector *p*, if $q_u(t)$ is a \"rotation\" as above for a point *u* on the unit sphere,\n then another vector (the image of *p*) can be described by\n\n$$\n\\begin{gather*}\n qpq^* = qpq^{-1}\n = \\left({1 + tu \\over 1 - tu}\\right) p \\left({1 - tu \\over 1 + tu}\\right)\n = (\\alpha + \\beta u)p(\\alpha - \\beta u)\n \\\\[4pt]\n = (\\alpha + \\beta u)(\\alpha p - \\beta pu)\n = \\alpha^2 p - \\alpha \\beta pu + \\alpha \\beta up - \\beta^2 upu\n\\end{gather*}\n$$\n\n\n### Testing a Transformation\n\n3D space contains 2D subspaces.\nIf this transformation is a rotation, then a 2D subspace will be affected in a way\n which can be described more simply by complex numbers.\nFor example, if $u = k$ and $p = xi + yj$, then this can be expanded as:\n\n$$\n\\begin{align*}\n qpq^{-1} &= (\\alpha + \\beta k)(xi + yj)(\\alpha - \\beta k)\n \\\\[10pt]\n &= \\alpha^2(xi + yj) - \\alpha \\beta (xi + yj)k + \\alpha \\beta k(xi + yj) - \\beta^2 k(xi + yj)k\n \\vphantom{\\over}\n \\\\[10pt]\n &= \\alpha^2(xi + yj) - \\alpha \\beta(-xj + yi) + \\alpha \\beta(xj - yi) - \\beta^2(xi + yj)\n \\\\[10pt]\n &= (\\alpha^2 - \\beta^2)(xi + yj) + 2\\alpha \\beta(xj - yi)\n \\\\[10pt]\n &= [(\\alpha^2 - \\beta^2)x - 2\\alpha \\beta y]i + [(\\alpha^2 - \\beta^2)y + 2\\alpha \\beta x]j\n\\end{align*}\n$$\n\nIf *p* is rewritten as a vector (in the linear algebra sense), then this final expression\n can be rewritten as a linear transformation of *p*:\n\n$$\n\\begin{align*}\n \\begin{pmatrix}\n (\\alpha^2 - \\beta^2)x - 2 \\alpha \\beta y \\\\\n (\\alpha^2 - \\beta^2)y + 2 \\alpha \\beta x\n \\end{pmatrix}\n &= \\begin{pmatrix}\n \\alpha^2 - \\beta^2 & -2\\alpha \\beta \\\\\n 2\\alpha \\beta & \\alpha^2 - \\beta^2\n \\end{pmatrix}\n \\begin{pmatrix}\n x \\\\\n y\n \\end{pmatrix}\n \\\\\n &= \\begin{pmatrix}\n \\alpha & -\\beta \\\\\n \\beta & \\alpha\n \\end{pmatrix}^2\n \\begin{pmatrix}\n x \\\\\n y\n \\end{pmatrix}\n\\end{align*}\n$$\n\nThe complex number $\\alpha + \\beta i$ is isomorphic to the matrix on the second line[^5].\nSince $\\alpha$ and $\\beta$ were chosen so to lie on \"a\" complex unit circle,\n this means that the vector (*x*, *y*) is rotated by $\\alpha + \\beta i$ twice.\nThis also demonstrates that *u* specifies the axis of rotation, or equivalently,\n the plane of a great circle.\nThis means that the \"some kind of rotation\" specified by *q* is a rotation around\n the great circle normal to *u*.\n\n[^5]: Observe this by comparing the entries of the square of the matrix and the square of the complex number.\n\nThe double rotation resembles the half-steps in the complex numbers,\n where $1 + ti$ performs a dilation, ${1 \\over 1 - ti}$ reverses it, and together they describe a rotation.\nThe form $qpq^{-1}$ is similar to this -- the $q$ on the left performs some transformation which is (partially)\n undone by the $q^{-1}$ on the right.\nIn this case, since *q*'s conjugate is its inverse and quaternions do not commute, the only thing to do without\n the transformation being trivial is to sandwich *p* between them.\n\nAs shown above, the product of a vector with itself should be totally real\n and equal to the negative of the norm of *p*, the sum of the squares of its components.\nThe rotated *p* shares the same norm as *p*, so it should equal $p^2$.\nIndeed, this is the case, as\n\n$$\n(qpq^{-1})^2 = (qpq^{-1})(qpq^{-1}) = q p p q^{-1} = p^2 q q^{-1} = p^2\n$$\n\nAs a final remark, due to rotation through quaternions being doubled, the interpolating polynomial\n used above to smooth out double rotations can also be used here.\nThat is, $q_u(P(t))pq_u^{-1}(P(t))$ rotates *p* by (approximately) the fraction of a turn specified\n by *t* through the great circle which intersects the plane normal to *u*.\n\n\nClosing\n-------\n\nIt is difficult to find a treatment of rotations which does not hesitate\n to use the complex exponential $e^{ix} = \\cos(x) + i \\sin(x)$.\nThe true criterion for rotations is simply that a point lies on the unit circle.\nPerhaps this contributes to why understanding the 3D situation with quaternions is challenging for many.\nPast the barrier to entry, I believe them to be rather intuitive.\nI have outlined some futher benefits of this approach in this post.\n\nAs a disclaimer, this post was (at least subconsciously) inspired by\n [this video](https://www.youtube.com/watch?v=d4EgbgTm0Bg) by 3blue1brown on YouTube\n (though I had not seen the video in years before checking that I wasn't just plagiarizing it).\nIt *also* uses stereographic projections of the circle and sphere to describe rotations\n in the complex plane and quaternion vector space.\nHowever, I feel like it fails to provide an algebraic motivation for quaternions,\n or even stereography in the first place.\nHopefully, my remarks on the algebraic approach can be used to augment the information in the video.\n\n\nDiagrams created with GeoGebra and Matplotlib.\nRepository with approximations (as well as GeoGebra files) available [here](https://github.com/queue-miscreant/approx-trig).\n\n",
"supporting": [
"index_files"
],
diff --git a/_freeze/posts/math/stereo/2/index/execute-results/html.json b/_freeze/posts/math/stereo/2/index/execute-results/html.json
index 9615f07..1bd7e7c 100644
--- a/_freeze/posts/math/stereo/2/index/execute-results/html.json
+++ b/_freeze/posts/math/stereo/2/index/execute-results/html.json
@@ -1,10 +1,10 @@
{
- "hash": "a233a2c3e506dde0e740c7aaf2014a18",
+ "hash": "f3c5de7a41749354ba6dd47b7b3d88a5",
"result": {
"engine": "jupyter",
- "markdown": "---\ntitle: \"Further Notes on Algebraic Stereography\"\ndescription: |\n How do you rotate in 2D and 3D without standard trigonometry?\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2021-10-10\"\ndate-modified: \"2025-06-30\"\ncategories:\n - algebra\n - complex analysis\n - polar roses\n - generating functions\n---\n\n\n\n\n\nIn my previous post, I discussed the stereographic projection of a circle as it pertains\n to complex numbers, as well as its applications in 2D and 3D rotation.\nIn an effort to document more interesting facts about this mathematical object\n (of which scarce information is immediately available online),\n I will now elaborate on more of its properties.\n\n\nChebyshev Polynomials\n---------------------\n\n[Previously](/posts/math/chebyshev/1), I derived the\n [Chebyshev polynomials](https://en.wikipedia.org/wiki/Chebyshev_polynomials)\n with the archetypal complex exponential.\nThese polynomials express the sines and cosines of a multiple of an angle from\n the sine and cosine of the base angle.\nWhere $T_n(t)$ are Chebyshev polynomials of the first kind and $U_n(t)$ are those of the second kind,\n\n$$\n\\begin{gather*}\n \\cos(n \\theta) = T_n(\\cos(\\theta))\n \\\\\n \\sin(n \\theta) = U_{n - 1}(\\cos(\\theta)) \\sin(\\theta)\n\\end{gather*}\n$$\n\nThe complex exponential derivation begins by squaring and developing a second-order recurrence.\n\n$$\n\\begin{align*}\n (e^{i\\theta})^2 &= (\\cos + i\\sin)^2\n \\\\\n &= \\cos^2 + 2i\\cos \\cdot \\sin - \\sin^2 + (0 = \\cos^2 + \\sin^2 - 1)\n \\\\\n &= 2\\cos^2 + 2i\\cos \\cdot \\sin - 1\n \\\\\n &= 2\\cos \\cdot (\\cos + i\\sin) - 1\n \\\\\n &= 2\\cos(\\theta)e^{i\\theta} - 1\n \\\\\n (e^{i\\theta})^{n+2} &= 2\\cos(\\theta)(e^{i\\theta})^{n+1} - (e^{i\\theta})^n\n\\end{align*}\n$$\n\nThis recurrence relation can then be used to obtain the Chebyshev polynomials, and hence,\n the expressions using sine and cosine above.\nPresented this way with such a simple derivation, it appears as though these relationships\n are inherently trigonometric.\n\nHowever, these polynomials actually have *nothing* to do with sine and cosine on their own.\nFor one, [they appear in graph theory](/posts/math/chebyshev/2), and for two,\n the importance of the complex exponential is overstated.\n$e^{i\\theta}$ really just specifies a point on the complex unit circle.\nThis property is used on the second line to coax the equation into a quadratic in $e^{i\\theta}$.\nThis is also the *only* property upon which the recurrence depends; all else is algebraic manipulation.\n\n\n### Back to the Stereograph\n\nKnowing this, let's start over with the stereographic projection of the circle:\n\n$$\no_1(t) = {1 + it \\over 1 - it}\n = {1 - t^2 \\over 1 + t^2} + i {2t \\over 1 + t^2}\n = \\text{c}_1 + i\\text{s}_1\n$$\n\nThe subscript \"1\" is because as *t* ranges over $(-\\infty, \\infty)$, the function loops once\n around the unit circle.\nTaking this to higher powers keeps points on the circle since all points on the circle\n have a norm of 1.\nIt also makes more loops around the circle, which we can denote by larger subscripts:\n\n$$\n\\begin{align*}\n o_n &= (o_1)^n\n = \\left( {1 + it \\over 1 - it} \\right)^n\n \\\\\n \\text{c}_n + i\\text{s}_n\n &= (\\text{c}_1 + i\\text{s}_1)^n\n\\end{align*}\n$$\n\nThis mirrors raising the complex exponential to a power\n (which loops over the range $(-\\pi, \\pi)$ instead).\nThe final line is analogous to de Moivre's formula, but in a form where everything is\n a ratio of polynomials in *t*.\nThis means that the Chebyshev polynomials can be obtained directly from these rational expressions:\n\n$$\n\\begin{align*}\n o_2 = (o_1)^2 &= (\\text{c}_1 + i\\text{s}_1)^2\n \\\\\n &= \\text{c}_1^2 + 2i\\text{c}_1\\text{s}_1 - \\text{s}_1^2\n + (0 = \\text{c}_1^2 + \\text{s}_1^2 - 1)\n \\\\\n &= 2\\text{c}_1^2 + 2i\\text{c}_1\\text{s}_1 - 1\n \\\\\n &= 2\\text{c}_1(\\text{c}_1 + i\\text{s}_1) - 1\n \\\\\n &= 2\\text{c}_1 o_1 - 1\n \\\\\n o_2 \\cdot (o_1)^n &= 2\\text{c}_1 o_1 \\cdot (o_1)^n - (o_1)^n\n \\\\\n o_{n+2} &= 2\\text{c}_1 o_{n+1} - o_n\n\\end{align*}\n$$\n\nThis matches the earlier recurrence relation with the complex exponential and therefore\n the recurrence relation of the Chebyshev polynomials.\nIt also means that the the rational functions obey the same relationship as sine and cosine:\n\n$$\n\\begin{matrix}\n \\begin{gather*}\n \\text{c}_n = T_n(\\text{c}_1)\n \\\\\n \\text{s}_n = U_{n-1}(\\text{c}_1) \\text{s}_1\n \\end{gather*}\n & \\text{where }\n \\text{c}_1 = {1 - t^2 \\over 1 + t^2}, &\n \\text{s}_1 = {2t \\over 1 + t^2}\n\\end{matrix}\n$$\n\nThus, the Chebyshev polynomials are tied to (coordinates on) circles,\n rather than explicitly to the trigonometric functions.\nIt is a bit strange that these polynomials are in terms of rational functions, but no stranger\n than them being in terms of *ir*rational functions like sine and cosine.\n\n\nCalculus\n--------\n\nSince these functions behave similarly to sine and cosine, one might wonder about\n the nature of these expressions in the context of calculus.\n\nFor comparison, the complex exponential (as it is a parallel construction) has a simple derivative[^1].\nSince the exponential function is its own derivative, the expression acquires\n an imaginary coefficient through the chain rule.\n\n[^1]: This is forgoing the fact that complex derivatives require more care than their real counterparts.\n It matters slightly less in this case since this function is complex-valued, but has a real parameter.\n\n$$\n\\begin{align*}\n e^{it} &= \\cos(t) + i\\sin(t)\n \\\\\n {d \\over dt} e^{it}\n &= {d \\over dt} \\cos(t) + {d \\over dt} i\\sin(t)\n \\\\\n i e^{it} &= -\\sin(t) + i\\cos(t)\n \\\\\n i[\\cos(t) + i\\sin(t)]\n &\\stackrel{\\checkmark}{=} -\\sin(t) + i\\cos(t)\n\\end{align*}\n$$\n\nMeanwhile, the complex stereograph has derivative\n\n$$\n\\begin{align*}\n {d \\over dt} o_1(t) &= {d \\over dt} {1 + it \\over 1 - it}\n = {i(1 - it) + i(1 + it) \\over (1 - it)^2}\n \\\\\n &= {2i \\over (1 - it)^2}\n = {2i(1 + it)^2 \\over (1 + t^2)^2}\n = {2i(1 - t^2 + 2it) \\over (1 + t^2)^2}\n \\\\\n &= {-4t \\over (1 + t^2)^2} + i {2(1 - t^2) \\over (1 + t^2)^2}\n \\\\\n &= {-2 \\over 1 + t^2}s_1 + i {2 \\over 1 + t^2}c_1\n \\\\\n &= -(1 + c_1)s_1 + i(1 + c_1)c_1\n \\\\\n &= i(1 + c_1)o_1\n\\end{align*}\n$$\n\nJust like the complex exponential, an imaginary coefficient falls out.\nHowever, the expression also accrues a $1 + c_1$ term, almost like an adjustment factor\n for its failure to be the complex exponential.\nSine and cosine obey a simpler relationship with respect to the derivative,\n and thus need no adjustment.\n\n\n### Complex Analysis\n\nSince $o_n$ is a curve which loops around the unit circle *n* times, that possibly suits it\n to showing a simple result from complex analysis.\nIntegrating along a contour which wraps around a sufficiently nice function's pole\n (i.e., where its magnitude grows without bound) yields a familiar value.\nThis is easiest to see with $f(z) = 1 / z$:\n\n$$\n\\oint_\\Gamma {1 \\over z} dz\n = \\int_a^b {\\gamma'(t) \\over \\gamma(t)} dt\n = 2\\pi i\n$$\n\nIn this example, Γ is a counterclockwise curve parametrized by γ which loops once around\n the pole at *z* = 0.\nMore loops will scale this by a factor according to the number of loops.\n\nNormally this equality is demonstrated with the complex exponential, but will $o_1$ work just as well?\nIf Γ is the unit circle, the integral is:\n\n$$\n\\oint_\\Gamma {1 \\over z} dz\n = \\int_{-\\infty}^\\infty {o_1'(t) \\over o_1(t)} dt\n = \\int_{-\\infty}^\\infty i(1 + c_1(t)) dt\n = 2i\\int_{-\\infty}^\\infty {1 \\over 1 + t^2} dt\n$$\n\nIf one has studied their integral identities, the indefinite version of the final integral\n will be obvious as $\\arctan(t)$, which has horizontal asymptotes of $\\pi / 2$ and $-\\pi / 2$.\nTherefore, the value of the integral is indeed $2\\pi i$.\n\nIf there are *n* loops, then naturally there are *n* of these $2\\pi i$s.\nSince powers of *o* are more loops around the circle, the chain and power rules show:\n\n$$\n\\begin{gather*}\n {d \\over dt} (o_1)^n = n(o_1)^{n-1} {d \\over dt} o_1\n \\\\[14pt]\n \\oint_\\Gamma {1 \\over z} dz\n = \\int_{-\\infty}^\\infty {n o_1(t)^{n-1} o_1'(t) \\over o_1(t)^n} dt\n = n \\int_{-\\infty}^\\infty {o_1'(t) \\over o_1(t)} dt\n = 2 \\pi i n\n\\end{gather*}\n$$\n\nIt is certainly possible to perform these contour integrals along straight lines;\n in fact, integrating along lines from 1 to *i* to -1 to -*i* deals with a\n similar integral involving arctangent.\nHowever, the best one can do to construct more loops with lines is to count each line\n multiple times, which isn't extraordinarily convincing.\n\nPerhaps the use of $\\infty$ in the integral bounds is also unconvincing.\nThe integral can be shifted back into the realm of plausibility by considering simpler bounds on $o_2$:\n\n$$\n\\begin{align*}\n \\oint_\\Gamma {1 \\over z} dz\n &= \\int_{-1}^1 {2 o_1(t) o_1'(t) \\over o_1(t)^2} dt\n \\\\\n &= 2 \\int_{-1}^1 {o_1'(t) \\over o_1(t)} dt\n \\\\\n &= 2(2i\\arctan(1) - 2i\\arctan(-1))\n \\\\\n &= 2\\pi i\n\\end{align*}\n$$\n\nThis has an additional benefit: using the series form of $1 / (1 + t^2)$ and integrating,\n one obtains the series form of the arctangent.\nThis series converges for $-1 \\le t \\le 1$, which happens to match the bounds of integration.\nThe convergence of this series is fairly important, since it is tied to formulas for π,\n in particular [Leibniz's formula](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80).\n\nWere one to integrate with the complex exponential, we would instead use the bounds $(0, 2\\pi)$,\n since at this point a full loop has been made.\nBut think to yourself -- how do you know the period of the complex exponential?\nHow do you know that 2π radians is equivalent to 0 radians?\nThe result using stereography relies on neither of these prior results and is directly pinned\n to a formula for π instead an apparent detour through the number *e*.\n\n\nPolar Curves\n------------\n\nPolar coordinates are useful for expressing for which the distance from the origin is\n a function of the angle with respect to the positive *x*-axis.\nThey can also be readily converted to parametric forms:\n\n$$\n\\begin{gather*}\n r(\\theta) &\\Longleftrightarrow&\n \\begin{matrix}\n x(\\theta) = r \\cos(\\theta) \\\\\n y(\\theta) = r \\sin(\\theta)\n \\end{matrix}\n\\end{gather*}\n$$\n\nPolar curves frequently loop in on themselves, and so it is necessary to choose appropriate bounds\n for θ (usually as multiples of π) when plotting.\nEvidently, this is due to the use of sine and cosine in the above parametrization.\nFortunately, $s_n$ and $c_n$ (as shown by the calculus above) have much simpler bounds.\nSo what happens when one substitutes the rational functions in place of the trig ones?\n\n\n### Polar Roses\n\n[Polar roses](https://en.wikipedia.org/wiki/Rose_(mathematics)) are beautiful shapes which have\n a simple form when expressed in polar coordinates.\n\n$$\nr(\\theta) = \\cos \\left( {p \\over q} \\cdot \\theta \\right)\n$$\n\nThe ratio $p/q$ in least terms uniquely determines the shape of the curve.\n\nIf you weren't reading this post, you might assume this curve is transcendental since it uses cosine,\n but you probably know better at this point.\nThe Chebyshev examples above demonstrate the resemblance between $c_n$ and $\\cos(n\\theta)$.\nThe subscript of $c$ is easiest to work with as an integer, so let $q = 1$.\n\n$$\nx(t) = c_p(t) c_1(t) \\qquad y(t) = c_p(t) s_1(t)\n$$\n\nwill plot a $p/1$ polar rose as t ranges over $(-\\infty, \\infty)$.\n\n\n\n::: {#fig-polar-roses-1}\n{{< video \"./polar_roses_1.mp4\" >}}\n\np/1 polar roses as rational curves.\nSince *t* never reaches infinity, a bite appears to be taken out of the graphs near (-1, 0).\"\n:::\n\n$q = 1$ happens to match the subscript *c* term of *x* and *s* term of *y*, so one might wonder\n whether the other polar curves can be obtained by allowing it to vary as well.\nAnd you'd be right.\n\n$$\nx(t) = c_p(t) c_q(t) \\qquad y(t) = c_p(t) s_q(t)\n$$\n\nwill plot a $p/q$ polar rose as t ranges over $(-\\infty, \\infty)$.\n\n\n\n::: {#fig-polar-roses-2}\n{{< video \"./polar_roses_2.mp4\" >}}\n\np/q polar roses as rational curves\n:::\n\nJust as with the prior calculus examples, doubling all subscripts of *c* and *s* will\n only require *t* to range over $(-1, 1)$, which removes the ugly bite mark.\nPerhaps it is also slightly less satisfying, since the fraction $p/q$ directly appears in the\n typical polar incarnation with cosine.\nOn the other hand, it exposes an important property of these curves: they are all rational.\n\nThis approach lends additional precision to a prospective pseudo-polar coordinate system.\nIn the next few examples, I will be using the following notation for compactness:\n\n$$\n \\begin{gather*}\n R_n(t) = f(t) &\\Longleftrightarrow&\n \\begin{matrix}\n x(t) = f(t) c_n(t) \\\\\n y(t) = f(t) s_n(t)\n \\end{matrix}\n\\end{gather*}\n$$\n\n\n### Conic Sections\n\nThe polar equation for a conic section (with a particular unit length occurring somewhere)\n in terms of its eccentricity $\\varepsilon$ is:\n\n$$\nr(\\theta) = {1 \\over 1 - \\varepsilon \\cos(\\theta)}\n$$\n\nCorrespondingly, the rational polar form can be expressed as\n\n$$\nR_1(t) = {1 \\over 1 - \\varepsilon c_1}\n$$\n\nSince polynomial arithmetic is easier to work with than trigonometric identities,\n it is a matter of pencil-and-paper algebra to recover the implicit form from a parametric one.\n\n\n#### Parabola ($|\\varepsilon| = 1$)\n\nThe conic section with the simplest implicit equation is the parabola.\nSince $c_n$ is a simple ratio of polynomials in *t*, it is much simpler to recover the implicit equation.\nFor $\\varepsilon = 1$,\n\n:::: {layout-ncol=\"2\"}\n\n::: {#3902cb4b .cell execution_count=5}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{align*}\n 1 - c_1 &= 1 - {1 - t^2 \\over 1 + t^2}\n = {2 t^2 \\over 1 + t^2}\n \\\\\n y &= {s_1 \\over 1 - c_1}\n = {2t \\over 1 + t^2} {1 + t^2 \\over 2 t^2}\n = {1 \\over t}\n \\\\\n x &= {c_1 \\over 1 - c_1}\n = {1 - t^2 \\over 1 + t^2} \\cdot {1 + t^2 \\over 2 t^2}\n = {1 - t^2 \\over 2t^2}\n \\\\\n &= {1 \\over 2t^2} - {1 \\over 2}\n = {y^2 \\over 2} - {1 \\over 2}\n\\end{align*}\n$$\n:::\n::::\n\n*x* is a quadratic polynomial in *y*, so trivially the figure formed is a parabola.\nTechnically it is missing the point where $y = 0 ~ (t = \\infty)$, and this is not a circumstance\n where using a higher $c_n$ would help.\nIt is however, similar to the situation where we allow $o_1(\\infty) = -1$, and an argument\n can be made to waive away any concerns one might have.\n\n\n#### Ellipse ($|\\varepsilon| < 1$)\n\nEllipses are next.\nThe simplest fraction between zero and one is 1/2, so for $\\varepsilon = 1/2$,\n\n:::: {layout-ncol = \"2\"}\n\n::: {#ce1bccb3 .cell execution_count=6}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{align*}\n 1 - {1 \\over 2}c_1 &= 1 - {1 \\over 2} \\cdot {1 - t^2 \\over 1 + t^2}\n = {3 t^2 + 1 \\over 2 + 2t^2}\n \\\\\n y &= {s_1 \\over 1 - {1 \\over 2}c_1}\n = {4t \\over 3t^2 + 1}\n \\\\\n x &= {c_1 \\over 1 - {1 \\over 2}c_1}\n = {2 - 2t^2 \\over 3t^2 + 1}\n\\end{align*}\n$$\n:::\n::::\n\nThere isn't an obvious way to combine products of *x* and *y* into a single equation.\nThe general form of a conic section is $Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$, so\n we know that the implicit equation for the curve almost certainly involves $x^2$ and $y^2$.\n\n$$\nx^2 = {4 - 8t^2 + 4t^4 \\over (3t^2 + 1)^2} \\qquad\n y^2 = {16t^2 \\over (3t^2 + 1)^2}\n$$\n\nSquaring produces some $t^4$ terms which cannot exist outside of these terms and *xy*.\nA linear combination of $x^2$ and $y^2$ never includes any cubic terms in the numerator\n which would appear in *xy*, so $B = 0$.\nSince all remaining terms are linear in *x* and *y*, their denominator must appear as a factor\n in the numerator of $Ax^2 + Cy^2$, whatever *A* and *C* are.\n\nSince the coefficient of $t^4$ in $x^2$ is 4, *A* must be multiple of 3.\nThrough trial and error, $A = 3, C = 4$ gives:\n\n$$\n\\begin{align*}\n 3x^2 + 4y^2\n &= {12 - 24t^2 + 12t^4 + 64t^2 \\over (3t^2 + 1)^2}\n \\\\\n &= {12 - 40t^2 + 12t^4 \\over (3t^2 + 1)^2}\n \\\\\n &= {(4t^2 + 12) (3t^2 + 1) \\over (3t^2 + 1)^2}\n \\\\\n &= {4t^2 + 12 \\over 3t^2 + 1}\n\\end{align*}\n$$\n\nSince the numerator of *y* has a *t*, this is clearly some combination of *x* and a constant.\nBy the previous line of thought, the constant term must be a multiple of 4, and picking the smallest\n option finally results in the implicit form:\n\n$$\n\\begin{align*}\n 4 &= {4(3t^2 + 1) \\over 3t^2 + 1}\n = {12t^2 + 4 \\over 3t^2 + 1}\n \\\\\n {4t^2 + 12 \\over 3t^2 + 1} - 4\n &= {8 - 8t^2 \\over 3t^2 + 1} = 4x\n \\\\[14pt]\n 3x^2 + 4y^2 &= 4x + 4\n \\\\\n 3x^2 + 4y^2 - 4x - 4 &= 0\n\\end{align*}\n$$\n\nNotably, the coefficients of *x* and *y* are 3 and 4.\nSimultaneously, $o_1(\\varepsilon) = o_1(1/2) = {3 \\over 5} + i{4 \\over 5}$.\nThis binds together three concepts: the simplest case of the Pythagorean theorem,\n the 3-4-5 right triangle; the coefficients of the implicit form; and the role of eccentricity\n with respect to stereography.\n\n\n#### Hyperbola ($|\\varepsilon| > 1$)\n\nAs evidenced by the bound on the eccentricity above, hyperbolae are in some way the inverses of ellipses.\nSince $o_1(2)$ is a reflection of $o_1(1/2)$, you might think the implicit equation for\n $\\varepsilon = 2$ to be the same, but with a flipped sign or two.\nUnfortunately, you'd be wrong.\n\n:::: {layout-ncol=\"2\"}\n\n::: {#12a8b8f9 .cell execution_count=7}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{gather*}\n \\begin{align*}\n x &= {c_1 \\over 1 - 2c_1} = {1 - t^2 \\over 3t^2 - 1}\n \\\\\n y &= {s_1 \\over 1 - 2c_1} = {2t \\over 3t^2 - 1}\n \\\\[14pt]\n 3x^2 - y^2 &= {3 - 6t^2 + 3t^4 - 4t^2 \\over 3t^2 - 1}\n \\\\\n &= {(t^2 - 3)(3t^2 - 1) \\over (3t^2 - 1)^2 }\n \\\\\n &= {t^2 - 3 \\over 3t^2 - 1 }\n = ... = -4x - 1\n \\end{align*}\n \\\\[14pt]\n 3x^2 - y^2 + 4x + 1 = 0\n\\end{gather*}\n$$\n:::\n::::\n\nAt the very least, the occurrences of 1 in the place of 4 have a simple explanation: 1 = 4 - 3.\n\n\n### Archimedean Spiral\n\nArguably the simplest (non-circular) polar curve is $r(\\theta) = \\theta$, the unit\n [Archimedean spiral](https://en.wikipedia.org/wiki/Archimedean_spiral).\nSince the curve is defined by a constant turning, this is a natural application of the properties\n of sine and cosine.\nThe closest equivalent in rational polar coordinates is $R_1(t) = t$.\nBut this can be converted to an implicit form:\n\n$$\n\\begin{gather*}\n x = tc_1 \\qquad y = ts_1\n \\\\[14pt]\n x^2 + y^2 = t^2(c_1^2 + s_1^2) = t^2\n \\\\\n y = {2t^2 \\over 1 + t^2} = {2(x^2 + y^2) \\over 1 + (x^2 + y^2)}\n \\\\[14pt]\n (1 + x^2 + y^2)y = 2(x^2 + y^2)\n\\end{gather*}\n$$\n\nThe curve produced by this equation is a\n [right strophoid](https://mathworld.wolfram.com/RightStrophoid.html)\n with a node at (0, 1) and asymptote $y = 2$.\nThis form suggests something interesting about this curve: it approximates the Archimedean spiral\n (specifically the one with polar equation $r(\\theta) = \\theta/2$).\nIndeed, the sequence of curves with parametrization $R_n(t) = 2nt$ approximate the (unit) spiral\n for larger *n*, as can be seen in the following video.\n\n\n\n::: {#fig-approx-archimedes}\n{{< video ./approximate_archimedes.mp4 >}}\n\nApproximations to the Archimedean spiral\n:::\n\n\nSince R necessarily defines a rational curve, the curves will never be equal,\n just as any stretching of $c_n$ will never exactly become cosine.\n\n\nClosing\n-------\n\nSine, cosine, and the exponential function, are useful in a calculus setting precisely\n because of their constant \"velocity\" around the circle.\nAlso, nearly every modern scientific calculator in the world features buttons\n for trigonometric functions, so there seems to be no reason *not* to use them.\n\nWe can however be misled by their apparent omnipresence.\nStereographic projection has been around for *millennia*, and not every formula needs to be rewritten\n in its language.\nFor example (and as previously mentioned), defining the Chebyshev polynomials really only requires\n understanding the multiplication of two complex numbers whose norm cannot grow,\n not trigonometry and dividing angles.\nMany other instances of sine and cosine merely rely on a number (or ratio) of loops around a circle.\nWhen velocity does not factor, it will obviously do to \"stay rational\".\n\nOne of my favorite things to plot as a kid were polar roses, so I was somewhat intrigued\n to see that they are, in fact, rational curves.\nOn the other hand, their rationality follows immediately from the rationality of the circle\n (which itself follows from the existence of Pythagorean triples).\nIf I were more experienced with manipulating Chebyshev polynomials or willing to set up a\n linear system in (way too) many terms, I might have considered attempting to find\n an implicit form for them as well.\n\nDiagrams created with Sympy and Matplotlib.\n\n",
+ "markdown": "---\ntitle: \"Further Notes on Algebraic Stereography\"\ndescription: |\n How do you rotate in 2D and 3D without standard trigonometry?\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2021-10-10\"\ndate-modified: \"2025-06-30\"\ncategories:\n - algebra\n - complex analysis\n - polar roses\n - generating functions\n---\n\n\n\n\n\nIn my previous post, I discussed the stereographic projection of a circle as it pertains\n to complex numbers, as well as its applications in 2D and 3D rotation.\nIn an effort to document more interesting facts about this mathematical object\n (of which scarce information is immediately available online),\n I will now elaborate on more of its properties.\n\n\nChebyshev Polynomials\n---------------------\n\n[Previously](/posts/math/chebyshev/1), I derived the\n [Chebyshev polynomials](https://en.wikipedia.org/wiki/Chebyshev_polynomials)\n with the archetypal complex exponential.\nThese polynomials express the sines and cosines of a multiple of an angle from\n the sine and cosine of the base angle.\nWhere $T_n(t)$ are Chebyshev polynomials of the first kind and $U_n(t)$ are those of the second kind,\n\n$$\n\\begin{gather*}\n \\cos(n \\theta) = T_n(\\cos(\\theta))\n \\\\\n \\sin(n \\theta) = U_{n - 1}(\\cos(\\theta)) \\sin(\\theta)\n\\end{gather*}\n$$\n\nThe complex exponential derivation begins by squaring and developing a second-order recurrence.\n\n$$\n\\begin{align*}\n (e^{i\\theta})^2 &= (\\cos + i\\sin)^2\n \\\\\n &= \\cos^2 + 2i\\cos \\cdot \\sin - \\sin^2 + (0 = \\cos^2 + \\sin^2 - 1)\n \\\\\n &= 2\\cos^2 + 2i\\cos \\cdot \\sin - 1\n \\\\\n &= 2\\cos \\cdot (\\cos + i\\sin) - 1\n \\\\\n &= 2\\cos(\\theta)e^{i\\theta} - 1\n \\\\\n (e^{i\\theta})^{n+2} &= 2\\cos(\\theta)(e^{i\\theta})^{n+1} - (e^{i\\theta})^n\n\\end{align*}\n$$\n\nThis recurrence relation can then be used to obtain the Chebyshev polynomials, and hence,\n the expressions using sine and cosine above.\nPresented this way with such a simple derivation, it appears as though these relationships\n are inherently trigonometric.\n\nHowever, these polynomials actually have *nothing* to do with sine and cosine on their own.\nFor one, [they appear in graph theory](/posts/math/chebyshev/2), and for two,\n the importance of the complex exponential is overstated.\n$e^{i\\theta}$ really just specifies a point on the complex unit circle.\nThis property is used on the second line to coax the equation into a quadratic in $e^{i\\theta}$.\nThis is also the *only* property upon which the recurrence depends; all else is algebraic manipulation.\n\n\n### Back to the Stereograph\n\nKnowing this, let's start over with the stereographic projection of the circle:\n\n$$\no(t) = {1 + it \\over 1 - it}\n = {1 - t^2 \\over 1 + t^2} + i {2t \\over 1 + t^2}\n = \\text{c}_1 + i\\text{s}_1\n$$\n\nThe subscript \"1\" for *c* and *s* is because as *t* ranges over $[-\\infty, \\infty)$,\n the function loops once around the unit circle.\nTaking *o* to higher powers keeps points on the circle since all points on the circle\n have a norm of 1.\nIt also makes more loops around the circle, which we can denote by larger subscripts:\n\n$$\n\\begin{align*}\n o^n\n &= \\left( {1 + it \\over 1 - it} \\right)^n\n \\\\\n &= (\\text{c}_1 + i\\text{s}_1)^n\n \\\\\n &= \\text{c}_n + i\\text{s}_n\n\\end{align*}\n$$\n\nThis mirrors raising the complex exponential to a power\n (which loops over the range $[-\\pi, \\pi)$ instead).\nThe final line is analogous to de Moivre's formula, but in a form where everything is\n a ratio of polynomials in *t*.\nThis means that the Chebyshev polynomials can be obtained directly from these rational expressions:\n\n$$\n\\begin{align*}\n o^2 &= (\\text{c}_1 + i\\text{s}_1)^2\n \\\\\n &= \\text{c}_1^2 + 2i\\text{c}_1\\text{s}_1 - \\text{s}_1^2\n + (0 = \\text{c}_1^2 + \\text{s}_1^2 - 1)\n \\\\\n &= 2\\text{c}_1^2 + 2i\\text{c}_1\\text{s}_1 - 1\n \\\\\n &= 2\\text{c}_1(\\text{c}_1 + i\\text{s}_1) - 1\n \\\\\n &= 2\\text{c}_1 o - 1\n \\\\\n o^2 \\cdot o^n &= 2\\text{c}_1 o \\cdot o^n - o^n\n \\\\\n o^{n+2} &= 2\\text{c}_1 o^{n+1} - o^n\n\\end{align*}\n$$\n\nThis matches the earlier recurrence relation with the complex exponential and therefore\n the recurrence relation of the Chebyshev polynomials.\nIt also means that the the rational functions obey the same relationship as sine and cosine:\n\n$$\n\\begin{matrix}\n \\begin{gather*}\n \\text{c}_n = T_n(\\text{c}_1)\n \\\\\n \\text{s}_n = U_{n-1}(\\text{c}_1) \\text{s}_1\n \\end{gather*}\n & \\text{where }\n \\text{c}_1 = {1 - t^2 \\over 1 + t^2}, &\n \\text{s}_1 = {2t \\over 1 + t^2}\n\\end{matrix}\n$$\n\nThus, the Chebyshev polynomials are tied to (coordinates on) circles,\n rather than explicitly to the trigonometric functions.\nIt is a bit strange that these polynomials are in terms of rational functions, but no stranger\n than them being in terms of *ir*rational functions like sine and cosine.\n\n\nCalculus\n--------\n\nSince these functions behave similarly to sine and cosine, one might wonder about\n the nature of these expressions in the context of calculus.\n\nFor comparison, the complex exponential (as it is a parallel construction) has a simple derivative[^1].\nSince the exponential function is its own derivative, the expression acquires\n an imaginary coefficient through the chain rule.\n\n[^1]: This is forgoing the extra care that complex derivatives require beyond their real counterparts.\n It matters slightly less in this case since this function is complex-valued, but has a real parameter.\n\n$$\n\\begin{align*}\n e^{it} &= \\cos(t) + i\\sin(t)\n \\\\\n {d \\over dt} e^{it}\n &= {d \\over dt} \\cos(t) + {d \\over dt} i\\sin(t)\n \\\\\n i e^{it} &= -\\sin(t) + i\\cos(t)\n \\\\\n i[\\cos(t) + i\\sin(t)]\n &\\stackrel{\\checkmark}{=} -\\sin(t) + i\\cos(t)\n\\end{align*}\n$$\n\nMeanwhile, the complex stereograph has derivative\n\n$$\n\\begin{align*}\n {d \\over dt} o(t) &= {d \\over dt} {1 + it \\over 1 - it}\n = {i(1 - it) + i(1 + it) \\over (1 - it)^2}\n \\\\\n &= {2i \\over (1 - it)^2}\n = {2i(1 + it)^2 \\over (1 + t^2)^2}\n = {2i(1 - t^2 + 2it) \\over (1 + t^2)^2}\n \\\\\n &= {-4t \\over (1 + t^2)^2} + i {2(1 - t^2) \\over (1 + t^2)^2}\n \\\\\n &= {-2 \\over 1 + t^2}s_1 + i {2 \\over 1 + t^2}c_1\n \\\\\n &= -(1 + c_1)s_1 + i(1 + c_1)c_1\n \\\\\n &= i(1 + c_1)o\n\\end{align*}\n$$\n\nJust like the complex exponential, an imaginary coefficient falls out.\nHowever, the expression also accrues $1 + c_1$ as an adjustment factor.\nThe complex exponential doesn't need this term because it goes around the circle at a constant rate,\n resulting in a simpler relationship with respect to the derivative.\n\n\n### Complex Analysis\n\nSince $o^n$ is a curve which loops around the unit circle *n* times, that possibly suits it\n to showing a simple result from complex analysis.\nIntegrating along a contour which wraps around a sufficiently nice function's pole\n (i.e., where its magnitude grows without bound) yields a familiar value.\nThis is easiest to see with $f(z) = 1 / z$:\n\n$$\n\\oint_\\Gamma {1 \\over z} dz\n = \\int_a^b {\\gamma'(t) \\over \\gamma(t)} dt\n = 2\\pi i\n$$\n\nIn this example, Γ is a counterclockwise curve parametrized by *γ* which loops once around\n the pole at *z* = 0.\nMore loops will scale this by a factor according to the number of loops.\n\nNormally this equality is demonstrated with Γ as the unit circle and *γ* as the complex exponential?\nBut will *o* work just as well in place of the latter?\n\n$$\n\\oint_\\Gamma {1 \\over z} dz\n = \\int_{-\\infty}^\\infty {o'(t) \\over o(t)} dt\n = \\int_{-\\infty}^\\infty i(1 + c_1(t)) dt\n = 2i\\int_{-\\infty}^\\infty {1 \\over 1 + t^2} dt\n$$\n\nIf one has studied their integral identities, the indefinite version of the final integral\n will be obvious as $\\arctan(t)$, which has horizontal asymptotes of $\\pi / 2$ and $-\\pi / 2$.\nTherefore, the value of the integral is indeed $2\\pi i$.\n\nIf there are *n* loops, then naturally there are *n* of these $2\\pi i$s.\nSince powers of *o* are more loops around the circle, the chain and power rules show:\n\n$$\n\\begin{gather*}\n {d \\over dt} o^n = no^{n-1} {d \\over dt} o\n \\\\[14pt]\n \\oint_\\Gamma {1 \\over z} dz\n = \\int_{-\\infty}^\\infty {n o(t)^{n-1} o'(t) \\over o(t)^n} dt\n = n \\int_{-\\infty}^\\infty {o'(t) \\over o(t)} dt\n = 2 \\pi i n\n\\end{gather*}\n$$\n\nIt is certainly possible to perform these contour integrals along straight lines\n in the complex plane; in fact, making Γ a diamond-shaped contour from\n 1 to *i* to -1 to -*i* produces a similar integral involving arctangent.\nHowever, the best one can do to construct more loops with lines is to count each line\n multiple times, which isn't extraordinarily convincing.\n\nPerhaps the use of $\\infty$ in the integral bounds is also unconvincing.\nThe integral can be shifted back into the realm of plausibility by considering simpler bounds on $o^2$:\n\n$$\n\\begin{align*}\n \\oint_\\Gamma {1 \\over z} dz\n &= \\int_{-1}^1 {2 o(t) o'(t) \\over o(t)^2} dt\n \\\\\n &= 2 \\int_{-1}^1 {o'(t) \\over o(t)} dt\n \\\\\n &= 2(2i\\arctan(1) - 2i\\arctan(-1))\n \\\\\n &= 2\\pi i\n\\end{align*}\n$$\n\nThis has an additional benefit: using the series form of $1 / (1 + t^2)$ and integrating,\n one obtains [the series form of arctangent](https://en.wikipedia.org/wiki/Arctangent_series).\nThis series converges for $-1 \\le t \\le 1$, which happens to match the bounds of integration.\nThe convergence of this series is fairly important, since it is tied to formulas for π,\n in particular [Leibniz's formula](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80).\n\nWere one to integrate with the complex exponential, we would instead use the bounds $[0, 2\\pi)$,\n since at this point a full loop has been made.\nBut think to yourself -- how do you know the period of the complex exponential?\nHow do you know that 2π radians is equivalent to 0 radians?\nThe result using stereography relies on neither of these prior results and is directly pinned\n to a formula for π instead an apparent detour through the number *e*.\n\n\nPolar Curves\n------------\n\nPolar coordinates are useful for expressing for which the distance from the origin is\n a function of the angle with respect to the positive *x*-axis.\nThey can also be readily converted to parametric forms:\n\n$$\n\\begin{gather*}\n r(\\theta) &\\Longleftrightarrow&\n \\begin{matrix}\n x(\\theta) = r \\cos(\\theta) \\\\\n y(\\theta) = r \\sin(\\theta)\n \\end{matrix}\n\\end{gather*}\n$$\n\nPolar curves frequently loop in on themselves, and so it is necessary to choose appropriate bounds\n for θ (usually as multiples of π) when plotting.\nEvidently, this is due to the use of sine and cosine in the above parametrization.\nFortunately, $s_n$ and $c_n$ (as shown by the calculus above) have much simpler bounds.\nSo what happens when one substitutes the rational functions in place of the trig ones?\n\n\n### Polar Roses\n\n[Polar roses](https://en.wikipedia.org/wiki/Rose_(mathematics)) are beautiful shapes which have\n a simple form when expressed in polar coordinates.\n\n$$\nr(\\theta) = \\cos \\left( {p \\over q} \\cdot \\theta \\right)\n$$\n\nThe ratio $p/q$ in least terms uniquely determines the shape of the curve.\n\nIf you weren't reading this post, you might assume this curve is transcendental since it uses cosine,\n but you probably know better at this point.\nThe Chebyshev examples above demonstrate the resemblance between $c_n$ and $\\cos(n\\theta)$.\nThe subscript of $c$ is easiest to work with as an integer, so let $q = 1$.\n\n$$\nx(t) = c_p(t) c_1(t) \\qquad y(t) = c_p(t) s_1(t)\n$$\n\nwill plot a $p/1$ polar rose as t ranges over $[-\\infty, \\infty)$.\n\n\n\n::: {#fig-polar-roses-1}\n{{< video \"./polar_roses_1.mp4\" >}}\n\np/1 polar roses as rational curves.\nSince *t* never reaches infinity, a bite appears to be taken out of the graphs near (-1, 0).\"\n:::\n\n$q = 1$ happens to match the subscript of a *c* term of *x* and the *s* term of *y*,\n so one might wonder whether the other polar curves can be obtained by allowing it to vary.\nAnd you'd be right.\n\n$$\nx(t) = c_p(t) c_q(t) \\qquad y(t) = c_p(t) s_q(t)\n$$\n\nwill plot a $p/q$ polar rose as t ranges over $[-\\infty, \\infty)$.\n\n\n\n::: {#fig-polar-roses-2}\n{{< video \"./polar_roses_2.mp4\" >}}\n\np/q polar roses as rational curves\n:::\n\nJust as with the prior calculus examples, doubling all subscripts of *c* and *s* will\n only require *t* to range over $[-1, 1)$, which removes the ugly bite mark.\nPerhaps it is also slightly less satisfying, since the fraction $p/q$ directly appears in the\n typical polar incarnation with cosine.\nOn the other hand, it exposes an important property of these curves: they are all rational.\n\nThis approach lends additional precision to a prospective pseudo-polar coordinate system.\nIn the next few examples, I will be using the following notation for compactness:\n\n$$\n \\begin{gather*}\n R_n(t) = f(t) &\\Longleftrightarrow&\n \\begin{matrix}\n x(t) = f(t) c_n(t) \\\\\n y(t) = f(t) s_n(t)\n \\end{matrix}\n\\end{gather*}\n$$\n\n\n### Conic Sections\n\nThe polar equation for a conic section (with a particular unit length occurring somewhere)\n in terms of its eccentricity $\\varepsilon$ is:\n\n$$\nr(\\theta) = {1 \\over 1 - \\varepsilon \\cos(\\theta)}\n$$\n\nCorrespondingly, the rational polar form can be expressed as\n\n$$\nR_1(t) = {1 \\over 1 - \\varepsilon c_1}\n$$\n\nSince polynomial arithmetic is easier to work with than trigonometric identities,\n it is a matter of pencil-and-paper algebra to recover the implicit form from a parametric one.\n\n\n#### Parabola ($|\\varepsilon| = 1$)\n\nThe conic section with the simplest implicit equation is the parabola.\nSince $c_n$ is a simple ratio of polynomials in *t*, it is much simpler to recover the implicit equation.\nFor $\\varepsilon = 1$,\n\n:::: {layout-ncol=\"2\"}\n\n::: {#3902cb4b .cell execution_count=5}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{align*}\n 1 - c_1 &= 1 - {1 - t^2 \\over 1 + t^2}\n = {2 t^2 \\over 1 + t^2}\n \\\\\n y &= {s_1 \\over 1 - c_1}\n = {2t \\over 1 + t^2} {1 + t^2 \\over 2 t^2}\n = {1 \\over t}\n \\\\\n x &= {c_1 \\over 1 - c_1}\n = {1 - t^2 \\over 1 + t^2} \\cdot {1 + t^2 \\over 2 t^2}\n = {1 - t^2 \\over 2t^2}\n \\\\\n &= {1 \\over 2t^2} - {1 \\over 2}\n = {y^2 \\over 2} - {1 \\over 2}\n\\end{align*}\n$$\n:::\n::::\n\n*x* is a quadratic polynomial in *y*, so trivially the figure formed is a parabola.\nTechnically, it is missing the point where $y = 0 ~ (t = \\infty)$.\nUnfortunately, this is not a circumstance where using a higher $c_n$ would help.\nIt is however, similar to the situation where we allow $o(\\infty) = -1$, and an argument\n can be made to waive away any concerns one might have.\n\n\n#### Ellipse ($|\\varepsilon| < 1$)\n\nEllipses are next.\nThe simplest fraction between zero and one is 1/2, so for $\\varepsilon = 1/2$,\n\n:::: {layout-ncol = \"2\"}\n\n::: {#ce1bccb3 .cell execution_count=6}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{align*}\n 1 - {1 \\over 2}c_1 &= 1 - {1 \\over 2} \\cdot {1 - t^2 \\over 1 + t^2}\n = {3 t^2 + 1 \\over 2 + 2t^2}\n \\\\\n y &= {s_1 \\over 1 - {1 \\over 2}c_1}\n = {4t \\over 3t^2 + 1}\n \\\\\n x &= {c_1 \\over 1 - {1 \\over 2}c_1}\n = {2 - 2t^2 \\over 3t^2 + 1}\n\\end{align*}\n$$\n:::\n::::\n\nThere isn't an obvious way write *x* and *y* above as an implicit equation for the curve.\nThe general form of a conic section is $Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$,\n so we know that such an equation curve almost certainly involves $x^2$ and $y^2$.\n\n$$\nx^2 = {4 - 8t^2 + 4t^4 \\over (3t^2 + 1)^2} \\qquad\n y^2 = {16t^2 \\over (3t^2 + 1)^2}\n$$\n\nSquaring produces some $t^4$ terms which cannot exist outside of these terms and *xy*.\nA linear combination of $x^2$ and $y^2$ never includes any cubic terms in the numerator\n which would appear in *xy*, so $B = 0$.\nSince all remaining terms are linear in *x* and *y*, their denominator must appear as a factor\n in the numerator of $Ax^2 + Cy^2$, whatever *A* and *C* are.\n\nSince the coefficient of $t^4$ in $x^2$ is 4, *A* must be multiple of 3.\nThrough trial and error, $A = 3, C = 4$ gives:\n\n$$\n\\begin{align*}\n 3x^2 + 4y^2\n &= {12 - 24t^2 + 12t^4 + 64t^2 \\over (3t^2 + 1)^2}\n \\\\\n &= {12 - 40t^2 + 12t^4 \\over (3t^2 + 1)^2}\n \\\\\n &= {(4t^2 + 12) (3t^2 + 1) \\over (3t^2 + 1)^2}\n \\\\\n &= {4t^2 + 12 \\over 3t^2 + 1}\n\\end{align*}\n$$\n\nSince the numerator of *y* has a *t*, this is clearly some combination of *x* and a constant.\nBy the previous line of thought, the constant term must be a multiple of 4, and picking the smallest\n option finally results in the implicit form:\n\n$$\n\\begin{align*}\n 4 &= {4(3t^2 + 1) \\over 3t^2 + 1}\n = {12t^2 + 4 \\over 3t^2 + 1}\n \\\\\n {4t^2 + 12 \\over 3t^2 + 1} - 4\n &= {8 - 8t^2 \\over 3t^2 + 1} = 4x\n \\\\[14pt]\n 3x^2 + 4y^2 &= 4x + 4\n \\\\\n 3x^2 + 4y^2 - 4x - 4 &= 0\n\\end{align*}\n$$\n\nNotably, the coefficients of *x* and *y* are 3 and 4.\nSimultaneously, $o(\\varepsilon) = o(1/2) = {3 \\over 5} + i{4 \\over 5}$.\nThis binds together three concepts: the simplest case of the Pythagorean theorem,\n the 3-4-5 right triangle; the coefficients of the implicit form; and the role of eccentricity\n with respect to stereography.\n\n\n#### Hyperbola ($|\\varepsilon| > 1$)\n\nAs evidenced by the bound on the eccentricity above, hyperbolae are in some way the inverses of ellipses.\nSince $o(2)$ is a reflection of $o(1/2)$, you might think the implicit equation for\n $\\varepsilon = 2$ to be the same, but with a flipped sign or two.\nUnfortunately, you'd be wrong.\n\n:::: {layout-ncol=\"2\"}\n\n::: {#12a8b8f9 .cell execution_count=7}\n\n::: {.cell-output .cell-output-display}\n{}\n:::\n:::\n\n\n::: {}\n$$\n\\begin{gather*}\n \\begin{align*}\n x &= {c_1 \\over 1 - 2c_1} = {1 - t^2 \\over 3t^2 - 1}\n \\\\\n y &= {s_1 \\over 1 - 2c_1} = {2t \\over 3t^2 - 1}\n \\\\[14pt]\n 3x^2 - y^2 &= {3 - 6t^2 + 3t^4 - 4t^2 \\over 3t^2 - 1}\n \\\\\n &= {(t^2 - 3)(3t^2 - 1) \\over (3t^2 - 1)^2 }\n \\\\\n &= {t^2 - 3 \\over 3t^2 - 1 }\n = ... = -4x - 1\n \\end{align*}\n \\\\[14pt]\n 3x^2 - y^2 + 4x + 1 = 0\n\\end{gather*}\n$$\n:::\n::::\n\nAt the very least, the occurrences of 1 in the place of 4 have a simple explanation: 1 = 4 - 3.\n\n\n### Archimedean Spiral\n\nArguably the simplest (non-circular) polar curve is $r(\\theta) = \\theta$, the unit\n [Archimedean spiral](https://en.wikipedia.org/wiki/Archimedean_spiral).\nSince the curve is defined by a constant turning, this is a natural application of the properties\n of sine and cosine.\nThe closest equivalent in rational polar coordinates is $R_1(t) = t$.\nBut this can be converted to an implicit form:\n\n$$\n\\begin{gather*}\n x = tc_1 \\qquad y = ts_1\n \\\\[14pt]\n x^2 + y^2 = t^2(c_1^2 + s_1^2) = t^2\n \\\\\n y = {2t^2 \\over 1 + t^2} = {2(x^2 + y^2) \\over 1 + (x^2 + y^2)}\n \\\\[14pt]\n (1 + x^2 + y^2)y = 2(x^2 + y^2)\n\\end{gather*}\n$$\n\nThe curve produced by this equation is a\n [right strophoid](https://mathworld.wolfram.com/RightStrophoid.html)\n with a node at (0, 1) and asymptote $y = 2$.\nThis form suggests something interesting about this curve: it approximates the Archimedean spiral\n (specifically the one with polar equation $r(\\theta) = \\theta/2$).\nIndeed, the sequence of curves with parametrization $R_n(t) = 2nt$ approximate the (unit) spiral\n for larger *n*, as can be seen in the following video.\n\n\n\n::: {#fig-approx-archimedes}\n{{< video ./approximate_archimedes.mp4 >}}\n\nApproximations to the Archimedean spiral\n:::\n\n\nSince *R* necessarily defines a rational curve, the curves will never be equal,\n just as any stretching of $c_n$ will never exactly become cosine.\n\n\nClosing\n-------\n\nSine, cosine, and the exponential function, are useful in a calculus setting precisely\n because of their constant \"velocity\" around the circle.\nAlso, nearly every modern scientific calculator in the world features buttons\n for trigonometric functions, so there seems to be no reason *not* to use them.\n\nWe can however be misled by their apparent omnipresence.\nStereographic projection has been around for *millennia*, and not every formula needs to be rewritten\n in its language.\nFor example (and as previously mentioned), defining the Chebyshev polynomials really only requires\n understanding the multiplication of two complex numbers whose norm cannot grow,\n not trigonometry and dividing angles.\nMany other instances of sine and cosine merely rely on a number (or ratio) of loops around a circle.\nWhen velocity does not factor, it will obviously do to \"stay rational\".\n\nOne of my favorite things to plot as a kid were polar roses, so I was somewhat intrigued\n to see that they are, in fact, rational curves.\nOn the other hand, their rationality follows immediately from the rationality of the circle\n (which itself follows from the existence of Pythagorean triples).\nIf I were more experienced with manipulating Chebyshev polynomials or willing to set up a\n linear system in (way too) many terms, I might have considered attempting to find\n an implicit form for them as well.\n\nDiagrams created with Sympy and Matplotlib.\n\n",
"supporting": [
- "index_files/figure-html"
+ "index_files"
],
"filters": [],
"includes": {}
diff --git a/_freeze/posts/math/stereo/3/index/execute-results/html.json b/_freeze/posts/math/stereo/3/index/execute-results/html.json
new file mode 100644
index 0000000..c52be4d
--- /dev/null
+++ b/_freeze/posts/math/stereo/3/index/execute-results/html.json
@@ -0,0 +1,12 @@
+{
+ "hash": "2f05158828573d2e0c44bc4721aa7760",
+ "result": {
+ "engine": "jupyter",
+ "markdown": "---\ntitle: \"Stereographic Hyperspheres\"\ndescription: |\n How do you explicitly describe *n*-dimensional spheres?\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2026-10-04\"\ncategories:\n - algebra\n - topology\n - geometric algebra\ndraft: true\n---\n\n\n\n\n\nIn [the first post of this series](../1/), we explored a definition of quaternions\n and their application to rotation in three dimensions.\nIn doing so, we used stereography to define a point on the 2-sphere, i.e.,\n one whose coordinates satisfy $x^2 + y^2 + z^2 = 1$.\n\nIt's easy to extend this implicit equation to higher-dimensional spheres (or hyperspheres).\nA point $(x_0, x_1, x_2, ... x_n)$ is on a unit hypersphere in *n*+1-dimensional\n Euclidean space if\n\n$$\nx_0^2 + x_1^2 + x_2^2 + ... + x_n^2 = 1\n$$\n\nThis follows naturally from the definition of the sphere as the locus of points which\n all have the same distance to the origin.\nSince this has an implicit equation, there's a natural question: how do we parameterize hyperspheres?\n\n\nGuidance from Lower Dimensions\n------------------------------\n\nBecause points on the sphere are constrained by an equation, there is one fewer degree of freedom\n than a general point in the space they occupy.\nHence, a sphere in *n+1*-dimensional space is itself *n*-dimensional, and is termed an *n*-sphere.\n\nAs a basic example, the complex unit circle is a 1-sphere in the 2-dimensional complex plane:\n\n$$\no(t) = {1 + it \\over 1 - it}\n= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2}\n$$\n\nThe explicit map for the 2-sphere is similar; we have two parameters and\n have two \"nonreal\"s *i* and *j*, which turned out to be quaternions.\n\n$$\no_2(s, t) = {1 + is + jt \\over 1 - is - jt}\n= {1 - s^2 - t^2 \\over 1 + s^2 + t^2} + i{2s \\over 1 + s^2} + j{2t \\over 1 + t^2}\n$$\n\nThese are valid constructions because division works for both complex numbers and quaternions.\nBut the ability to divide\n [isn't very common in higher dimensions](https://mathworld.wolfram.com/DivisionAlgebra.html),\n so without justification, we can't extend it and hope the math works out.\n\n\n### Topological Insights\n\nIn above equation for a circle, we assign values to *t* from a number line,\n a 1-dimensional Euclidean space.\nMore precisely, the line is the imaginary axis $it$ in the numerator.\nWe also include an extra point \"at infinity\".\nThis same point is approached regardless of whether *t* is negative or positive,\n and \"closes\" the circle.\n\n$$\n\\begin{align*}\n o(\\infty) &\\approx {1 + i\\infty \\over 1 - i\\infty}\n \\approx {-\\infty \\over \\infty}\n \\approx -1\n \\\\\n o(-\\infty) &\\approx {1 - i\\infty \\over 1 + i\\infty}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n\\end{align*}\n$$\n\nFor (2-)spheres, a similar statement holds true.\nRather than a line, we range over the imaginary plane $is + jt$, a 2-dimensional Euclidean space.\nIf one or both of the parameters *s* or *t* has a value of \"infinity\",\n then they seem to describe the same point.\n\n$$\n\\begin{align*}\n o_2(s, \\infty) &\\approx {1 + is + j\\infty \\over 1 - is - j\\infty}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n \\\\\n o_2(\\infty, t) &\\approx {1 + i\\infty + jt \\over 1 - i\\infty - jt}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n\\end{align*}\n$$\n\nIn both expressions, the point at infinity contains no \"nonreals\" like *i* or *j*.\nIn another sense, the real space is the extra dimension into which the sphere extends as a surface.\n\nTopologically, this description of the resulting space is called the\n [one-point compactification](https://mathworld.wolfram.com/One-PointCompactification.html).\nIn other words, the circle is the one-point compactification of the line,\n and in general, an *n*-sphere is the one-point compactification of Euclidean *n*-space.\n\n$$\n\\mathbb{E}^{n} \\cup \\{ \\infty \\} \\cong S^n\n$$\n\n\n\n\n### Invariance of Dimension\n\nThe topological definition seems to imply that our construction shouldn't care about\n how many dimensions are in the space.\nIn fact, when constructing the 2-sphere, all we cared about was that *i* and *j* anti-commute\n to get cancellation.\n\n[Geometric algebra](https://en.wikipedia.org/wiki/Geometric_algebra) gives some tools to generalize\n this argument to higher dimensions.\nIn an *n*-dimensional algebra, we have unit vectors ${\\vec e_0}, {\\vec e_1}, ..., {\\vec e_{n-1}}$\n and the following properties:\n\n- Scalars and vectors can be added and multiplied together,\n and all possibilities comprise the algebra\n- The product of a unit vector with itself is a scalar, generally chosen among -1, 0, or 1\n- Scalars commute, but the product of two different unit vectors anticommutes\n - e.g., ${\\vec e_0} {\\vec e_1} = - {\\vec e_1} {\\vec e_0}$\n - Consequently, the square of the product is the negative of the product of the squares\n - e.g., ${\\vec e_0} {\\vec e_1} {\\vec e_0} {\\vec e_1} = - {\\vec e_0} {\\vec e_1} {\\vec e_1} {\\vec e_0} = - {\\vec e_0^2} {\\vec e_1^2}$\n- Division by anything other than scalars is undefined\n\nA consequence is that the square of a general vector $\\vec v$ with components\n ${\\vec e_k}x_k$ is a scalar.\nThis can be seen by arranging the components of the product after distributing as a square:\n\n$$\n\\begin{align*}\n {\\vec v} &= {\\vec e_0} x_0 + {\\vec e_1} x_1 + ... {\\vec e_{n-1}} x_{n-1} = \\sum_k {\\vec e_k} x_k\n \\\\\n {\\vec v^2} &= (\\sum_k^{n-1} {\\vec e_k} x_k) (\\sum_l^{n-1} {\\vec e_l} x_l)\n = \\sum_k^{n-1} \\sum_l^{n-1} {\\vec e_k} {\\vec e_l} x_k x_l\n \\\\\n &= \\underset{\\diagdown}{\\sum_k^{n-1} {\\vec e_k^2} x_k^2}\n + \\underset{◥}{ \\sum_k^{n-1} \\sum_{l > k} {\\vec e_k} {\\vec e_l} x_k x_l }\n + \\underset{◣}{ \\sum_k^{n-1} \\sum_{l < k} {\\vec e_k} {\\vec e_l} x_k x_l }\n\\end{align*}\n$$\n\nDue to anticommutativity, we can cancel the upper and lower triangles, leaving only the diagonal.\n\n$$\n\\begin{align*}\n ◣ &= \\sum_k^{n-1} \\sum_{l < k} {\\vec e_k} {\\vec e_l} x_k x_l\n = \\sum_k^{n-1} \\sum_{k < l} {\\vec e_l} {\\vec e_k} x_l x_k\n \\\\\n &= - \\sum_k^{n-1} \\sum_{l > k} {\\vec e_k} {\\vec e_l} x_k x_l\n = - ◥\n \\\\[10pt]\n &\\implies \\diagdown + ◥ + ◣ = \\diagdown + ◥ - ◥ = \\diagdown\n\\end{align*}\n$$\n\nTo align with the prior examples *i* and *j*, we'll assume that ${\\vec e_k^2} = -1$ for all *k*.\nThis means that ${\\vec v}^2 = - ||{\\vec v}||$, the sum of squares of the extent\n in each basis (or Euclidean norm).\n\n\n### Being Hyperrational\n\nFinally, we can consider an expression analogous to the one from which we derived\n the 1- and 2-spheres.\n\nSuppose that a vector and a scalar are added together, as $a + {\\vec u}$.\nIf this point is on a sphere and the scalar component is considered the extent in a new dimension,\n then the norm of the entire quantity should be\n\n$$\n||a + {\\vec u}|| = a^2 + ||{\\vec u}|| = a^2 - {\\vec u}^2 = 1\n$$\n\nNow let a vector $\\vec v$ range over *n*-dimensional space.\nThe expression...\n\n$$\n{\\bm o_n}({\\vec v}) = a + {\\vec u} = {1 + {\\vec v} \\over 1 - {\\vec v}}\n$$\n\n...seems to be a ratio between two distinct quantities with the same norm,\n since $1^2 - {\\vec v}^2 = 1^2 - (-{\\vec v})^2$.\nHowever, it's ill-defined since there is a vector we can't divide by in the denominator.\nDue to the properties of the algebra, we can use a conjugation trick to clear it:\n\n$$\n\\begin{align*}\n {1 + {\\vec v} \\over 1 - {\\vec v}}\n &= \\left( {1 + {\\vec v} \\over 1 - {\\vec v}} \\right)\n \\left( {1 + {\\vec v} \\over 1 + {\\vec v}} \\right)\n = {(1 + {\\vec v})^2 \\over (1 - {\\vec v})(1 + {\\vec v})}\n \\\\\n &= {1 + 2{\\vec v} + {\\vec v}^2 \\over 1 - {\\vec v}^2}\n \\\\\n &= {1 - ||{\\vec v}|| \\over 1 + ||{\\vec v}||} + {2{\\vec v} \\over 1 + ||{\\vec v}||}\n = a + {\\vec u}\n\\end{align*}\n$$\n\nThe quantity in the denominator of both components is always a scalar and greater than zero,\n so there are no concerns about the validity of division.\nWe can also show that the norm of this expression is 1, as desired:\n\n$$\n\\begin{align*}\n a^2 - {\\vec v}^2 &= 1\n\\\\\n \\implies\n \\stackrel{\\text{Numerator of } a}{(1 + {\\vec v}^2)^2}\n - \\stackrel{\\text{Numerator of } \\vec u}{(2{\\vec v})^2}\n &= \\stackrel{\\text{Common denominator}}{1 - {\\vec v}^2}\n\\end{align*}\n$$\n\nThis is true no matter how many dimensions $\\vec v$ has[^1], justifying our earlier abuse of notation.\n\n[^1]: Technically, this should only hold for finitely many dimensions.\n The $\\infty$-sphere, composed of vectors with only finitely many nonzero components,\n is probably also valid under this construction, but it warrants a proper proof.\n\n\nInducing an Alternative\n-----------------------\n\nThe previous topological description of spheres lacks a couple of things:\n\n- It does not make reference to lower-dimensional spheres\n- \"Points at infinity\", while intuitive, are logically suspect\n\nFortunately, topology has an alternate description.\n\nThe 0-dimensional sphere is a little bit special.\nOn a number line, there are two points equidistant to the origin,\n and these comprise the 0-sphere $S^0$.\nThis can (topologically) be turned into a 1-sphere $S^1$ (the circle) by an operation called\n [suspension](https://en.wikipedia.org/wiki/Suspension_%28topology%29), which connects\n all points in the space to two new, auxiliary points.\nSubsequently, we can take the circle and repeat the operation to build the 2-sphere $S^2$.\n\n\n\nIn general,\n\n$$\n\\text{Susp}(S^{n-1}) = S^n\n$$\n\n\n### Algebraic Suspension\n\nLet's compare the topological definition with what we have algebraically.\nWe first definied the circle, or 1-sphere as\n\n$$\no(t) = {1 + it \\over 1 - it}\n= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2}\n$$\n\nNegating *t* keeps the real part the same, but negates the imaginary part.\nSo in most cases, where there *is* an imaginary part,\n the space looks two discrete points; to wit, a 0-sphere.\nThe remaining two points 1 and -1 are the exception.\n\nSimilarly, when we intersect the 2-sphere with a plane along a line of latitude,\n the space looks like a 1-sphere except at the two poles, also 1 and -1.\n\n\n\nHalfway between the two poles, at the equator, the scalar component is 0 and the sphere is a pure vector.\nFor a general sphere, this happens when $||{\\vec v}|| = 1$:\n\n$$\n{\\bm o_n}({\\vec v})\n= {1 - ||{\\vec v}|| \\over 1 + ||{\\vec v}||}\n+ {2{\\vec v} \\over 1 + ||{\\vec v}||}\n= {1 - 1 \\over 1 + 1} + {2 \\over 1 + 1}{\\vec v}\n= {\\vec v}\n$$\n\nIn general, this happens when $\\vec v$ is a point on a unit sphere of one dimension lower.\nFor the 2-sphere, this is a 1-sphere, which we can easily parametrize using *o*.\nBeing a unit sphere, all points on it behave similarly to *i* in that their square is -1.\nThus, we can construct an expression for the 2-sphere by replacing *i* with the vector in question.\n\n$$\n\\begin{align*}\n {\\vec v} = {\\vec w}_1(s)\n &= {1 - s^2 \\over 1 + s^2} e_0 + {2s \\over 1 + s^2} e_1\n \\\\[10pt]\n {\\bm \\varsigma}_2(s,t) &= {1 + {\\vec w}_1(s)t \\over 1 - {\\vec w}_1(s)t}\n = {1 - t^2 \\over 1 + t^2} + {2t \\over 1 + t^2} {\\vec w}_1(s)\n\\end{align*}\n$$\n\nJust like with *o*, if *t* is replaced with *-t* in the above expression,\n then the scalar part remains the same, but the vector part\n (which corresponds to latitudinal circles) is negated.\nSince the circle is a connected space, we only need one of the two circles this generates,\n and *s* must range over $[0, \\infty]$.\n*s*, however, ranges over $[-\\infty, \\infty)$, since that's the domain of *o*.\n\nThis process can be continued indefinitely -- at each stage,\n $\\bm \\varsigma_n$[^2] describes a *n*-dimensional unit sphere.\nIt can be converted to a pure vector ${\\vec w}_n$ by multiplying the scalar component\n with a new unit vector $e_n$.\nIn this form, ${\\vec w}_n^2 = -1$ for any *n*-dimensional algebra[^3].\nThis provides an inductive construction parallel to the topological one.\n\n[^2]: For \"σφαίρα\", sphere. I'm using ς rather than σ in hope that it's less prone to confusion with \"o\".\n[^3]: This should sound familiar from the first post -- it matches the \"unit quaternions\".\n\n$$\n\\begin{align*}\n {\\vec w}_n(x_0, x_1, ..., x_{n-1})\n &= V({\\bm \\varsigma}_n(x_0, x_1, ..., x_{n-1}))\n \\\\\n &= \\text{Scalar}({\\bm \\varsigma}_n)e_n + \\text{Vector}({\\bm \\varsigma}_n)\n \\\\\n {\\bm \\varsigma}_{n+1}(x_0, x_1, ..., x_{n-1}, x_n)\n &= {1 + {\\vec w}_n(x_0, x_1, ..., x_{n-1})x_n \\over 1 - {\\vec w}_n(x_0, x_1, ..., n_{n-1})x_n}\n \\\\\n &= {1 - x_n^2 \\over 1 + x_n^2} + {2x_n \\over 1 + x_n^2}{\\vec w_n}\n\\end{align*}\n$$\n\nWhen the new parameter $x_n$ is 0 or $\\infty$, the vector part collapses,\n and we get either 1 or -1, the \"new points\" of the suspension.\n\n$$\n\\begin{align*}\n {\\bm \\varsigma}_{n+1}(..., 0)\n &= {1 + {\\vec w}_n(...)\\cdot 0 \\over 1 - {\\vec w}_n(...) \\cdot 0}\n - {1 \\over 1} = 1\n \\\\\n {\\bm \\varsigma}_{n+1}(..., \\infty)\n &\\approx {1 + {\\vec w}_n(...)\\cdot \\infty \\over 1 - {\\vec w}_n(...) \\cdot \\infty}\n \\approx {\\infty \\over -\\infty} \\approx -1\n\\end{align*}\n$$\n\nAll spheres but the 0-sphere are connected spaces, so duplicate latitudinal spheres\n occur in all dimensions greater than 1.\nOnly in dimension 1 are negative numbers required for the expected duplication.\nMore directly, this means that the parameter attached to the 1D case ($x_0$) ranges over\n positive and negative numbers, but all others range over only positve numbers.\n\n\nMultiple Wrappings\n------------------\n\nOne feature of the complex rational circle mentioned in [the previous article](../2/)\n was that its powers correspond to going around multiple times.\nConveniently, a similar fact holds for *n*-spheres in general.\n\nStarting with the scalar/vector form of the sphere, we can square the sphere and apply\n the fact that the difference of squares of each part is constant:\n\n$$\n\\begin{align*}\n {\\bm o}_n &= a + {\\vec u}\n \\\\\n {\\bm o}_n^2 &= (a + {\\vec u})^2\n \\\\\n &= a^2 + {\\vec u}^2 + 2a{\\vec u} +\\textcolor{red}{(0 = a^2 - {\\vec u}^2 - 1)}\n \\\\\n &= 2a^2 - 1 + 2a{\\vec u} = 2a(a + {\\vec u}) - 1\n \\\\\n &= 2a {\\bm o_n} - 1\n\\end{align*}\n$$\n\nThis gives the familiar recurrence relation...\n\n$$\n{\\bm o}_n^{m+2} = 2a {\\bm o}_n^{m+1} - {\\bm o}_n^m\n$$\n\n...and thus a sphere can be wrapped around itself any number of times, as given by\n\n$$\n{\\bm o}_n^m = T_m(a) + U_{m-1}(a){\\vec u}\n$$\n\nwhere *T* and *U* are the standard Chebyshev polynomials.\n\n\n### Negative Indices\n\nThe topological equivalent to this statement is\n\n$$\nH_n(S^n) = \\Z\n$$\n\nMore directly, a map from the *n*-sphere to itself can be characterized by an integer,\n the *degree*, and these compose as integers add.\n\nSince this is an integer, there's the notion of maps in an opposite direction\n which correspond to negative degrees.\nThis seems to align with the behavior of the exponent *m* in ${\\bm o}_n^m$.\nHowever, we've only defined *m* over positive integers;\n after all, $\\bm o_n$ contains a vector, so we can't really divide by it.\n\nFortunately, it's pretty easy to make sense of this.\nSince we have a recurrence relation for the powers of the *n*-sphere, we\n can extend it backwards to define it over negative indices[^4].\n\n$$\n\\begin{align*}\n{\\bm o}_n^1 &= 2a {\\bm o}_n^{0} - {\\bm o}_n^{-1}\n \\\\\n a + {\\vec u} &= 2a - {\\bm o}_n^{-1}\n \\\\\n {\\bm o}_n^{-1} &= a - {\\vec u}\n\\end{align*}\n$$\n\n[^4]: The same argument holds for the Chebyshev polynomials.\n In general, $T_{-n}(x) = T_n(x)$ and $U_{-1} = 0$, $U_{-n}(x) = -U_{n-2}(x)$ for\n the standard indexing of *U*.\n If anything, this is another argument that this indexing of *U* isn't very well-suited,\n since if $U_0 \\stackrel{\\Delta}{=} 0$, it follows that $U_{-n}(x) = -U_{n}(x)$.\n\nThis actually aligns with what we'd expect according to adding powers, since:\n\n$$\n({\\bm o}_n^1)({\\bm o}_n^{-1})\n= (a + {\\vec u})(a - {\\vec u}) = a^2 - {\\vec u}^2\n= 1 = {\\bm o}_n^0\n$$\n\n\n### Degrees and Induction\n\nThe inductive case was established by noticing that a vector $\\vec w$ lying on a unit sphere\n behaves similarly to *i* in that that ${\\vec w}^2 = -1$.\nWe can use the same trick for higher-order wrappings -- the only thing that needs changing\n from the previous article is replacing \"real\" with \"scalar\" and \"nonreal\" with \"vector\".\n\n$$\n{\\bm \\varsigma}_n^m\n= ( c + s { {\\vec w}_{n-1}} )^m\n= T_m(c) + s U_m(c) {\\vec w}_{n-1}\n$$\n\nSimilarly,\n\n$$\n\\begin{align*}\n{\\bm \\varsigma}_n^{-1} &= ( c - s{\\vec w}_{n-1} )\n\\\\\n({\\bm \\varsigma}_n^{1}) ({\\bm \\varsigma}_n^{-1})\n &= ( c + s{\\vec w}_{n-1} )( c - s{\\vec w}_{n-1} )\n \\\\\n &= c^2 - s^2 {\\vec w}_{n-1}^2 = c^2 + s^2 = 1\n \\\\\n &= {\\bm \\varsigma}_n^0\n\\end{align*}\n$$\n\nTechnically, $\\bm \\varsigma_n$ is already a higher-degree map when all parameters\n (besides the one from the base case) are allowed to range over negative numbers.\nIn this case, $\\bm \\varsigma_2^\\pm$ is a degree-2 map, $\\bm \\varsigma_3^\\pm$ is a degree-4 map,\n and $\\bm \\varsigma_n^\\pm$ is a degree-$2^{n-1}$ map.\n\n\nDe-infinitizing\n---------------\n\nThe degree also gives us the tools to address \"points at infinity\".\nIf $\\vec w_n$ is a point on the equatorial unit *n-1*-sphere, then $\\bm o_n$\n behaves as the identity.\nBut we also know that it squares to -1, and that squaring $\\bm o_n$ produces a degree-2 map.\n\n$$\n{\\bm o}_n({\\vec w}_n)^2 = {\\vec w}_n^2 = -1\n$$\n\nThis means that the degree-2 map can be interpreted as collapsing the equator\n to a single point, the pole -1.\nThe hemi-*n*-sphere surrounding the antipode 1 gets closed, resulting in the whole *n*-sphere.\n\n::: {#f7c2eba4 .cell execution_count=3}\n``` {.python .cell-code code-fold=\"true\"}\n# circle map\ns,t = sympy.symbols(\"s t\", real=True)\no = (1 + sympy.I*s) / (1 - sympy.I*s)\n\n# doubled map for finite range\no2 = o**2\no2_real, o2_imag = o2.as_real_imag()\n\n# inductive 2-sphere\nsphere_x = o2_real.subs(s,t)\nsphere_y = o2_imag.subs(s,t)*o2_real\nsphere_z = o2_imag.subs(s,t)*o2_imag\n\ndef animate_sphere(filename: str, n=30, interval=80):\n lerp_steps = np.linspace(0, 1, n)\n t_hemisphere = 2**0.5 - 1\n\n with SympyAnimationWrapper(filename) as animate:\n @animate(len(lerp_steps), interval=interval)\n def ret(fr):\n plt.clf()\n lerp = lerp_steps[fr]\n\n t_upper = t_hemisphere*(1 - lerp) + 1*lerp\n p = plot.plot3d_parametric_surface(\n sphere_x, sphere_y, sphere_z,\n (s, -1, 1), (t, 0, t_upper),\n xlim=(-1,1), ylim=(-1,1), zlim=(-1,1),\n show=False,\n backend=\"matplotlib\",\n )\n p2 = plot.plot3d_parametric_line(\n sphere_x.subs(t, t_upper), sphere_y.subs(t, t_upper), sphere_z.subs(t, t_upper),\n (s, -1, 1),\n show=False,\n backend=\"matplotlib\",\n )\n p.append(p2[0])\n p.show()\n\n ret.save() # type: ignore\n\nanimate_sphere(\"close_equatorial_sphere.mp4\")\n```\n:::\n\n\n::: {#fig-hemisphere-closure}\n{{< video \"./close_equatorial_sphere.mp4\" >}}\n\nEffect of the degree-2 map on the hemisphere containing the scalar 1.\n:::\n\nIn the one-point construction, this region can only be described using all components of the input vector,\n since the scalar component depends on it.\nThus, the domain is made finite just by squaring ***o***.\n\nHowever, in the inductive construction, the scalar component only depends on\n the new free parameter, leaving the domain of lower-dimensional spheres unaffected,\n and potentially still unbounded.\n\nThe layered nature of the inductive construction means there are different \"levels\"\n at which wraps can be placed.\nFor example, for the 2-sphere, the smallest domain for which the entire sphere is parametrized\n is shown in the table below:\n\n| Sphere | Domain for first wrap around the sphere |\n|----------------------------------------|----------------------------------------------------|\n| ${\\bm o}_2^2({\\vec e_0} s + {\\vec e_1} t)$ | $s^2 + t^2 \\le 1$ |\n| ${\\bm \\varsigma}_2^2({\\bm \\varsigma}_1(s),t)$ | $s \\in [-\\infty, \\infty] \\quad t \\in [0, 1)$ |\n| ${\\bm \\varsigma}_2({\\bm \\varsigma}_1^2(s),t)$ | $s \\in [-1, 1] \\quad t \\in [0, \\infty]$ |\n| ${\\bm \\varsigma}_2^2({\\bm \\varsigma}_1^2(s),t)$ | $s \\in [-1, 1] \\quad t \\in [0, 1]$ |\n\nA finite domain is only achieved in the final case, corresponding to the combination of\n two separate degree-2 maps (i.e., a degree-4 map).\n\n\n### Closing the Disc\n\nOf course, the behavior of the equator comes with another topological analogue.\nAnother description of the *n*-sphere is by taking the boundary of an *n*-dimensional disc\n and collapsing its boundary to a single point.\n\n$$\n{ D^n / \\partial D^n } = S^n\n$$\n\nThis exactly aligns with the behavior of the equator when going from the degree-1 to the degree-2 map.\nIf ${\\vec u}_n$ has a norm of less than or equal to 1, then it lies within a unit disc.\nThis unit disc gets sent by $\\bm o_n$ to the aforementioned \"hemisphere around the scalar 1\",\n and when fed to $\\bm o_n^2$, it produces the *n*-sphere.\n\n\nClosing\n-------\n\nThere's still a lot worth discussing here.\n\nFor spheres themselves, one-point spheres provide an base-case in any dimension\n for inductive spheres.\nThis, combined with the choice of degree at each level of induction,\n grants the potential for many interesting descriptions,\n which get more numerous in higher dimensions.\nFor example, while there's only one degree-4 map for the 1-sphere,\n there are four for the 2-sphere (depending on choice of bounds).\n\nFor topology, I find that these constructions do a lot to nail down its typically abstract nature.\nThere are still a lot of interesting arguments to nail down,\n such as the degree of the antipodal map, or describing explicit, purely algebraic homotopies.\n\nFinally there's the geometric algebra itself.\nChoosing anything but vectors with the expected properties results in surfaces other than spheres.\nThis can get even more complicated when considering product of vectors as non-scalar components\n of the \"sphere\".\nIt's difficult to imagine what these look like in higher dimensions, or what interesting\n propositions they connect to.\n\nThe most convenient part of these constructions is the complexity they manage.\nThe alternative is attempting to come up with complicated polynomials\n in way too many variables to keep track of individually,\n all while managing equalities between them.\nInstead, algebra serves algebra while also significantly benefitting geometry and topology.\n\nDiagrams created with Geogebra, Sympy and Matplotlib.\n\n",
+ "supporting": [
+ "index_files"
+ ],
+ "filters": [],
+ "includes": {}
+ }
+}
\ No newline at end of file
diff --git a/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-3.png b/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-3.png
new file mode 100644
index 0000000..f306216
--- /dev/null
+++ b/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-3.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:be640d2d6f5d382d0e753bb6d024c1a5eec43266f140add81fbd4c3d438d8fa6
+size 156037
diff --git a/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-4.png b/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-4.png
new file mode 100644
index 0000000..b629232
--- /dev/null
+++ b/_freeze/posts/math/stereo/3/index/figure-html/cell-3-output-4.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac47ca90fe3cfc020e5bc3f21a6014fda4646fa39bf29ddf2f2cf38369b407cd
+size 161423
diff --git a/_freeze/posts/math/stereo/3/inductive/execute-results/html.json b/_freeze/posts/math/stereo/3/inductive/execute-results/html.json
new file mode 100644
index 0000000..37bcb6a
--- /dev/null
+++ b/_freeze/posts/math/stereo/3/inductive/execute-results/html.json
@@ -0,0 +1,12 @@
+{
+ "hash": "40450c54411e15421f8035826a22d5b3",
+ "result": {
+ "engine": "jupyter",
+ "markdown": "---\ntitle: \"Stereographic Hyperspheres\"\ndescription: |\n TODO\nformat:\n html:\n html-math-method: katex\njupyter: python3\ndate: \"2026-09-11\"\ncategories:\n - algebra\n - topology\n - geometric algebra\n---\n\n\nIn [the first post of this series](../1/), we explored the application of the quaternions\n to rotation in three dimensions.\nRotation is one problem, but the quaternions and the characterization of the sphere given\n correspond to another: how do we parameterize higher-dimensional spheres?\n\nIt's relatively easy to describe spheres implicitly using coordinates.\nThe natural definition is the locus of points which all have the same distance to the origin\n in Euclidean space.\nIn other words, a point $(x_0, x_1, x_2, ... x_n)$ is on a unit hypersphere\n in *n*+1-dimensional space if\n\n$$\nx_0^2 + x_1^2 + x_2^2 + ... + x_n^2 = 1\n$$\n\n\nGuidance from Lower Dimensions\n------------------------------\n\nBecause points on the sphere are constrained by an equation, there is one fewer degree of freedom\n than a general point in the space they occupy.\nHence, a sphere in *n+1*-dimensional space is itself *n*-dimensional, and is termed an *n*-sphere.\n\nAs a basic example, the complex unit circle is a 1-sphere in the 2-dimensional complex plane:\n\n$$\no(t) = {1 + it \\over 1 - it}\n= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2}\n$$\n\nThe explicit map for the 2-sphere is similar; we have two parameters and\n have two \"nonreal\"s *i* and *j*, which turned out to be quaternions.\n\n$$\no_2(s, t) = {1 + is + jt \\over 1 - is - jt}\n= {1 - s^2 - t^2 \\over 1 + s^2 + t^2} + i{2s \\over 1 + s^2} + j{2t \\over 1 + t^2}\n$$\n\nThese are valid constructions because division works for both complex numbers and quaternions.\n\n\n### Topological Insights\n\nIn above equation for a circle, we assign values to *t* from a number line,\n a 1-dimensional Euclidean space.\nMore precisely, the line is the imaginary axis $it$ in the numerator.\nWe also include an extra point \"at infinity\".\nThis same point is approached regardless of whether *t* is negative or positive,\n and \"closes\" the circle.\n\n$$\n\\begin{align*}\n o(\\infty) &\\approx {1 + i\\infty \\over 1 - i\\infty}\n \\approx {-\\infty \\over \\infty}\n \\approx -1\n \\\\\n o(-\\infty) &\\approx {1 - i\\infty \\over 1 + i\\infty}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n\\end{align*}\n$$\n\nFor (2-)spheres, a similar statement holds true.\nRather than a line, we range over the imaginary plane $is + jt$, a 2-dimensional Euclidean space.\nIf one or both of the parameters *s* or *t* has a value of \"infinity\",\n then they seem to describe the same point.\n\n$$\n\\begin{align*}\n o_2(s, \\infty) &\\approx {1 + is + j\\infty \\over 1 - is - j\\infty}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n \\\\\n o_2(\\infty, t) &\\approx {1 + i\\infty + jt \\over 1 - i\\infty - jt}\n \\approx {\\infty \\over -\\infty}\n \\approx -1\n\\end{align*}\n$$\n\nIn both expressions, the point at infinity contains no \"nonreals\" like *i* or *j*.\nIn another sense, the real space is the extra dimension into which the sphere extends as a surface.\n\nTopologically, this description of the resulting space is called the\n [one-point compactification](https://mathworld.wolfram.com/One-PointCompactification.html).\nIn other words, the circle is the one-point compactification of the line,\n and in general, an *n* sphere is the one-point compactification of Euclidean *n*-space.\n\n$$\n\\mathbb{E}^{n} \\cup \\{ \\infty \\} \\cong S^n\n$$\n\n![]()\n\n\n### Invariance of Dimension\n\nThe topological definition seems to imply that our construction shouldn't care about\n how many dimensions are in the space.\nIn fact, when constructing the 2-sphere, all we cared about was that *i* and *j* anti-commute\n to get cancellation.\n\n[Geometric algebra](https://en.wikipedia.org/wiki/Geometric_algebra) gives some tools to generalize\n this argument to higher dimensions.\nIn an *n*-dimensional algebra, we have unit vectors $e_0, e_1, ..., e_{n-1}$\n and the following properties:\n\n- Scalars and vectors can be added and multiplied together,\n and all possibilities comprise the algebra\n- The product of a unit vector with itself is a scalar, generally chosen among -1, 0, or 1\n- Scalars commute, but the product of two different unit vectors anticommutes\n - e.g., $e_0 e_1 = - e_1 e_0$\n - Consequently, the square of the product is the negative of the product of the squares\n - e.g., $e_0 e_1 e_0 e_1 = - e_0 e_1 e_1 e_0 = - e_0^2 e_1^2$\n- Division by anything other than scalars is undefined\n\nA consequence is that the square of a general vector ***v*** with components $x_k e_k$ is a scalar.\nThis can be seen by arranging the components of the product after distributing as a square:\n\n$$\n\\begin{align*}\n {\\bm v} &= e_0 x_0 + e_1 x_1 + ... e_{n-1} x_{n-1} = \\sum_k e_k x_k\n \\\\\n {\\bm v}^2 &= (\\sum_k^{n-1} e_k x_k) (\\sum_l^{n-1} e_l x_l)\n = \\sum_k^{n-1} \\sum_l^{n-1} e_k e_l x_k x_l\n \\\\\n &= \\underset{\\diagdown}{\\sum_k^{n-1} e_k^2 x_k^2}\n + \\underset{◥}{ \\sum_k^{n-1} \\sum_{l > k} e_k e_l x_k x_l }\n + \\underset{◣}{ \\sum_k^{n-1} \\sum_{l < k} e_k e_l x_k x_l }\n\\end{align*}\n$$\n\nDue to anticommutativity, we can cancel the upper and lower triangles, leaving only the diagonal.\n\n$$\n\\begin{align*}\n ◣ &= \\sum_k^{n-1} \\sum_{l < k} e_k e_l x_k x_l\n = \\sum_k^{n-1} \\sum_{k < l} e_l e_k x_l x_k\n \\\\\n &= - \\sum_k^{n-1} \\sum_{l > k} e_k e_l x_k x_l\n = - ◥\n \\\\[10pt]\n &\\implies \\diagdown + ◥ + ◣ = \\diagdown + ◥ - ◥ = \\diagdown\n\\end{align*}\n$$\n\nTo align with the prior examples *i* and *j*, we'll assume that $e_k^2 = -1$ for all *k*.\nThis means that ${\\bm v}^2 = - ||{\\bm v}||$, the sum of squares of the extent\n in each basis (or Euclidean norm).\n\n\n### Being Hyperrational\n\nFinally, we can consider an expression analogous to the one from which we derived\n the 1- and 2-spheres.\n\nSuppose that a vector and a scalar are added together, as $a + {\\bm v}$.\nIf this point is on a sphere and the scalar component is considered the extent in a new dimension,\n then the norm of the entire quantity should be\n\n$$\n||a + {\\bm v}|| = a^2 + ||{\\bm v}|| = a^2 - {\\bm v}^2 = 1\n$$\n\nAs a vector ***u*** ranges over *n*-dimensional space, the expression...\n\n$$\no_n({\\bm u}) = {1 + {\\bm u} \\over 1 - {\\bm u}}\n$$\n\n...seems to be a ratio between two distinct quantities with the same norm,\n since $1^2 - {\\bm u}^2 = 1^2 - (-{\\bm u})^2$.\nThis expression is actually ill-defined since there is a vector in the denominator,\n but we can use a conjugation trick to clear it:\n\n$$\n\\begin{align*}\n {1 + {\\bm u} \\over 1 - {\\bm u}}\n &= \\left( {1 + {\\bm u} \\over 1 - {\\bm u}} \\right)\n \\left( {1 + {\\bm u} \\over 1 + {\\bm u}} \\right)\n = {(1 + {\\bm u})^2 \\over (1 - {\\bm u})(1 + {\\bm u})}\n \\\\\n &= {1 + 2{\\bm u} + {\\bm u}^2 \\over 1 - {\\bm u}^2}\n \\\\\n &= {1 - ||{\\bm u}|| \\over 1 + ||{\\bm u}||} + {2{\\bm u} \\over 1 + ||{\\bm u}||}\n = a + {\\bm v}\n\\end{align*}\n$$\n\nThe quantity in the denominator of both components is always a scalar and greater than zero,\n so there are no concerns about the validity of division.\nWe can also show that the norm of this expression is 1, as desired:\n\n$$\n\\begin{align*}\n a^2 - {\\bm v}^2 &= 1\n\\\\\n \\implies\n \\stackrel{\\text{Numerator of } a}{(1 + {\\bm u}^2)^2}\n - \\stackrel{\\text{Numerator of } \\bm v}{(2{\\bm u})^2}\n &= \\stackrel{\\text{Common denominator}}{1 - {\\bm u}^2}\n\\end{align*}\n$$\n\nThis is true no matter how many dimensions ***v*** has[^1], justifying our earlier abuse of notation.\n\n[^1]: Technically, this should only hold for finitely many dimensions.\n The $\\infty$-sphere, composed of vectors with only finitely many nonzero components,\n is probably also valid under this construction, but I haven't proven this.\n\n:::{}\nTODO: Chebyshev relation on this form of the sphere is also valid!\n:::\n\n\nInducing an Alternative\n-----------------------\n\nThe previous topological description of spheres lacks a couple of things:\n\n- It does not make reference to lower-dimensional spheres\n- \"Points at infinity\", while intuitive, are logically suspect\n\nFortunately, topology has an alternate description.\n\nThe 0-dimensional sphere is a little bit special.\nOn a number line, there are two points equidistant to the origin,\n and these comprise the 0-sphere $S^0$.\nThis can (topologically) be turned into a 1-sphere $S^1$ (the circle) by an operation called\n [suspension](https://en.wikipedia.org/wiki/Suspension_%28topology%29), which connects\n all points in the space to two new, auxiliary points.\nSubsequently, we can take the circle and repeat the operation to build the 2-sphere $S^2$.\n\nIn general,\n\n$$\n\\text{Susp}(S^{n-1}) = S^n\n$$\n\n![]()\n\n\n### Algebraic Dual, Part 2\n\nLet's look at the first interesting case.\nWe first definied the circle, or 1-dimensional sphere as\n\n$$\no(t) = {1 + it \\over 1 - it}\n= {1 - t^2 \\over 1 + t^2} + i{2t \\over 1 + t^2}\n$$\n\nIf the real part remains fixed, then in most cases,\n the space looks two discrete points; to wit, a 0-dimensional sphere.\nThe remaining two points 1 and -1 are in some sense \"new\" to the space.\n\n![]()\n\nSimilarly, when we intersect the 2-sphere with a plane along a line of latitude,\n the space looks like a 1-dimensional sphere except at two points, also 1 and -1.\n\n![]()\n\nIf we create a 2D vector with components in the real and imaginary parts of *o*,\n we can immediately create an expression for the 2-sphere:\n\n$$\n\\begin{align*}\n {\\bm w}_1(t) &= {1 - t^2 \\over 1 + t^2} e_0 + {2t \\over 1 + t^2} e_1\n \\\\[10pt]\n \\varsigma_2(s,t) &= {1 + {\\bm w}_1(t)s \\over 1 - {\\bm w}_1(t)s}\n = {1 - s^2 \\over 1 + s^2} + {2s \\over 1 + s^2} {\\bm w}_1(t)\n\\end{align*}\n$$\n\nNote that if *s* is exchanged with *-s*, then the scalar part remains the same,\n but the vector part, which corresponds to latitudinal circles, is negated.\nIn effect, this means that if *s* is allowed to range over negative numbers,\n we will produce two duplicate circles.\n\nThis process can be continued indefinitely -- at each stage,\n $\\varsigma_k$[^2] describes a *k*-dimensional unit sphere.\nIt be converted to a pure vector ${\\bm w}_k$ by multiplying the scalar component\n with a new unit vector $e_k$.\nIn this form, ${\\bm w}_k^2 = -1$ for any *k*-dimensional algebra[^3].\nThis provides an inductive construction parallel to the topological one.\n\n[^2]: For \"σφαίρα\", sphere. I'm using ς in hope that it'll be less prone to confusion with \"o\".\n[^3]: This should sound familiar from the first post -- it matches the \"unit quaternions\".\n\n$$\n\\begin{align*}\n {\\bm w}_k(x_0, x_1, ..., x_{k-1})\n &= \\text{Scalar}(\\varsigma_k(x_0, x_1, ..., x_{k-1}))e_k\n \\\\\n &+ \\text{Vector}(\\varsigma_k(x_0, x_1, ..., x_{k-1}))\n \\\\\n \\varsigma_{k+1}(x_0, x_1, ..., x_{k-1}, x_k)\n &= {1 + {\\bm w}_k(x_0, x_1, ..., x_{k-1})x_k \\over 1 - {\\bm w}_k(x_0, x_1, ..., k_{k-1})x_k}\n\\end{align*}\n$$\n\nWhen the new parameter $x_k$ is 0 or $\\infty$, the vector part collapses,\n and we get either 1 or -1, the \"new points\" of the suspension.\n\n$$\n\\begin{align*}\n \\varsigma_{k+1}(..., 0)\n &= {1 + {\\bm w}_k(...)\\cdot 0 \\over 1 - {\\bm w}_k(...) \\cdot 0}\n - {1 \\over 1} = 1\n \\\\\n \\varsigma_{k+1}(..., \\infty)\n &\\approx {1 + {\\bm w}_k(...)\\cdot \\infty \\over 1 - {\\bm w}_k(...) \\cdot \\infty}\n \\approx {\\infty \\over -\\infty} \\approx -1\n\\end{align*}\n$$\n\nThe phenomenon of duplicate latitudinal spheres is a recurring one in dimensions greater than 1.\nThis can be seen from the 0-sphere being unique among spheres --\n as two discrete, disconnected points, negative numbers are needed for the expected duplication.\nMore directly, this means that the parameter attached to the 1D case ($x_0$) ranges over\n positive and negative numbers, but all others range over only positve numbers.\n\n:::{TODO}\nWe could also construct $\\bm w$ from the results in the previous section.\n:::\n\n\nMultiple Wrappings\n------------------\n\nOne feature of the complex rational circle mentioned in [the previous article](../2/)\n was that its powers correspond to going around multiple times.\nConveniently, a similar fact holds for *n*-spheres in general.\n\nStarting with the scalar/vector form of the sphere, we can square the sphere and apply\n the fact that the difference of squares of each part is constant:\n\n$$\n\\begin{align*}\n o_n &= a + {\\bm v}\n \\\\\n o_n^2 &= (a + {\\bm v})^2 = a^2 + {\\bm v}^2 + 2a{\\bm v}\n \\\\\n &= a^2 + {\\bm v}^2 + \\textcolor{red}{(a^2 - {\\bm v}^2 - 1 = 0)} + 2a{\\bm v}\n \\\\\n &= 2a^2 - 1 + 2a{\\bm v} = 2a(a + {\\bm v}) - 1 = 2a o_n - 1\n\\end{align*}\n$$\n\nThis gives the familiar recurrence relation...\n\n$$\no_n^{m+2} = 2a o_n^{m+1} - o_n^m\n$$\n\n...and thus a sphere can be wrapped around itself any number of times, as given by:\n\n$$\no_n^m = T_m(a) + U_{m-1}(a){\\bm u}\n$$\n\n*T* and *U* are the standard Chebyshev polynomials.\n\n\n### Negative Indices and Beyond\n\nThe topological equivalent to this statement is\n\n$$\nH_n(S^n) = \\Z\n$$\n\nMore directly, a map from the *n*-sphere to itself can be characterized by an integer,\n the *degree*, and these compose as integers add.\nSince this is an integer, there's the notion maps in an opposite direction\n which correspond to negative degrees.\nThis seems to align with the behavior of the exponent in $o_n^m$.\nHowever, we've only defined *m* over positive integers;\n after all, $o_n$ contains a vector, so we can't really divide by it.\n\nFortunately, it's pretty easy to make sense of this.\nSince we have a recurrence relation for the powers of the sphere, we\n can extend it backwards to define it over negative indices[^4].\n\n$$\n\\begin{align*}\n o_n^1 &= 2a o_n^{0} - o_n^{-1}\n \\\\\n a + {\\bm v} &= 2a - o_n^{-1}\n \\\\\n o_n^{-1} &= a - {\\bm v}\n\\end{align*}\n$$\n\n[^4]: The same argument holds for the Chebyshev polynomials.\n In general, $T_{-n}(x) = T_n(x)$ and $U_{-1} = 0$, $U_{-n}(x) = -U_{n-2}(x)$ for\n the standard indexing of *U*.\n If anything, this is another argument that this indexing of *U* isn't very well-suited,\n since if $U_0 \\stackrel{\\Delta}{=} 0$, it follows that $U_{-n}(x) = -U_{n}(x)$.\n\nThis actually aligns with what we'd expect according to adding powers, since:\n\n$$\no_n^1 \\cdot o_n^{-1} = (a + {\\bm v})(a - {\\bm v}) = a^2 - {\\bm v}^2 = 1 = o_n^0\n$$\n\n\n### Degrees and Induction\n\nIn the inductive case, since ${\\bm w}^2 = -1$, we can pull a similar trick.\nReplacing *i* with ***w***, the only thing that needs changing from the previous article is\n replacing \"real\" with \"scalar\" and \"nonreal\" with \"vector\".\n\n$$\n\\varsigma_n^m\n= ( c + s \\cdot { {\\bm w}_{n-1}} )^m\n= T_m(c) + s U_m(c) \\cdot {\\bm w}_{n-1}\n$$\n\nSimilarly,\n\n$$\n\\begin{align*}\n\\varsigma_n^{-1} &= ( c - s \\cdot { {\\bm w}_{n-1}} )\n\\\\\n\\varsigma_n^{1} \\cdot \\varsigma_n^{-1}\n &= ( c + s \\cdot {{\\bm w}_{n-1}} )( c - s \\cdot {{\\bm w}_{n-1}} )\n \\\\\n &= c^2 - s^2 {\\bm w}_{n-1}^2 = c^2 + s^2\n \\\\\n &= 1 = \\varsigma_n^0\n\\end{align*}\n$$\n\n\nDegree 2 and the Equator\n------------------------\n\nThe prior discussion about degree gives us the tools to address \"points at infinity\".\nAs a reminder, if we let a vector ***u*** range over the entirety of Euclidean space,\n the sphere is only closed by allowing such an extra point.\n\nWe can get rid of this point for the circle by considering a degree 2 map rather than a degree 1 map.\nThe former wraps around once $-\\infty$ to $\\infty$, while the latter wraps around once from -1 to 1.\nConveniently, -1 and 1 are both the points at which the real part of the degree 1 map becomes 0.\nPoints in this range lie on the semicircle bounded by these two points (which form a 0-sphere).\n\n![]()\n\nFor higher-dimensional spheres we just need to replace \"real part\" with \"scalar part\".\nFor a sphere $o_n({\\bm u}_n)$, this is precisely when ${\\bm u}_n$ has a norm of 1.\n\n$$\no_n({\\bm u}_n)\n= {1 - ||{\\bm u_n}|| \\over 1 + ||{\\bm u_n}||}\n+ {2{\\bm u_n} \\over 1 + ||{\\bm u_n}||}\n= {1 - 1 \\over 1 + 1} + {2 \\over 1 + 1}{\\bm u_n}\n= {\\bm u}_n\n$$\n\nLet *n* = 2 so we can plot it.\nThen we're actually talking about place in which the unit sphere in 3D space looks like the unit circle.\nSpecifically, this unit circle can be considered an equator bounding the hemisphere around the scalar 1.\n\n![]()\n\nIn general ${\\bm u}_n$ has a norm of 1 exactly when it's a point on the equatorial *n-1*-sphere.\nConveniently, under the degree 2 map, this equatorial sphere collapses to a single point.\n\n$$\no_n({\\bm u}_n)^2\n= {\\bm u}_n^2 = -1\n$$\n\nThis point was formerly the image of the point at infinity,\n eliminating its necessity in the description of the *n*-sphere.\n\n\n### Closing the Sphere\n\nOf course, this comes with another topological analogue.\nAnother description of the *n*-sphere is by taking the boundary of an *n*-dimensional disc\n and collapsing its boundary to a single point.\n\n$$\n{ D^n / \\partial D^n } = S^n\n$$\n\nThis exactly aligns with the behavior of the equator when going from the degree 1 to the degree 2 map.\nIf ${\\bm u}_n$ has a norm of less than or equal to 1, then it lies within a unit disc.\nThis unit disc gets sent by $o_n$ to the aforementioned \"hemisphere around the scalar 1\",\n and when fed to $o_n^2$, it produces the *n*-sphere.\n\n\nClosing\n-------\n\nThere are a couple of things that I still want to explore here.\nOne is the composition of one-point spheres and inductive spheres.\nThis structure should describe an (unbounded) lattice, where every \"one-point\" parametrization\n has no lesser element, but has a greater element as an element in an inductive parametrization.\nParametrizations should be considered the same up to a symmetric transformation of coordinates.\n\nThere's also a lot of interesting topological arguments to nail down.\nOne of these is the degree of the antipodal map.\nAnother is constructing explicit homotopies purely from algebra.\n\n",
+ "supporting": [
+ "inductive_files"
+ ],
+ "filters": [],
+ "includes": {}
+ }
+}
\ No newline at end of file
diff --git a/posts/math/stereo/2/index.qmd b/posts/math/stereo/2/index.qmd
index 964b99b..159ae7e 100644
--- a/posts/math/stereo/2/index.qmd
+++ b/posts/math/stereo/2/index.qmd
@@ -111,36 +111,37 @@ This is also the *only* property upon which the recurrence depends; all else is
Knowing this, let's start over with the stereographic projection of the circle:
$$
-o_1(t) = {1 + it \over 1 - it}
+o(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)$, the function loops once
- around the unit circle.
-Taking this to higher powers keeps points on the circle since all points on the circle
+The subscript "1" for *c* and *s* is because as *t* ranges over $[-\infty, \infty)$,
+ the function loops once around the unit circle.
+Taking *o* to higher powers keeps points on the circle since all points on the circle
have a norm of 1.
It also makes more loops around the circle, which we can denote by larger subscripts:
$$
\begin{align*}
- o_n &= (o_1)^n
- = \left( {1 + it \over 1 - it} \right)^n
+ o^n
+ &= \left( {1 + it \over 1 - it} \right)^n
\\
- \text{c}_n + i\text{s}_n
- &= (\text{c}_1 + i\text{s}_1)^n
+ &= (\text{c}_1 + i\text{s}_1)^n
+ \\
+ &= \text{c}_n + i\text{s}_n
\end{align*}
$$
This mirrors raising the complex exponential to a power
- (which loops over the range $(-\pi, \pi)$ instead).
+ (which loops over the range $[-\pi, \pi)$ instead).
The final line is analogous to de Moivre's formula, but in a form where everything is
a ratio of polynomials in *t*.
This 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
+ o^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)
@@ -149,11 +150,11 @@ $$
\\
&= 2\text{c}_1(\text{c}_1 + i\text{s}_1) - 1
\\
- &= 2\text{c}_1 o_1 - 1
+ &= 2\text{c}_1 o - 1
\\
- o_2 \cdot (o_1)^n &= 2\text{c}_1 o_1 \cdot (o_1)^n - (o_1)^n
+ o^2 \cdot o^n &= 2\text{c}_1 o \cdot o^n - o^n
\\
- o_{n+2} &= 2\text{c}_1 o_{n+1} - o_n
+ o^{n+2} &= 2\text{c}_1 o^{n+1} - o^n
\end{align*}
$$
@@ -211,7 +212,7 @@ Meanwhile, the complex stereograph has derivative
$$
\begin{align*}
- {d \over dt} o_1(t) &= {d \over dt} {1 + it \over 1 - it}
+ {d \over dt} o(t) &= {d \over dt} {1 + it \over 1 - it}
= {i(1 - it) + i(1 + it) \over (1 - it)^2}
\\
&= {2i \over (1 - it)^2}
@@ -224,20 +225,19 @@ $$
\\
&= -(1 + c_1)s_1 + i(1 + c_1)c_1
\\
- &= i(1 + c_1)o_1
+ &= i(1 + c_1)o
\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.
+However, the expression also accrues $1 + c_1$ as an adjustment factor.
+The complex exponential doesn't need this term because it goes around the circle at a constant rate,
+ resulting in a simpler relationship with respect to the derivative.
### Complex Analysis
-Since $o_n$ is a curve which loops around the unit circle *n* times, that possibly suits it
+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.
@@ -249,16 +249,16 @@ $$
= 2\pi i
$$
-In this example, *Γ* is a counterclockwise curve parametrized by *γ* which loops once around
+In this example, Γ is a counterclockwise curve parametrized by *γ* which loops once around
the pole at *z* = 0.
More loops will scale this by a factor according to the number of loops.
-Normally this equality is demonstrated with the complex exponential, but will $o_1$ work just as well?
-If *Γ* is the unit circle, the integral is:
+Normally this equality is demonstrated with Γ as the unit circle and *γ* as the complex exponential?
+But will *o* work just as well in place of the latter?
$$
\oint_\Gamma {1 \over z} dz
- = \int_{-\infty}^\infty {o_1'(t) \over o_1(t)} dt
+ = \int_{-\infty}^\infty {o'(t) \over o(t)} dt
= \int_{-\infty}^\infty i(1 + c_1(t)) dt
= 2i\int_{-\infty}^\infty {1 \over 1 + t^2} dt
$$
@@ -272,30 +272,30 @@ Since powers of *o* are more loops around the circle, the chain and power rules
$$
\begin{gather*}
- {d \over dt} (o_1)^n = n(o_1)^{n-1} {d \over dt} o_1
+ {d \over dt} o^n = no^{n-1} {d \over dt} o
\\[14pt]
\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
+ = \int_{-\infty}^\infty {n o(t)^{n-1} o'(t) \over o(t)^n} dt
+ = n \int_{-\infty}^\infty {o'(t) \over o(t)} dt
= 2 \pi i n
\end{gather*}
$$
It is certainly possible to perform these contour integrals along straight lines
- in the complex plane; in fact, making *Γ* a diamond-shaped contour from
+ in the complex plane; in fact, making Γ a diamond-shaped contour from
1 to *i* to -1 to -*i* produces a similar 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.
-The integral can be shifted back into the realm of plausibility by considering simpler bounds on $o_2$:
+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
+ &= \int_{-1}^1 {2 o(t) o'(t) \over o(t)^2} dt
\\
- &= 2 \int_{-1}^1 {o_1'(t) \over o_1(t)} dt
+ &= 2 \int_{-1}^1 {o'(t) \over o(t)} dt
\\
&= 2(2i\arctan(1) - 2i\arctan(-1))
\\
@@ -309,7 +309,7 @@ This series converges for $-1 \le t \le 1$, which happens to match the bounds of
The convergence of this series is fairly important, since it is tied to formulas for π,
in particular [Leibniz's formula](https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80).
-Were one to integrate with the complex exponential, we would instead use the bounds $(0, 2\pi)$,
+Were one to integrate with the complex exponential, we would instead use the bounds $[0, 2\pi)$,
since at this point a full loop has been made.
But think to yourself -- how do you know the period of the complex exponential?
How do you know that 2π radians is equivalent to 0 radians?
@@ -361,7 +361,7 @@ $$
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)$.
+will plot a $p/1$ polar rose as t ranges over $[-\infty, \infty)$.
```{python}
#| echo: false
@@ -413,15 +413,15 @@ p/1 polar roses as rational curves.
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.
+$q = 1$ happens to match the subscript of a *c* term of *x* and the *s* term of *y*,
+ so one might wonder whether the other polar curves can be obtained by allowing it to vary.
And you'd be right.
$$
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)$.
+will plot a $p/q$ polar rose as t ranges over $[-\infty, \infty)$.
```{python}
#| echo: false
@@ -443,7 +443,7 @@ p/q polar roses as rational curves
:::
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.
+ 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.
@@ -522,9 +522,9 @@ $$
::::
*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
+Technically, it is missing the point where $y = 0 ~ (t = \infty)$.
+Unfortunately, this is not a circumstance where using a higher $c_n$ would help.
+It is however, similar to the situation where we allow $o(\infty) = -1$, and an argument
can be made to waive away any concerns one might have.
@@ -562,9 +562,9 @@ $$
:::
::::
-There isn't an obvious way to combine products of *x* and *y* into a single equation.
-The general form of a conic section is $Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$, so
- we know that the implicit equation for the curve almost certainly involves $x^2$ and $y^2$.
+There isn't an obvious way write *x* and *y* above as an implicit equation for the curve.
+The general form of a conic section is $Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$,
+ so we know that such an equation curve almost certainly involves $x^2$ and $y^2$.
$$
x^2 = {4 - 8t^2 + 4t^4 \over (3t^2 + 1)^2} \qquad
@@ -612,7 +612,7 @@ $$
$$
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}$.
+Simultaneously, $o(\varepsilon) = o(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.
@@ -621,7 +621,7 @@ This binds together three concepts: the simplest case of the Pythagorean theorem
#### 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
+Since $o(2)$ is a reflection of $o(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.
@@ -751,7 +751,7 @@ Approximations to the Archimedean spiral
:::
-Since R necessarily defines a rational curve, the curves will never be equal,
+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.
diff --git a/posts/math/stereo/3/anim.py b/posts/math/stereo/3/anim.py
new file mode 120000
index 0000000..ebbf6c3
--- /dev/null
+++ b/posts/math/stereo/3/anim.py
@@ -0,0 +1 @@
+../2/anim.py
\ No newline at end of file
diff --git a/posts/math/stereo/3/close_equatorial_sphere.mp4 b/posts/math/stereo/3/close_equatorial_sphere.mp4
new file mode 100644
index 0000000..40de28c
--- /dev/null
+++ b/posts/math/stereo/3/close_equatorial_sphere.mp4
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e9d48b55b35845692b3bf151527a8ec75966f9bb4102a48a5a30f11a49a14b8d
+size 118036
diff --git a/posts/math/stereo/3/index.qmd b/posts/math/stereo/3/index.qmd
index 85ec159..8bc7972 100644
--- a/posts/math/stereo/3/index.qmd
+++ b/posts/math/stereo/3/index.qmd
@@ -1,12 +1,12 @@
---
title: "Stereographic Hyperspheres"
description: |
- TODO
+ How do you explicitly describe *n*-dimensional spheres?
format:
html:
html-math-method: katex
jupyter: python3
-date: "2026-09-11"
+date: "2026-10-04"
categories:
- algebra
- topology
@@ -14,22 +14,43 @@ categories:
draft: true
---
+
-In [the first post of this series](../1/), we explored the application of the quaternions
- to rotation in three dimensions.
-Rotation is one problem, but the quaternions and the characterization of the sphere given
- correspond to another: how do we parameterize higher-dimensional spheres?
+```{python}
+#| echo: false
-It's relatively easy to describe spheres implicitly using coordinates.
-The natural definition is the locus of points which all have the same distance to the origin
- in Euclidean space.
-In other words, a point $(x_0, x_1, x_2, ... x_n)$ is on a unit hypersphere
- in *n*+1-dimensional space if
+import numpy as np
+import matplotlib.pyplot as plt
+import sympy
+import sympy.plotting as plot
+from sympy.abc import t
+
+from anim import SympyAnimationWrapper
+```
+
+In [the first post of this series](../1/), we explored a definition of quaternions
+ and their application to rotation in three dimensions.
+In doing so, we used stereography to define a point on the 2-sphere, i.e.,
+ one whose coordinates satisfy $x^2 + y^2 + z^2 = 1$.
+
+It's easy to extend this implicit equation to higher-dimensional spheres (or hyperspheres).
+A point $(x_0, x_1, x_2, ... x_n)$ is on a unit hypersphere in *n*+1-dimensional
+ Euclidean space if
$$
x_0^2 + x_1^2 + x_2^2 + ... + x_n^2 = 1
$$
+This follows naturally from the definition of the sphere as the locus of points which
+ all have the same distance to the origin.
+Since this has an implicit equation, there's a natural question: how do we parameterize hyperspheres?
+
Guidance from Lower Dimensions
------------------------------
@@ -54,6 +75,9 @@ o_2(s, t) = {1 + is + jt \over 1 - is - jt}
$$
These are valid constructions because division works for both complex numbers and quaternions.
+But the ability to divide
+ [isn't very common in higher dimensions](https://mathworld.wolfram.com/DivisionAlgebra.html),
+ so without justification, we can't extend it and hope the math works out.
### Topological Insights
@@ -100,13 +124,16 @@ In another sense, the real space is the extra dimension into which the sphere ex
Topologically, this description of the resulting space is called the
[one-point compactification](https://mathworld.wolfram.com/One-PointCompactification.html).
In other words, the circle is the one-point compactification of the line,
- and in general, an *n* sphere is the one-point compactification of Euclidean *n*-space.
+ and in general, an *n*-sphere is the one-point compactification of Euclidean *n*-space.
$$
\mathbb{E}^{n} \cup \{ \infty \} \cong S^n
$$
-![]()
+
### Invariance of Dimension
@@ -118,31 +145,32 @@ In fact, when constructing the 2-sphere, all we cared about was that *i* and *j*
[Geometric algebra](https://en.wikipedia.org/wiki/Geometric_algebra) gives some tools to generalize
this argument to higher dimensions.
-In an *n*-dimensional algebra, we have unit vectors $e_0, e_1, ..., e_{n-1}$
+In an *n*-dimensional algebra, we have unit vectors ${\vec e_0}, {\vec e_1}, ..., {\vec e_{n-1}}$
and the following properties:
- Scalars and vectors can be added and multiplied together,
and all possibilities comprise the algebra
- The product of a unit vector with itself is a scalar, generally chosen among -1, 0, or 1
- Scalars commute, but the product of two different unit vectors anticommutes
- - e.g., $e_0 e_1 = - e_1 e_0$
+ - e.g., ${\vec e_0} {\vec e_1} = - {\vec e_1} {\vec e_0}$
- Consequently, the square of the product is the negative of the product of the squares
- - e.g., $e_0 e_1 e_0 e_1 = - e_0 e_1 e_1 e_0 = - e_0^2 e_1^2$
+ - e.g., ${\vec e_0} {\vec e_1} {\vec e_0} {\vec e_1} = - {\vec e_0} {\vec e_1} {\vec e_1} {\vec e_0} = - {\vec e_0^2} {\vec e_1^2}$
- Division by anything other than scalars is undefined
-A consequence is that the square of a general vector ***v*** with components $x_k e_k$ is a scalar.
+A consequence is that the square of a general vector $\vec v$ with components
+ ${\vec e_k}x_k$ is a scalar.
This can be seen by arranging the components of the product after distributing as a square:
$$
\begin{align*}
- {\bm v} &= e_0 x_0 + e_1 x_1 + ... e_{n-1} x_{n-1} = \sum_k e_k x_k
+ {\vec v} &= {\vec e_0} x_0 + {\vec e_1} x_1 + ... {\vec e_{n-1}} x_{n-1} = \sum_k {\vec e_k} x_k
\\
- {\bm v}^2 &= (\sum_k^{n-1} e_k x_k) (\sum_l^{n-1} e_l x_l)
- = \sum_k^{n-1} \sum_l^{n-1} e_k e_l x_k x_l
+ {\vec v^2} &= (\sum_k^{n-1} {\vec e_k} x_k) (\sum_l^{n-1} {\vec e_l} x_l)
+ = \sum_k^{n-1} \sum_l^{n-1} {\vec e_k} {\vec e_l} x_k x_l
\\
- &= \underset{\diagdown}{\sum_k^{n-1} e_k^2 x_k^2}
- + \underset{◥}{ \sum_k^{n-1} \sum_{l > k} e_k e_l x_k x_l }
- + \underset{◣}{ \sum_k^{n-1} \sum_{l < k} e_k e_l x_k x_l }
+ &= \underset{\diagdown}{\sum_k^{n-1} {\vec e_k^2} x_k^2}
+ + \underset{◥}{ \sum_k^{n-1} \sum_{l > k} {\vec e_k} {\vec e_l} x_k x_l }
+ + \underset{◣}{ \sum_k^{n-1} \sum_{l < k} {\vec e_k} {\vec e_l} x_k x_l }
\end{align*}
$$
@@ -150,18 +178,18 @@ Due to anticommutativity, we can cancel the upper and lower triangles, leaving o
$$
\begin{align*}
- ◣ &= \sum_k^{n-1} \sum_{l < k} e_k e_l x_k x_l
- = \sum_k^{n-1} \sum_{k < l} e_l e_k x_l x_k
+ ◣ &= \sum_k^{n-1} \sum_{l < k} {\vec e_k} {\vec e_l} x_k x_l
+ = \sum_k^{n-1} \sum_{k < l} {\vec e_l} {\vec e_k} x_l x_k
\\
- &= - \sum_k^{n-1} \sum_{l > k} e_k e_l x_k x_l
+ &= - \sum_k^{n-1} \sum_{l > k} {\vec e_k} {\vec e_l} x_k x_l
= - ◥
\\[10pt]
&\implies \diagdown + ◥ + ◣ = \diagdown + ◥ - ◥ = \diagdown
\end{align*}
$$
-To align with the prior examples *i* and *j*, we'll assume that $e_k^2 = -1$ for all *k*.
-This means that ${\bm v}^2 = - ||{\bm v}||$, the sum of squares of the extent
+To align with the prior examples *i* and *j*, we'll assume that ${\vec e_k^2} = -1$ for all *k*.
+This means that ${\vec v}^2 = - ||{\vec v}||$, the sum of squares of the extent
in each basis (or Euclidean norm).
@@ -170,36 +198,37 @@ This means that ${\bm v}^2 = - ||{\bm v}||$, the sum of squares of the extent
Finally, we can consider an expression analogous to the one from which we derived
the 1- and 2-spheres.
-Suppose that a vector and a scalar are added together, as $a + {\bm v}$.
+Suppose that a vector and a scalar are added together, as $a + {\vec u}$.
If this point is on a sphere and the scalar component is considered the extent in a new dimension,
then the norm of the entire quantity should be
$$
-||a + {\bm v}|| = a^2 + ||{\bm v}|| = a^2 - {\bm v}^2 = 1
+||a + {\vec u}|| = a^2 + ||{\vec u}|| = a^2 - {\vec u}^2 = 1
$$
-As a vector ***u*** ranges over *n*-dimensional space, the expression...
+Now let a vector $\vec v$ range over *n*-dimensional space.
+The expression...
$$
-o_n({\bm u}) = {1 + {\bm u} \over 1 - {\bm u}}
+{\bm o_n}({\vec v}) = a + {\vec u} = {1 + {\vec v} \over 1 - {\vec v}}
$$
...seems to be a ratio between two distinct quantities with the same norm,
- since $1^2 - {\bm u}^2 = 1^2 - (-{\bm u})^2$.
-This expression is actually ill-defined since there is a vector in the denominator,
- but we can use a conjugation trick to clear it:
+ since $1^2 - {\vec v}^2 = 1^2 - (-{\vec v})^2$.
+However, it's ill-defined since there is a vector we can't divide by in the denominator.
+Due to the properties of the algebra, we can use a conjugation trick to clear it:
$$
\begin{align*}
- {1 + {\bm u} \over 1 - {\bm u}}
- &= \left( {1 + {\bm u} \over 1 - {\bm u}} \right)
- \left( {1 + {\bm u} \over 1 + {\bm u}} \right)
- = {(1 + {\bm u})^2 \over (1 - {\bm u})(1 + {\bm u})}
+ {1 + {\vec v} \over 1 - {\vec v}}
+ &= \left( {1 + {\vec v} \over 1 - {\vec v}} \right)
+ \left( {1 + {\vec v} \over 1 + {\vec v}} \right)
+ = {(1 + {\vec v})^2 \over (1 - {\vec v})(1 + {\vec v})}
\\
- &= {1 + 2{\bm u} + {\bm u}^2 \over 1 - {\bm u}^2}
+ &= {1 + 2{\vec v} + {\vec v}^2 \over 1 - {\vec v}^2}
\\
- &= {1 - ||{\bm u}|| \over 1 + ||{\bm u}||} + {2{\bm u} \over 1 + ||{\bm u}||}
- = a + {\bm v}
+ &= {1 - ||{\vec v}|| \over 1 + ||{\vec v}||} + {2{\vec v} \over 1 + ||{\vec v}||}
+ = a + {\vec u}
\end{align*}
$$
@@ -209,20 +238,20 @@ We can also show that the norm of this expression is 1, as desired:
$$
\begin{align*}
- a^2 - {\bm v}^2 &= 1
+ a^2 - {\vec v}^2 &= 1
\\
\implies
- \stackrel{\text{Numerator of } a}{(1 + {\bm u}^2)^2}
- - \stackrel{\text{Numerator of } \bm v}{(2{\bm u})^2}
- &= \stackrel{\text{Common denominator}}{1 - {\bm u}^2}
+ \stackrel{\text{Numerator of } a}{(1 + {\vec v}^2)^2}
+ - \stackrel{\text{Numerator of } \vec u}{(2{\vec v})^2}
+ &= \stackrel{\text{Common denominator}}{1 - {\vec v}^2}
\end{align*}
$$
-This is true no matter how many dimensions ***v*** has[^1], justifying our earlier abuse of notation.
+This is true no matter how many dimensions $\vec v$ has[^1], justifying our earlier abuse of notation.
[^1]: Technically, this should only hold for finitely many dimensions.
The $\infty$-sphere, composed of vectors with only finitely many nonzero components,
- is probably also valid under this construction, but I haven't proven this.
+ is probably also valid under this construction, but it warrants a proper proof.
Inducing an Alternative
@@ -243,100 +272,120 @@ This can (topologically) be turned into a 1-sphere $S^1$ (the circle) by an oper
all points in the space to two new, auxiliary points.
Subsequently, we can take the circle and repeat the operation to build the 2-sphere $S^2$.
+
+
In general,
$$
\text{Susp}(S^{n-1}) = S^n
$$
-![]()
+### Algebraic Suspension
-### Algebraic Dual, Part 2
-
-Let's look at the first interesting case.
-We first definied the circle, or 1-dimensional sphere as
+Let's compare the topological definition with what we have algebraically.
+We first definied the circle, or 1-sphere as
$$
o(t) = {1 + it \over 1 - it}
= {1 - t^2 \over 1 + t^2} + i{2t \over 1 + t^2}
$$
-If the real part remains fixed, then in most cases,
- the space looks two discrete points; to wit, a 0-dimensional sphere.
-The remaining two points 1 and -1 are in some sense "new" to the space.
-
-![]()
+Negating *t* keeps the real part the same, but negates the imaginary part.
+So in most cases, where there *is* an imaginary part,
+ the space looks two discrete points; to wit, a 0-sphere.
+The remaining two points 1 and -1 are the exception.
Similarly, when we intersect the 2-sphere with a plane along a line of latitude,
- the space looks like a 1-dimensional sphere except at two points, also 1 and -1.
+ the space looks like a 1-sphere except at the two poles, also 1 and -1.
-![]()
+
-If we create a 2D vector with components in the real and imaginary parts of *o*,
- we can immediately create an expression for the 2-sphere:
+Halfway between the two poles, at the equator, the scalar component is 0 and the sphere is a pure vector.
+For a general sphere, this happens when $||{\vec v}|| = 1$:
+
+$$
+{\bm o_n}({\vec v})
+= {1 - ||{\vec v}|| \over 1 + ||{\vec v}||}
++ {2{\vec v} \over 1 + ||{\vec v}||}
+= {1 - 1 \over 1 + 1} + {2 \over 1 + 1}{\vec v}
+= {\vec v}
+$$
+
+In general, this happens when $\vec v$ is a point on a unit sphere of one dimension lower.
+For the 2-sphere, this is a 1-sphere, which we can easily parametrize using *o*.
+Being a unit sphere, all points on it behave similarly to *i* in that their square is -1.
+Thus, we can construct an expression for the 2-sphere by replacing *i* with the vector in question.
$$
\begin{align*}
- {\bm w}_1(t) &= {1 - t^2 \over 1 + t^2} e_0 + {2t \over 1 + t^2} e_1
+ {\vec v} = {\vec w}_1(s)
+ &= {1 - s^2 \over 1 + s^2} e_0 + {2s \over 1 + s^2} e_1
\\[10pt]
- \varsigma_2(s,t) &= {1 + {\bm w}_1(t)s \over 1 - {\bm w}_1(t)s}
- = {1 - s^2 \over 1 + s^2} + {2s \over 1 + s^2} {\bm w}_1(t)
+ {\bm \varsigma}_2(s,t) &= {1 + {\vec w}_1(s)t \over 1 - {\vec w}_1(s)t}
+ = {1 - t^2 \over 1 + t^2} + {2t \over 1 + t^2} {\vec w}_1(s)
\end{align*}
$$
-Note that if *s* is exchanged with *-s*, then the scalar part remains the same,
- but the vector part, which corresponds to latitudinal circles, is negated.
-In effect, this means that if *s* is allowed to range over negative numbers,
- we will produce two duplicate circles.
+Just like with *o*, if *t* is replaced with *-t* in the above expression,
+ then the scalar part remains the same, but the vector part
+ (which corresponds to latitudinal circles) is negated.
+Since the circle is a connected space, we only need one of the two circles this generates,
+ and *s* must range over $[0, \infty]$.
+*s*, however, ranges over $[-\infty, \infty)$, since that's the domain of *o*.
This process can be continued indefinitely -- at each stage,
- $\varsigma_k$[^2] describes a *k*-dimensional unit sphere.
-It be converted to a pure vector ${\bm w}_k$ by multiplying the scalar component
- with a new unit vector $e_k$.
-In this form, ${\bm w}_k^2 = -1$ for any *k*-dimensional algebra[^3].
+ $\bm \varsigma_n$[^2] describes a *n*-dimensional unit sphere.
+It can be converted to a pure vector ${\vec w}_n$ by multiplying the scalar component
+ with a new unit vector $e_n$.
+In this form, ${\vec w}_n^2 = -1$ for any *n*-dimensional algebra[^3].
This provides an inductive construction parallel to the topological one.
-[^2]: For "σφαίρα", sphere. I'm using ς in hope that it'll be less prone to confusion with "o".
+[^2]: For "σφαίρα", sphere. I'm using ς rather than σ in hope that it's less prone to confusion with "o".
[^3]: This should sound familiar from the first post -- it matches the "unit quaternions".
$$
\begin{align*}
- {\bm w}_k(x_0, x_1, ..., x_{k-1})
- &= \text{Scalar}(\varsigma_k(x_0, x_1, ..., x_{k-1}))e_k
+ {\vec w}_n(x_0, x_1, ..., x_{n-1})
+ &= V({\bm \varsigma}_n(x_0, x_1, ..., x_{n-1}))
\\
- &+ \text{Vector}(\varsigma_k(x_0, x_1, ..., x_{k-1}))
+ &= \text{Scalar}({\bm \varsigma}_n)e_n + \text{Vector}({\bm \varsigma}_n)
\\
- \varsigma_{k+1}(x_0, x_1, ..., x_{k-1}, x_k)
- &= {1 + {\bm w}_k(x_0, x_1, ..., x_{k-1})x_k \over 1 - {\bm w}_k(x_0, x_1, ..., k_{k-1})x_k}
+ {\bm \varsigma}_{n+1}(x_0, x_1, ..., x_{n-1}, x_n)
+ &= {1 + {\vec w}_n(x_0, x_1, ..., x_{n-1})x_n \over 1 - {\vec w}_n(x_0, x_1, ..., n_{n-1})x_n}
+ \\
+ &= {1 - x_n^2 \over 1 + x_n^2} + {2x_n \over 1 + x_n^2}{\vec w_n}
\end{align*}
$$
-When the new parameter $x_k$ is 0 or $\infty$, the vector part collapses,
+When the new parameter $x_n$ is 0 or $\infty$, the vector part collapses,
and we get either 1 or -1, the "new points" of the suspension.
$$
\begin{align*}
- \varsigma_{k+1}(..., 0)
- &= {1 + {\bm w}_k(...)\cdot 0 \over 1 - {\bm w}_k(...) \cdot 0}
+ {\bm \varsigma}_{n+1}(..., 0)
+ &= {1 + {\vec w}_n(...)\cdot 0 \over 1 - {\vec w}_n(...) \cdot 0}
- {1 \over 1} = 1
\\
- \varsigma_{k+1}(..., \infty)
- &\approx {1 + {\bm w}_k(...)\cdot \infty \over 1 - {\bm w}_k(...) \cdot \infty}
+ {\bm \varsigma}_{n+1}(..., \infty)
+ &\approx {1 + {\vec w}_n(...)\cdot \infty \over 1 - {\vec w}_n(...) \cdot \infty}
\approx {\infty \over -\infty} \approx -1
\end{align*}
$$
-The phenomenon of duplicate latitudinal spheres is a recurring one in dimensions greater than 1.
-This can be seen from the 0-sphere being unique among spheres --
- as two discrete, disconnected points, negative numbers are needed for the expected duplication.
+All spheres but the 0-sphere are connected spaces, so duplicate latitudinal spheres
+ occur in all dimensions greater than 1.
+Only in dimension 1 are negative numbers required for the expected duplication.
More directly, this means that the parameter attached to the 1D case ($x_0$) ranges over
positive and negative numbers, but all others range over only positve numbers.
-:::{TODO}
-We could also construct $\bm w$ from the results in the previous section.
-:::
-
Multiple Wrappings
------------------
@@ -350,32 +399,34 @@ Starting with the scalar/vector form of the sphere, we can square the sphere and
$$
\begin{align*}
- o_n &= a + {\bm v}
+ {\bm o}_n &= a + {\vec u}
\\
- o_n^2 &= (a + {\bm v})^2 = a^2 + {\bm v}^2 + 2a{\bm v}
+ {\bm o}_n^2 &= (a + {\vec u})^2
\\
- &= a^2 + {\bm v}^2 + \textcolor{red}{(a^2 - {\bm v}^2 - 1 = 0)} + 2a{\bm v}
+ &= a^2 + {\vec u}^2 + 2a{\vec u} +\textcolor{red}{(0 = a^2 - {\vec u}^2 - 1)}
\\
- &= 2a^2 - 1 + 2a{\bm v} = 2a(a + {\bm v}) - 1 = 2a o_n - 1
+ &= 2a^2 - 1 + 2a{\vec u} = 2a(a + {\vec u}) - 1
+ \\
+ &= 2a {\bm o_n} - 1
\end{align*}
$$
This gives the familiar recurrence relation...
$$
-o_n^{m+2} = 2a o_n^{m+1} - o_n^m
+{\bm o}_n^{m+2} = 2a {\bm o}_n^{m+1} - {\bm o}_n^m
$$
-...and thus a sphere can be wrapped around itself any number of times, as given by:
+...and thus a sphere can be wrapped around itself any number of times, as given by
$$
-o_n^m = T_m(a) + U_{m-1}(a){\bm u}
+{\bm o}_n^m = T_m(a) + U_{m-1}(a){\vec u}
$$
-*T* and *U* are the standard Chebyshev polynomials.
+where *T* and *U* are the standard Chebyshev polynomials.
-### Negative Indices and Beyond
+### Negative Indices
The topological equivalent to this statement is
@@ -385,23 +436,24 @@ $$
More directly, a map from the *n*-sphere to itself can be characterized by an integer,
the *degree*, and these compose as integers add.
-Since this is an integer, there's the notion maps in an opposite direction
+
+Since this is an integer, there's the notion of maps in an opposite direction
which correspond to negative degrees.
-This seems to align with the behavior of the exponent in $o_n^m$.
+This seems to align with the behavior of the exponent *m* in ${\bm o}_n^m$.
However, we've only defined *m* over positive integers;
- after all, $o_n$ contains a vector, so we can't really divide by it.
+ after all, $\bm o_n$ contains a vector, so we can't really divide by it.
Fortunately, it's pretty easy to make sense of this.
-Since we have a recurrence relation for the powers of the sphere, we
+Since we have a recurrence relation for the powers of the *n*-sphere, we
can extend it backwards to define it over negative indices[^4].
$$
\begin{align*}
- o_n^1 &= 2a o_n^{0} - o_n^{-1}
+{\bm o}_n^1 &= 2a {\bm o}_n^{0} - {\bm o}_n^{-1}
\\
- a + {\bm v} &= 2a - o_n^{-1}
+ a + {\vec u} &= 2a - {\bm o}_n^{-1}
\\
- o_n^{-1} &= a - {\bm v}
+ {\bm o}_n^{-1} &= a - {\vec u}
\end{align*}
$$
@@ -414,84 +466,144 @@ $$
This actually aligns with what we'd expect according to adding powers, since:
$$
-o_n^1 \cdot o_n^{-1} = (a + {\bm v})(a - {\bm v}) = a^2 - {\bm v}^2 = 1 = o_n^0
+({\bm o}_n^1)({\bm o}_n^{-1})
+= (a + {\vec u})(a - {\vec u}) = a^2 - {\vec u}^2
+= 1 = {\bm o}_n^0
$$
### Degrees and Induction
-In the inductive case, since ${\bm w}^2 = -1$, we can pull a similar trick.
-Replacing *i* with ***w***, the only thing that needs changing from the previous article is
- replacing "real" with "scalar" and "nonreal" with "vector".
+The inductive case was established by noticing that a vector $\vec w$ lying on a unit sphere
+ behaves similarly to *i* in that that ${\vec w}^2 = -1$.
+We can use the same trick for higher-order wrappings -- the only thing that needs changing
+ from the previous article is replacing "real" with "scalar" and "nonreal" with "vector".
$$
-\varsigma_n^m
-= ( c + s \cdot { {\bm w}_{n-1}} )^m
-= T_m(c) + s U_m(c) \cdot {\bm w}_{n-1}
+{\bm \varsigma}_n^m
+= ( c + s { {\vec w}_{n-1}} )^m
+= T_m(c) + s U_m(c) {\vec w}_{n-1}
$$
Similarly,
$$
\begin{align*}
-\varsigma_n^{-1} &= ( c - s \cdot { {\bm w}_{n-1}} )
+{\bm \varsigma}_n^{-1} &= ( c - s{\vec w}_{n-1} )
\\
-\varsigma_n^{1} \cdot \varsigma_n^{-1}
- &= ( c + s \cdot {{\bm w}_{n-1}} )( c - s \cdot {{\bm w}_{n-1}} )
+({\bm \varsigma}_n^{1}) ({\bm \varsigma}_n^{-1})
+ &= ( c + s{\vec w}_{n-1} )( c - s{\vec w}_{n-1} )
\\
- &= c^2 - s^2 {\bm w}_{n-1}^2 = c^2 + s^2
+ &= c^2 - s^2 {\vec w}_{n-1}^2 = c^2 + s^2 = 1
\\
- &= 1 = \varsigma_n^0
+ &= {\bm \varsigma}_n^0
\end{align*}
$$
+Technically, $\bm \varsigma_n$ is already a higher-degree map when all parameters
+ (besides the one from the base case) are allowed to range over negative numbers.
+In this case, $\bm \varsigma_2^\pm$ is a degree-2 map, $\bm \varsigma_3^\pm$ is a degree-4 map,
+ and $\bm \varsigma_n^\pm$ is a degree-$2^{n-1}$ map.
-Degree 2 and the Equator
-------------------------
-The prior discussion about degree gives us the tools to address "points at infinity".
-As a reminder, if we let a vector ***u*** range over the entirety of Euclidean space,
- the sphere is only closed by allowing such an extra point.
+De-infinitizing
+---------------
-We can get rid of this point for the circle by considering a degree 2 map rather than a degree 1 map.
-The former wraps around once $-\infty$ to $\infty$, while the latter wraps around once from -1 to 1.
-Conveniently, -1 and 1 are both the points at which the real part of the degree 1 map becomes 0.
-Points in this range lie on the semicircle bounded by these two points (which form a 0-sphere).
-
-![]()
-
-For higher-dimensional spheres we just need to replace "real part" with "scalar part".
-For a sphere $o_n({\bm u}_n)$, this is precisely when ${\bm u}_n$ has a norm of 1.
+The degree also gives us the tools to address "points at infinity".
+If $\vec w_n$ is a point on the equatorial unit *n-1*-sphere, then $\bm o_n$
+ behaves as the identity.
+But we also know that it squares to -1, and that squaring $\bm o_n$ produces a degree-2 map.
$$
-o_n({\bm u}_n)
-= {1 - ||{\bm u_n}|| \over 1 + ||{\bm u_n}||}
-+ {2{\bm u_n} \over 1 + ||{\bm u_n}||}
-= {1 - 1 \over 1 + 1} + {2 \over 1 + 1}{\bm u_n}
-= {\bm u}_n
+{\bm o}_n({\vec w}_n)^2 = {\vec w}_n^2 = -1
$$
-Let *n* = 2 so we can plot it.
-Then we're actually talking about place in which the unit sphere in 3D space looks like the unit circle.
-Specifically, this unit circle can be considered an equator bounding the hemisphere around the scalar 1.
+This means that the degree-2 map can be interpreted as collapsing the equator
+ to a single point, the pole -1.
+The hemi-*n*-sphere surrounding the antipode 1 gets closed, resulting in the whole *n*-sphere.
-![]()
+```{python}
+#| code-fold: true
+#| output: false
-In general ${\bm u}_n$ has a norm of 1 exactly when it's a point on the equatorial *n-1*-sphere.
-Conveniently, under the degree 2 map, this equatorial sphere collapses to a single point.
+# circle map
+s,t = sympy.symbols("s t", real=True)
+o = (1 + sympy.I*s) / (1 - sympy.I*s)
-$$
-o_n({\bm u}_n)^2
-= {\bm u}_n^2 = -1
-$$
+# doubled map for finite range
+o2 = o**2
+o2_real, o2_imag = o2.as_real_imag()
-This point was formerly the image of the point at infinity,
- eliminating its necessity in the description of the *n*-sphere.
+# inductive 2-sphere
+sphere_x = o2_real.subs(s,t)
+sphere_y = o2_imag.subs(s,t)*o2_real
+sphere_z = o2_imag.subs(s,t)*o2_imag
+
+def animate_sphere(filename: str, n=30, interval=80):
+ lerp_steps = np.linspace(0, 1, n)
+ t_hemisphere = 2**0.5 - 1
+
+ with SympyAnimationWrapper(filename) as animate:
+ @animate(len(lerp_steps), interval=interval)
+ def ret(fr):
+ plt.clf()
+ lerp = lerp_steps[fr]
+
+ t_upper = t_hemisphere*(1 - lerp) + 1*lerp
+ p = plot.plot3d_parametric_surface(
+ sphere_x, sphere_y, sphere_z,
+ (s, -1, 1), (t, 0, t_upper),
+ xlim=(-1,1), ylim=(-1,1), zlim=(-1,1),
+ show=False,
+ backend="matplotlib",
+ )
+ p2 = plot.plot3d_parametric_line(
+ sphere_x.subs(t, t_upper), sphere_y.subs(t, t_upper), sphere_z.subs(t, t_upper),
+ (s, -1, 1),
+ show=False,
+ backend="matplotlib",
+ )
+ p.append(p2[0])
+ p.show()
+
+ ret.save() # type: ignore
+
+animate_sphere("close_equatorial_sphere.mp4")
+```
+
+::: {#fig-hemisphere-closure}
+{{< video "./close_equatorial_sphere.mp4" >}}
+
+Effect of the degree-2 map on the hemisphere containing the scalar 1.
+:::
+
+In the one-point construction, this region can only be described using all components of the input vector,
+ since the scalar component depends on it.
+Thus, the domain is made finite just by squaring ***o***.
+
+However, in the inductive construction, the scalar component only depends on
+ the new free parameter, leaving the domain of lower-dimensional spheres unaffected,
+ and potentially still unbounded.
+
+The layered nature of the inductive construction means there are different "levels"
+ at which wraps can be placed.
+For example, for the 2-sphere, the smallest domain for which the entire sphere is parametrized
+ is shown in the table below:
+
+| Sphere | Domain for first wrap around the sphere |
+|----------------------------------------|----------------------------------------------------|
+| ${\bm o}_2^2({\vec e_0} s + {\vec e_1} t)$ | $s^2 + t^2 \le 1$ |
+| ${\bm \varsigma}_2^2({\bm \varsigma}_1(s),t)$ | $s \in [-\infty, \infty] \quad t \in [0, 1)$ |
+| ${\bm \varsigma}_2({\bm \varsigma}_1^2(s),t)$ | $s \in [-1, 1] \quad t \in [0, \infty]$ |
+| ${\bm \varsigma}_2^2({\bm \varsigma}_1^2(s),t)$ | $s \in [-1, 1] \quad t \in [0, 1]$ |
+
+A finite domain is only achieved in the final case, corresponding to the combination of
+ two separate degree-2 maps (i.e., a degree-4 map).
-### Closing the Sphere
+### Closing the Disc
-Of course, this comes with another topological analogue.
+Of course, the behavior of the equator comes with another topological analogue.
Another description of the *n*-sphere is by taking the boundary of an *n*-dimensional disc
and collapsing its boundary to a single point.
@@ -499,21 +611,40 @@ $$
{ D^n / \partial D^n } = S^n
$$
-This exactly aligns with the behavior of the equator when going from the degree 1 to the degree 2 map.
-If ${\bm u}_n$ has a norm of less than or equal to 1, then it lies within a unit disc.
-This unit disc gets sent by $o_n$ to the aforementioned "hemisphere around the scalar 1",
- and when fed to $o_n^2$, it produces the *n*-sphere.
+This exactly aligns with the behavior of the equator when going from the degree-1 to the degree-2 map.
+If ${\vec u}_n$ has a norm of less than or equal to 1, then it lies within a unit disc.
+This unit disc gets sent by $\bm o_n$ to the aforementioned "hemisphere around the scalar 1",
+ and when fed to $\bm o_n^2$, it produces the *n*-sphere.
Closing
-------
-There are a couple of things that I still want to explore here.
-One is the composition of one-point spheres and inductive spheres.
-This structure should describe an (unbounded) lattice, where every "one-point" parametrization
- has no lesser element, but has a greater element as an element in an inductive parametrization.
-Parametrizations should be considered the same up to a symmetric transformation of coordinates.
+There's still a lot worth discussing here.
-There's also a lot of interesting topological arguments to nail down.
-One of these is the degree of the antipodal map.
-Another is constructing explicit homotopies purely from algebra.
+For spheres themselves, one-point spheres provide an base-case in any dimension
+ for inductive spheres.
+This, combined with the choice of degree at each level of induction,
+ grants the potential for many interesting descriptions,
+ which get more numerous in higher dimensions.
+For example, while there's only one degree-4 map for the 1-sphere,
+ there are four for the 2-sphere (depending on choice of bounds).
+
+For topology, I find that these constructions do a lot to nail down its typically abstract nature.
+There are still a lot of interesting arguments to nail down,
+ such as the degree of the antipodal map, or describing explicit, purely algebraic homotopies.
+
+Finally there's the geometric algebra itself.
+Choosing anything but vectors with the expected properties results in surfaces other than spheres.
+This can get even more complicated when considering product of vectors as non-scalar components
+ of the "sphere".
+It's difficult to imagine what these look like in higher dimensions, or what interesting
+ propositions they connect to.
+
+The most convenient part of these constructions is the complexity they manage.
+The alternative is attempting to come up with complicated polynomials
+ in way too many variables to keep track of individually,
+ all while managing equalities between them.
+Instead, algebra serves algebra while also significantly benefitting geometry and topology.
+
+Diagrams created with Geogebra, Sympy and Matplotlib.
diff --git a/posts/math/stereo/3/one-point_compactification.png b/posts/math/stereo/3/one-point_compactification.png
new file mode 100644
index 0000000..9cf8ab3
--- /dev/null
+++ b/posts/math/stereo/3/one-point_compactification.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:50ed005237da4bb32c6d60af17d61fe48ee0804038a85edd9f7518f6ea18aed4
+size 47211
diff --git a/posts/math/stereo/3/parametrized_suspension.png b/posts/math/stereo/3/parametrized_suspension.png
new file mode 100644
index 0000000..68018e5
--- /dev/null
+++ b/posts/math/stereo/3/parametrized_suspension.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b676005b80cde7a315d613ccfd3da4070cceb1fd3f0f51454dba78897634ecd7
+size 64711
diff --git a/posts/math/stereo/3/suspension.png b/posts/math/stereo/3/suspension.png
new file mode 100644
index 0000000..a34a7bf
--- /dev/null
+++ b/posts/math/stereo/3/suspension.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9d1dce67e9ee7928d7662c5ecc273e04ff8b929a70eb5ff8b725bf141f307d11
+size 46602