## A Polar Curve

So I suppose, if I’m being honest, my post from earlier today about piecewise functions wasn’t entirely self-motivated. In all honestly, I sat down and was inspired to find a formula for a new polar curve. I’ve done similar things before. Today’s goal was to find a formula for a polar curve like the following:

My goal

The red lines are supposed to indicate that the curve is 0 at $\theta=\pi/4$ and $\theta=3\pi/4$. My goal in drawing this curve was to find something that looked like a limacon, but had self-intersections away from the origin. It’s a happy coincidence (in my mind, anyway) that the result, when crossings are properly applied, is a trefoil knot.

So, anyway, how to find a formula for my function? The first step, for me, is to unroll it back to a Cartesian form. I’ll call it $f_1(x)$, and it looks something like the following, with 0s at $\pi/4,3\pi/4$, a min corresponding to the polar point $(-3,\pi/2)$, and a max corresponding to the polar point $(2,3\pi/2)$:

My (Cartesian) goal

Next, I know that shifting functions horizontally isn’t too hard, so let me shift left by $\pi/4$, obtaining a graph like the one above, except passing through the origin. Let’s call this $f_2(x)$:

As a third change, though one that’s trickier to sort out algebraically (I’ll do it below), I’ll make the graph more symmetric by assuming the second 0 occurs at $x=\pi$, instead of at $x=\pi/2$. Let’s call the resulting graph $f_3(x)$:

Now this, to me, looks like the plot of $-\sin(x)$, except for the fact that the amplitude is 3 on the first half, and only 2 on the second half. So let’s call it $-a(x)\sin(x)$, where my amplitude function looks like:

This is just the curve $a(x)=2.5+.5\sin(x)$, so we have a formula for $f_3(x)$. Namely, $f_3(x)=-(2.5+.5\sin(x))\sin(x)$. Not terribly pretty, but manageable.

Now, how do I do that change that took me from $f_2(x)$ to $f_3(x)$? Since the graph of $f_2(x)$ is obtained from the graph of $f_3(x)$ by some sort of horizontal manipulations, I know $f_2(x)=f_3(s(x))$ for some function $s(x)$. What does $s(x)$ look like? Well, it sends 0 to 0, and $2\pi$ to $2\pi$, and also sends $\pi/2$ to $\pi$. That gives me three points, $(0,0)$, $(\pi/2,\pi)$, and $(2\pi,2\pi)$ on the graph of $s(x)$, and I’ll define $s(x)$ to be the piecewise linear function connecting them. Because I think maybe it’ll be handy, let me set $o(x)=s(x)-x$. From my work on piecewise curves in my earlier post (and a handful of algebra and horizontal translations), I know I can write $o(x)=\frac{1}{3}(x-\pi-2|x-\pi/2|)$. The following graph shows $s(x)$ (in black), $x$ (in red), and $o(x)$ (blue):

Thus, I’ve found $f_2(x)=f_3(x+o(x))$, something I can write out fully if I want (it’s getting to be a pretty long formula). Finally, I shift this graph over to the right by $\pi/4$ to obtain $f_1(x)=f_2(x-\pi/4)$, with graph:

Oh no! That’s not the graph I was expecting at the beginning. My Cartesian goal didn’t hit 2 at $x=0$. What happened?

Let me plot the function $f_1(x)$, obtained so far, on a wider domain:

Notice that this looks like a piecewise function. It begins as a sin (sinusoidal, I guess) curve (with modified amplitudes) with period $\pi$, and then shifts to one with a larger period. I would have probably hoped that the curve I was going for was just going to be periodic itself, so that if I extended the domain in the polar curve, I’d just end up tracing out the trefoil again.

The problem stems from my linear shift function $s(x)$, and it’s accompanying $o(x)=s(x)-x$. Notice that the formula for $o(x)$ is not periodic. It does what I want on the interval $[0,2\pi]$, but outside of that, it’s negative. That’s not what I wanted, and it matters because I shift some of these negative bits into the picture with my final shift from $f_2(x)$ to $f_1(x)$. How can I take this function that I like on $[0,2\pi]$ and extend it periodically throughout the whole real line?

Let me define another function, $m(x)$, which computes “$x\bmod 2\pi$“. Usually, I expect the modulus of a number to be taken with respect to an integer, not $2\pi$. All the same, we can make it work. The function $x\bmod 1$ can be written as $x-\lfloor x\rfloor$ (here $\lfloor x\rfloor$ is the “floor” function, returning the greatest integer less than $x$). The graph of this function is a saw-tooth curve. Of course, I don’t want “$x\bmod 1$“, but “$x\bmod 2\pi$“. I just modify $x-\lfloor x\rfloor$ with some factors of $2\pi$, obtaining $m(x)=2\pi(x/(2\pi)-\lfloor x/(2\pi) \rfloor)$.

The following plot contains the original $o(x)$ (in green), the saw-tooth curve $m(x)$ (in black), and the nicely periodic offset function $\tilde{o}(x)=o(m(x))$ (in blue, overlapped by green $o(x)$ in the first positive interval):

Now let’s go back and fix up our functions. The function $f_3(x)$ was fine, it didn’t involve $o(x)$. The definition of $f_2(x)$ above was $f_2(x)=f_3(x+o(x))$, but that uses the non-periodic offset function $o(x)$. I’ll replace it with it’s period cousin, $\tilde{o}(x)=o(m(x))$, so that $f_2(x)=f_3(x+\tilde{o}(x))$. This has the nice periodic graph:

Finally, $f_1(x)$ was just a horizontal shift of $f_2(x)$, so $f_1(x)=f_2(x-\pi/4)$. This graph looks much better (it’s periodic, and not 2 at $x=0$).

Not only is it correct on $[0,2\pi]$, but when plotted as a polar curve, it gives us what we were after all along:

Hurray! Now, what are the coordinates of the intersection points (besides the origin)? Does the corner at $\pi/4$ (coming from the corner on $\tilde{o}(x)$) in $f_1(x)$ mean this function has a discontinuous derivative? How could it be patched up? Would making $o(x)$ as a quadratic function (I’ve got 3 non-colinear points, which determine a quadratic) work well? Can the symmetry be improved? Perhaps by picking other angles where the curve is 0, or different amplitudes for the inner and outer loop (2 and 3, respectively, in the example above)?

I don’t know the answers to any of those questions. Some I have worked a little on (the last one, since I could do lots of nice plots if I set things up in enough generality in Maple), others, though interesting (points of intersection), I have not.

By the way, I made all of my graphs at fooplot.com (which I’ve used lots, it’s nice).

Tags: , ,

### One Response to “A Polar Curve”

1. Mikael Vejdemo Johansson Says:

So, your intersection points are points (a,f(a)) such that f(a) = -f(a+π). What you really are doing is figuring out an angle such that the function value on the other side of the circle really is negative, and with the same magnitude as the function value right here and now.

So, you can figure out your intersection points by just solving the original function for this particular equality. And by periodicity, and the phase shift, it is enough to match the function in the interval [0,π] with the negative of the function value in the interal [π,2π]. This means I can actually escape all the nice stuff you did to make things work with domain all reals, and just look at the piecewise bits.