Saturday, April 30, 2016

More Polar Classics: Spirals

Some more from the classic polar curves collection... today we specialize in spirals. The basic concept of what a spiral should be, in polar coordinates, is any plot $r$ varying with $\theta$, $r=f(\theta)$, where $f$ is always increasing, and $\theta$ is allowed to go beyond the usual range of $0\leq \theta < 2\pi$ (or $-\pi < \theta \leq \pi$). The most fundamental one, of course, is $r = \theta$, which says the distance from the origin is proportional to the amount you've wound around the origin:



(here the angle is in radians and the equation is $r = \theta$). Of course, some people thought this was a bit boring, so Fermat spiced it up and thought what if we make the spirals wind tighter as you go around? Basically, make it a concave-down, increasing function, $r = \sqrt{\theta}$. Actually, it's more fun to also consider $r = -\sqrt{\theta}$:

($r=\sqrt{\theta}$ is in blue, and $r = -\sqrt{\theta} is in yellow$)

This of course could more succinctly be written $\theta = r^2$. But perhaps the second-most famous, due to its ubiquity in nature (because stuff tends to grow exponentially) is the famous logarithmic spiral $r = e^{c \theta}$ or $\theta = \frac{1}{c} \log r$, which magnifies every time you spin it.

($r=e^{\theta/5}$)

And finally, where would we be in polar graphs if we didn't have the analogue of stuff with asymptotes? Consider $r^{-2} = \theta$ (instead of $r^+2$):



This is called the lituus of Cotes. There's all sorts of curves from back in the day with very funny names; I used to look for a lot of them on the MacTutor History of Math Page (more specifically, its Curves Index).

There's one other spiral that's my favorite, but (1) it isn't polar, and (2) there's a lot of interesting differential geometry going on in it, so I'm saving it for another post.

Thursday, April 28, 2016

Variance Solids: Volumes and $\mathscr{L}^2$, Part 2


Last time, we talked about how the classical $\mathscr{L}^2$ norm of a (one-variable) function could be visualized as a solid consisting of squares. Of course, there's another formula that is defined by almost the same formula, with an extra factor of $\pi$: the solid of revolution of the function about the $x$-axis: \[
V = \int_a^b \pi f(x)^2\,dx
\]
It looks pretty cool, although not quite as cool as twisted square cross-sections.

I wanted to mention another common application of $\mathscr{L}^2$ norms that probably is more familiar than any other: the statistical concept of variance. For functions $f$ defined on a continuous domain, we can define an average value:\[
\overline{f} = \frac1{b-a}\int_a^b f(x)\,dx.
\] which basically is the height of a rectangle over the same domain $[a,b]$ that has the same area as the area under $f$. For example, for \[
f(x) = \sin \left( x \right)\sin \left( t \right)+\frac{1}{3}\sin \left( 5x \right)\sin \left( 5t \right)+\frac{1}{3}\sin \left( 10x \right)\sin \left( 10t \right)+\frac{1}{5}\sin \left( 15x \right)\sin \left( 15t \right)
\]
(choosing $t=3.030303$), it looks like:


(the blue line in the middle is the mean value). The variance $\sigma^2$ is then a measure of how far $f$ is from its mean:\[ \sigma^2 = \frac{1}{b-a}\int_a^b (f(x) - \overline{f})^2\,dx. \] This of course can be visualized exactly as last time, namely, make a bunch of square cross sections about the line $y=\overline{f}$, and possibly do funny things to such squares, such as rotate it. But ... for kicks, let's add a factor of $\pi(b-a)$:\[ \pi(b-a)\sigma^2 = \int_a^b\pi (f(x) - \overline{f})^2\,dx, \] which is precisely the same quantity as the solid obtained by revolving $f(x)$ around its mean $y=\overline{f}$. The resulting solid is the title picture.

Sunday, April 24, 2016

Volumes of Solids and (squared) $\mathscr{L}^2$ Norms

The volume of this solid is the squared $\mathscr{L}^2$ distance between $y=x^2$ and $y=x^3$ on the interval $[0,\frac{3}{2}]$.

The good ol' $\mathscr{L}^2$ norm has an outsized importance in many applications of math, principally, because Hilbert spaces (spaces with inner product) are useful for, well, just about anything. Much of a fan of Hilbert spaces I might have been for much of my recent life, it is only when teaching how to find the volume of solids (and a little help from Math Homie William) when it hit me what the best visualization for them is, at least for functions defined on $\mathbb{R}$. (For the longest time, I just said "It's sort of like the area between two curves, but, you know, squared, and stuff.") But we learn in integration theory that we can base a solid by putting squares (or semidisks or triangles, or whatever) in a perpendicular, 3rd dimension, over the area between curves; the volume of the solid is \[
V=\int_a^b A(x) \, dx
\] where $A(x)$ is the area of the cross section. But of course there's an obvious candidate: if you choose squares to have side length being the height of your function $f(x)$, then $A(x)$ is just $f(x)^2$. Thus,\[
V = \int_a^b f(x)^2 dx.
\] But that's none other than the squared $\mathscr{L}^2$ norm of $f$! Similarly, for the volume of a solid consisting of squares between two curves $f(x)$ and $g(x)$, this is just \[
V=\int_a^b (f(x) - g(x))^2dx,
\] the (squared) $\mathscr{L}^2$ distance between the two functions. Now if we treat each of these squares like a deck of cards, and rotate them, it shouldn't change the volume. So we apply this to the functions $f(x)=x^2$ and $g(x)=x^3$ on $[0,\frac{3}{2}]$:



Now making vertical segments between the curve, and making a square with that side length pop half out of the plane, and half into the plane, gives us a nice solid. Rotating it gives the picture at the top.

Friday, April 15, 2016

Polar Coordinate Classic

In some sense, my first "Nested Tori" was a notebook which contained really cool plots and graphs. There's lots of old gems there worth posting and updating. Today, I bring you a nice polar plot. I was really intrigued by plots in polar coordinates, because it represented the first real departure from simply graphing $y=f(x)$. We instead (most commonly) write $r = f(\theta)$ where $r$ is distance from the origin and $\theta$ is counterclockwise angle, and let things get farther or closer as we go around. Without further ado, here is the famed butterfly (it does have a little post-warping afterward, though), which shows you that you don't need fancy-schmancy 3D stuff to still find great things:

$r = e^{\sin \theta} - 2 \cos(4\theta) +\sin^5\left(\dfrac{\theta-\frac{\pi}{2}}{12}\right), 0 \leq \theta \leq 24\pi$




Monday, April 11, 2016

Pasta Parametrization, High Resolution

Integrating (ha ha) Nested Tori back into life (of course I'm doing a lot of integrating, if I'm teaching, anyway). Lots of change was (and is) afoot.

Anyway, instead of continually getting peeved with Apple for not ever fixing any bugs in Grapher for over 10 years (a job that I would gladly take the mantle on, by the way: anyone at Apple listening??), I took matters into my own hands and started experimenting with some open source plotting libraries. In particular, I've taken somewhat of a liking for matplotlib, a famous Python package. The boon is, it can generate pdf files properly (unlike Grapher, which basically puts the bitmap into a pdf file and adds the extension .pdf, but when you zoom in, it's blocky and clearly still a bitmap). Honestly, though, it is in fact a lot more work (which was mitigated somewhat by defining some functions).

Here are the results for plotting the Pasta Parametrization in matplotlib (specifically, the mplot3d toolkit):


Of course, I should probably figure out how to control the lighting better: it doesn't look as good as Grapher's (at a scale for which the resolution issue is not a problem). And here are the matching formulas (at a larger size than the old version):


Happy parametrizing! (see here for the answer key, and here for the Python source)
(Astute readers may notice that the above images are actually still bitmaps... but that's an artifact of the blogging software, which does not natively display pdf's ... see here for the pdf for that)