diff --git a/posts/stereo/1/index.qmd b/posts/stereo/1/index.qmd index bdeaecc..7e00740 100644 --- a/posts/stereo/1/index.qmd +++ b/posts/stereo/1/index.qmd @@ -24,6 +24,7 @@ categories: ```{python} #| echo: false +from IPython.display import display, Code import sympy from sympy.abc import t ``` @@ -200,7 +201,7 @@ This action of squaring *z* means that as *t* ranges from $-\infty$ to $\infty$, Let's go on a brief tangent and compare these expressions to their transcendental trigonometric counterparts. Graphing the real and imaginary parts separately shows how much they resemble - $\cos(\pi t)$ and $\sin(\pi t)$ around 0[^1]. + $\cos(\pi t)$ and $\sin(\pi t)$ around zero[^1]. [^1]: An approximation of a function as the ratio of two polynomials is called a [Padé approximant](https://en.wikipedia.org/wiki/Pad%C3%A9_approximant). @@ -376,28 +377,21 @@ A best-case analysis of the above approximation, given some value *t* is... ...or 15 FLOPs. On a more optimistic note, a Monte Carlo test of the above approximation on my computer yields - promising results when compared with GCC's `libm` implementations of `sin` and `cos` - (also tested with `cexp`). + promising results when compared with GCC's `libm` implementations of `sin`, `cos`, and `cexp`. -```{} -Timing for 100000 math.h sin and cos: 5409619ns -Timing for 100000 approximations: 2408645ns -Approximation faster, speedup: 3000974ns (2.25x) -Squared error in cosines: - Average: 0.000051 (0.713743% error) - Largest: 0.000174 (1.320551% error) - Input: 0.729202 - Value: -0.659428 - Approximation: -0.672634 -Squared error in sines: - Average: 0.000070 (0.835334% error) - Largest: 0.000288 (1.698413% error) - Input: 0.729202 - Value: 0.475669 - Approximation: 0.458685 +```{python} +#| echo: false + +for file in [ + "approx-results/results_math.txt", + "approx-results/results_complex.txt", +]: + with open(file) as a: + display(Code(a.read())) ``` -For the source which I used to generate this output, see the repository linked below. +For the source which I used to generate this output, see the repository linked at the bottom + of this article. Even though results can be inaccurate, this exercise in the algebraic manipulation of complex numbers is fairly interesting since it requires no calculus to define, @@ -453,6 +447,7 @@ $$ These are exactly the same expressions which appear in the real and imaginary components of the ratio between $1 + ti$ and its conjugate. + Compared to the algebra using complex numbers, this is quite a bit more work. One might ask whether, given a proper arithmetic setting, this can be extended to three dimensions. In other words, we want to find the projection of a sphere using some new number system @@ -535,7 +530,7 @@ If you know a little group theory, you might know there are only two nonabelian dihedral group of degree 4 ](https://en.wikipedia.org/wiki/Examples_of_groups#dihedral_group_of_order_8). -In the latter group, *j* and *k* are both imaginary, but square to 1 (*i* still squares to -1)[^4] . +In the latter group, *j* and *k* are both imaginary, but square to 1 (*i* still squares to -1)[^4]. [^4]: I'm being a bit careless with the meanings of "1" and "-1" here. Properly, these are the group identity and another group element which commutes with all others. @@ -707,5 +702,6 @@ However, I feel like it fails to provide an algebraic motivation for quaternions or even stereography in the first place. Hopefully, my remarks on the algebraic approach can be used to augment the information in the video. + Diagrams created with GeoGebra and Matplotlib. Repository with approximations (as well as GeoGebra files) available [here](https://github.com/queue-miscreant/approx-trig).