## Inscribed Triangle in circle problem

In the LinkedIn Pre-University Geometric Algebra group, James presents a problem from the MindYourDecisions youtube channel Impossible Viral Problem, as a candidate for solution using geometric algebra.

I tried this out and found a couple ways to solve it. One of those I’ll detail here. I have to admit that part of the reason that I wanted to solve this is that the figure in the beginning of the video really bugged me. The triangle that was inscribed in the circle didn’t have any of the length properties from the problem. I could do much better with a sloppy freehand sketch, but to do a good figure, you have to actually solve for the vertexes of the triangle (once you do that, the area is easy to figure out.)

## Formulating the problem.

Having solved the problem, the geometry of the problem is illustrated in fig. 1.

fig. 1. Inscribed triangle in circle.

I set up the problem so that the $$A,C$$ triangle vertices were symmetric with respect to the x-axis, and the $$B$$ vertex located elsewhere. I can describe those algebraically as
\label{eqn:inscribedTriangleProblem:20}
\begin{aligned}
\BA &= r \Be_1 e^{i\theta} \\
\BC &= r \Be_1 e^{-i\theta} \\
\BB &= r \Be_1 e^{i\phi},
\end{aligned}

where the radius $$r$$ and two angles $$\theta, \phi$$ are to be determined, and $$i = \Be_1 \Be_1$$ the pseudoscalar for the $$x-y$$ plane.
The vector pointing to the midpoint of the upper triangular face is given by the average of the $$\BA, \BB$$ vectors, which can be seen from
\label{eqn:inscribedTriangleProblem:40}
\BA + \frac{\BB – \BA}{2} = \frac{\BA + \BB}{2},

and similarly, the midpoint of the lower face is found at
\label{eqn:inscribedTriangleProblem:60}
\BC + \frac{\BB – \BC}{2} = \frac{\BB + \BC}{2},

The problem tells us that the respective lengths of those vectors from the origin are $$r-2, r – 3$$ respectively, so
\label{eqn:inscribedTriangleProblem:80}
\begin{aligned}
r – 2 &= \inv{2} \Abs{ \BA + \BB } \\
r – 3 &= \inv{2} \Abs{ \BB + \BC },
\end{aligned}

or
\label{eqn:inscribedTriangleProblem:100}
\begin{aligned}
(r – 2)^2 &= \frac{r^2}{4} \lr{ \Be_1 e^{i\theta} + \Be_1 e^{i\phi} }^2 \\
(r – 3)^2 &= \frac{r^2}{4} \lr{ \Be_1 e^{i\phi} + \Be_1 e^{-i\theta} }^2 \\
\end{aligned}

Finally, since the midpoint of the right edge is found at $$(r-1)\Be_1$$, it is clear that
\label{eqn:inscribedTriangleProblem:120}
\frac{r-1}{r} = \cos\theta,

or
\label{eqn:inscribedTriangleProblem:140}
r = \inv{1 – \cos\theta}.

This leaves us with three equations and three unknowns. Unfortunately, these are rather non-linear equations. In the video, a direct method of solving equivalent equations was demonstrated, but I picked the lazy route, and used Mathematica’s NSolve routine, solving for $$r,\theta, \phi$$ numerically. Since NSolve has intrinsic complex number support, I made the following substitutions:
\label{eqn:inscribedTriangleProblem:160}
\begin{aligned}
z &= e^{i\theta} \\
w &= e^{i\phi},
\end{aligned}

and then plugged those into our relations above, after expanding the squares, to find
\label{eqn:inscribedTriangleProblem:180}
\begin{aligned}
\lr{ \Be_1 e^{i\theta} + \Be_1 e^{i\phi} }^2
&=
2 + \Be_1 e^{i\theta} \Be_1 e^{i\phi} + \Be_1 e^{i\phi} \Be_1 e^{i\theta} \\
&=
2 + e^{-i\theta} \Be_1^2 e^{i\phi} + e^{-i\phi} \Be_1^2 e^{i\theta} \\
&=
2 + e^{-i\theta} \Be_1^2 e^{i\phi} + e^{-i\phi} \Be_1^2 e^{i\theta} \\
&=
2 + \frac{w}{z} + \frac{z}{w},
\end{aligned}

and
\label{eqn:inscribedTriangleProblem:200}
\begin{aligned}
\lr{ \Be_1 e^{i\phi} + \Be_1 e^{-i\theta} }^2
&=
2 + \Be_1 e^{i\phi} \Be_1 e^{-i\theta} + \Be_1 e^{-i\theta} \Be_1 e^{i\phi} \\
&=
2 + e^{-i\phi} e^{-i\theta} + e^{ i\theta} e^{i\phi} \\
&=
2 + w z + \inv{w z}.
\end{aligned}

This gives us
\label{eqn:inscribedTriangleProblem:220}
\begin{aligned}
4 \lr{ \frac{r – 2 }{r} }^2 &= 2 + \frac{w}{z} + \frac{z}{w} \\
4 \lr{ \frac{r – 3 }{r} }^2 &= 2 + w z + \inv{w z},
\end{aligned}

where
\label{eqn:inscribedTriangleProblem:240}
r = \inv{1 – \inv{2}\lr{ z + \inv{z}}}.

The NSolve gave me some garbage solutions (like $$\theta = 0$$) that must have been valid numerically, but did not encode the geometry of the problem, so I added a few additional constraints to the problem, namely
\label{eqn:inscribedTriangleProblem:260}
\begin{aligned}
z \bar{z} &= 1 \\
w \bar{w} &= 1 \\
\inv{2} \lr{ z + \inv{z} } &\ne 1 \\
1/(1 – (1/2) \textrm{Re}(z + 1/z)) &> 3.
\end{aligned}

This provided exactly two solutions, but when plotted, they turn out to just be mirror images of each other. After back substitution, the solution illustrated above was given by
\label{eqn:inscribedTriangleProblem:280}
\begin{aligned}
r &= 3.87939 \\
\theta &= 42.078 \\
\phi &= 164.125,
\end{aligned}

where these angles are in degrees, not radians.

## The triangular area.

There are probably lots of formulas for the area of a triangle (that I have forgotten), but we can compute it easily by doubling the triangle, forming a parallelogram, to find
\label{eqn:inscribedTriangleProblem:300}
\textrm{Area} = \inv{2} \Abs{ \lr{ \BA – \BC } \wedge {\BC – \BB } },

or
\label{eqn:inscribedTriangleProblem:320}
\begin{aligned}
\textrm{Area}^2
&= \frac{-1}{4} \lr{ \lr{ \BA – \BC } \wedge \lr{\BC – \BB } }^2 \\
&= \frac{-1}{4} \lr{ \BA \wedge \BC – \BA \wedge \BB + \BC \wedge \BB }^2 \\
&= \frac{-r^4}{4} \lr{\gpgradetwo{ \Be_1 e^{i\theta} \Be_1 e^{-i\theta} – \Be_1 e^{i\theta} \Be_1 e^{i\phi} + \Be_1 e^{-i\theta} \Be_1 e^{i\phi} }}^2 \\
&= \frac{-r^4}{4} \lr{\gpgradetwo{ e^{-2 i \theta} – e^{i \phi -i\theta} + e^{i\theta + i \phi} }}^2,
\end{aligned}

so
\label{eqn:inscribedTriangleProblem:340}
\textrm{Area} = \frac{r^2}{2} \Abs{ -\sin( 2 \theta ) – \sin(\phi- \theta) + \sin(\theta + \phi)}.

Plugging in $$r, \theta, \phi$$, we find
\label{eqn:inscribedTriangleProblem:360}
\textrm{Area} = 17.1866.

After computing this value, I then finally watched the original video to compare my answer, and was initially disturbed to find that this wasn’t even one of the possible values. However, that was because the problem itself, as originally stated, didn’t include the correct answer, and my worry that I’d made a mistake was unfounded, as the value I computed matched what was computed in the video (it also looks “about right” visually.)

## A minimally configured Windows laptop

November 22, 2020 Windows , , , , , ,

I’ve now installed enough that my new Windows machine is minimally functional (LaTex, Linux, and Mathematica), with enough installed that I can compile any of my latex based books, or standalone content for blog posts.  My list of installed extras includes:

• Brother HL-2170W (printer driver)
• Windows Terminal
• GPL Ghostscript (for MaTeX, latex labels in Mathematica figures.)
• Wolfram Mathematica
• Firefox
• Chrome
• Visual Studio
• Python
• Julia
• Discord
• OBS Studio
• MikTeX
• SumatraPDF
• GVim
• Git
• PowerShell (7)
• Ubuntu
• Dropbox

Some notes:

• On Windows, for my LaTeX work, I used to use MikTex + cygwin.  The cygwin dependency was for my makefile dependencies (gnu-make+perl).  With this new machine, I tried WSL2.  I’m running my bash shells within the new Windows Terminal, which is far superior to the old cmd.
• Putty is no longer required.  Windows Terminal does the job very nicely.  It does terminal emulation well enough that I can even ssh into a Linux machine and use screen within my Linux session, and my .screenrc just works.  Very nice.
• SumatraPDF is for latex reverse tex lookup.  i.e. I can double click on pdf content, and up pops the editor with the latex file.  Last time I used Sumatra, I had to configure it to use GVim (notepad used to be the default I think.)  Now it seems to be the default (to my suprise.)
• I will probably uninstall Git, as it seems superfluous given all the repos I want to access are cloned within my bash file system.
• I used to use GVim extensively on Windows, but most of my editing has been in vim in the bash shell.  I expect I’ll now only use it for reverse tex (–synctex) lookup editing.

WSL2 has very impressive integration.  A really nice demo of that was access of synctex lookup.  Here’s a screenshot that shows it in action:

I invoked the windows pdf viewer within a bash shell in the Ubuntu VM, using the following:


pjoot@DESKTOP-6J7L1NS:~/project/blogit$alias pdfview alias pdfview='/mnt/c/Users/peete/AppData/Local/SumatraPDF/SumatraPDF.exe' pjoot@DESKTOP-6J7L1NS:~/project/blogit$ pdfview fibonacci.pdf


The Ubuntu filesystem directory has the fibonacci.synctex.gz reverse lookup index that Summatra is able to read. Note that this file, after unzipping, has only Linux paths (/home/pjoot/…), but Summatra is able to use those without any trouble, and pops up the (Windows executable) editor on the files after I double click on the file. This sequence is pretty convoluted:

• Linux bash ->
• invoke Windows pdf viewer ->
• that program reading Linux files ->
• it invokes a windows editor (presumably using the Linux path), and that editor magically knows the path to the Linux file that it has to edit.

### C64 Nostalgia.

Incidentally, does anybody else still have their 6402 assembly programming references?  I’ve kept mine all these years, moving them around house to house, and taking a peek in them every few years, but I really ought to toss them!  I’m sure I couldn’t even give them away.

### Windows vs. MacOS

It’s been 4 years since I’ve actively used a Windows machine, and will have to relearn enough to get comfortable with it again (after suffering with the transition to MacOS and finally getting comfortable with it).  However, there are some new developments that I’m gung-ho to try, in particular, the new:

With WSL, I wonder if cygwin is even still a must have?  With windows terminal, I’m guessing that putty is a thing of the past (good riddance to cmd, that piece of crap.)

## Crashing Mathematica with HatchShading + Opacity

May 31, 2020 math and physics play , , ,

I attempted to modify a plot for an electric field solution that I had in my old Antenna-Theory notes:
\BE
=
j \omega
\frac{\mu_0 I_{\textrm{eo}} l}{4 \pi r} e^{-j k r}
\lr{ 1 + \cos\theta }
\lr{
-\cos\phi \thetacap
+ \sin\phi \phicap
},

and discovered that you can crash Mathematica (12.1.0.0) by combining PlotStyle with Opacity and HatchShading (new in 12.1).  Here’s a stripped down version of the plot code that demonstrates the crash:

ClearAll[ rcap]
rcap = {Sin[#1] Cos[#2], Sin[#1] Sin[#2], Cos[#1]} & ;

{
ParametricPlot3D[
rcap[t, p]
, {t, 0, π}
, {p, 0, 2 π}
, PlotStyle -> { HatchShading[0.5, Black]}
]
, ParametricPlot3D[
rcap[t, p]
, {t, 0, π}
, {p, 0, 2 π}
, PlotStyle -> {Directive[Opacity[0.5]]}
], ParametricPlot3D[
rcap[t,p]
,{t,0,π}
,{p,0,2 π}
Black]}
]
}

The first two plots, using one, but not both of, Opacity or HatchShading work fine:

In this reproducer, the little dimple at the base has been removed, which was the reason for the Opacity.

I’ve reported the bug to Wolfram, but wonder if they are going to come back to me saying, “Well, don’t do that!”

EDIT: Fixed in Mathematica 12.1.1

## Exploring 0^0, x^x, and z^z.

My Youtube home page knows that I’m geeky enough to watch math videos.  Today it suggested Eddie Woo’s video about $$0^0$$.

Mr Woo, who has great enthusiasm, and must be an awesome teacher to have in person.  He reminds his class about the exponent laws, which allow for an interpretation that $$0^0$$ would be equal to 1.  He points out that $$0^n = 0$$ for any positive integer, which admits a second contradictory value for $$0^0$$, if this was true for $$n=0$$ too.

When reviewing the exponent laws Woo points out that the exponent law for subtraction $$a^{n-n}$$ requires $$a$$ to be non-zero.  Given that restriction, we really ought to have no expectation that $$0^{n-n} = 1$$.

To attempt to determine a reasonable value for this question, resolving the two contradictory possibilities, neither of which we actually have any reason to assume are valid possibilities, he asks the class to perform a proof by calculator, computing a limit table for $$x \rightarrow 0+$$. I stopped at that point and tried it by myself, constructing such a table in Mathematica. Here is what I used

griddisp[labelc1_, labelc2_, f_, values_] := Grid[({
({{labelc1}, values}) // Flatten,
({ {labelc2}, f[#] & /@ values} ) // Flatten
}) // Transpose,
Frame -> All]
decimalFractions[n_] := ((10^(-#)) & /@ Range[n])
With[{m = 10}, griddisp[x, x^x, #^# &, N[decimalFractions[m], 10]]]
With[{m = 10}, griddisp[x, x^x, #^# &, -N[decimalFractions[m], 10]]]


Observe that I calculated the limits from both above and below. The results are

and for the negative limit

Sure enough, from both below and above, we see numerically that $$\lim_{\epsilon\rightarrow 0} \epsilon^\epsilon = 1$$, as if the exponent law argument for $$0^0 = 1$$ was actually valid.  We see that this limit appears to be valid despite the fact that $$x^x$$ can be complex valued — that is ignoring the fact that a rigorous limit argument should be valid for any path neighbourhood of $$x = 0$$ and not just along two specific (real valued) paths.

Let’s get a better idea where the imaginary component of $$(-x)^{-x}$$ comes from.  To do so, consider $$f(z) = z^z$$ for complex values of $$z$$ where $$z = r e^{i \theta}$$. The logarithm of such a beast is

\label{eqn:xtox:20}
\begin{aligned}
\ln z^z
&= z \ln \lr{ r e^{i\theta} } \\
&= z \ln r + i \theta z \\
&= e^{i\theta} \ln r^r + i \theta z \\
&= \lr{ \cos\theta + i \sin\theta } \ln r^r + i r \theta \lr{ \cos\theta + i \sin\theta } \\
&= \cos\theta \ln r^r – r \theta \sin\theta
+ i r \lr{ \sin\theta \ln r + \theta \cos\theta },
\end{aligned}

so
\label{eqn:xtox:40}
z^z =
e^{ r \lr{ \cos\theta \ln r – \theta \sin\theta}} \times
e^{i r \lr{ \sin\theta \ln r + \theta \cos\theta }}.

In particular, picking the $$\theta = \pi$$ branch, we have, for any $$x > 0$$
\label{eqn:xtox:60}
(-x)^{-x} = e^{-x \ln x – i x \pi } = \frac{e^{ – i x \pi }}{x^x}.

Let’s get some visual appreciation for this interesting $$z^z$$ beastie, first plotting it for real values of $$z$$


Manipulate[
Plot[ {Re[x^x], Im[x^x]}, {x, -r, r}
, PlotRange -> {{-r, r}, {-r^r, r^r}}
, PlotLegends -> {Re[x^x], Im[x^x]}
], {{r, 2.25}, 0.0000001, 10}]


From this display, we see that the imaginary part of $$x^x$$ is zero for integer values of $$x$$.  That’s easy enough to verify explicitly: $$(-1)^{-1} = -1, (-2)^{-2} = 1/4, (-3)^{-3} = -1/27, \cdots$$.

The newest version of Mathematica has a few nice new complex number visualization options.  Here’s two that I found illuminating, an absolute value plot that highlights the poles and zeros, also showing some of the phase action:

Manipulate[
ComplexPlot[ x^x, {x, s (-1 – I), s (1 + I)},
PlotLegends -> Automatic, ColorFunction -> "GlobalAbs"], {{s, 4},
0.00001, 10}]

We see the branch cut nicely, the tendency to zero in the left half plane, as well as some of the phase periodicity in the regions that are in the intermediate regions between the zeros and the poles.  We can also plot just the phase, which shows its interesting periodic nature


Manipulate[
ComplexPlot[ x^x, {x, s (-1 – I), s (1 + I)},
PlotLegends -> Automatic, ColorFunction -> "CyclicArg"], {{s, 6},
0.00001, 10}]


I’d like to take the time to play with some of the other ComplexPlot ColorFunction options, which appears to be a powerful and flexible visualization tool.