# Smooth Pac-Man Curve?

Idle curiosity and a basic understanding of the last example here led me to this polar curve: $$r(\theta) = \exp\left(10\frac{|2\theta|-1-||2\theta|-1|}{|2\theta|}\right)\qquad\theta\in(-\pi,\pi]$$ which Wolfram Alpha shows to look like this:

The curve is not defined at $\theta=0$, but we can augment with $r(0)=0$. If we do, then despite appearances, the curve is smooth at $\theta=0$. It is also smooth at the back where two arcs meet. However it is not differentiable at the mouth corners.

Again out of idle curiosity, can someone propose a polar equation that produces a smooth-everywhere Pac-Man on $(-\pi.\pi]$? No piece-wise definitions please, but absolute value is OK.

• $r(\theta)=1+\tanh\big(100(0.9-\cos\theta)\big)$ – Rahul Jun 14 '13 at 1:03
• @Rahul That's really good - a simple formula and as it seems to me smooth all the way round. Bumping 100 to 1000 makes the mouth lines completely straight to my eyes. I'd probably take this as the answer if you post it. – alex.jordan Jun 14 '13 at 18:17
• @Rahul If you are still around, I'd love for you to post this as an answer. It's the answer I'd like to accept and clear this question from my unanswereds. – alex.jordan Nov 28 '14 at 1:05
• RIP Masaya Nakamura. – alex.jordan Jan 31 '17 at 1:19

Look at it in normal $(x,y)$ coordinates: what you're looking for here is a smooth approximation to a square wave (that's only $0$ for 1/4 of a period). In that light, this:

$$r=\frac1{(e^{100(\theta-3\pi/4)}+1)(e^{-100(\theta+3\pi/4)}+1)}\ \ \ \theta\in[-\pi,\pi]$$

Gives a pretty good approximation. Increasing the $100$ will make it arbitrarily good. Unfortunately it's not smooth at the inner corner of the mouth (though again this gets closer and closer as you increase $100$). This could be remedied by multiplying with a function that is essentially $1$ for almost all of $[-\pi,\pi]$ and quickly dips down to hit zero horizontally at the ends of the interval. I'm having trouble coming up with an example that isn't horrifying.

• +1 although this is also not smooth at the far left point. Rahul's answer in the comments seems to me to be elegant and smooth all the way around. – alex.jordan Jun 14 '13 at 19:23

OK, I found something, through a series of compositions:

Choose a large $n$ (used to approximately straighten out the mouth "lines"), and a parameter $c$ for the mouth width ($c=2$ works well).

$$r(\theta)=\left(f(c\theta)+r(c\theta)\right)^n$$ $$f(x)=1-\exp\left(\frac{1}{q(x)^2-1}\right)$$ $$q(x)=p(x)-\frac12\left(g(x+1)+g(x-1)\right)$$ $$p(x)=\frac{|x+1|-|x-1|}{2}$$ $$g(x)=\frac{|x|}{x}$$ $$r(x)=\frac{e^{-1}}{2}\left(g(x-1)-g(x+1)+2\right)$$

All together that's $$r(\theta)=\left(1-\exp\left(\frac{1}{\left(\frac{|c\theta+1|-|c\theta-1|}{2}-\frac12\left(\frac{|c\theta+1|}{c\theta+1}+\frac{|c\theta-1|}{c\theta-1}\right)\right)^2-1}\right)+\frac{e^{-1}}{2}\left(\frac{|c\theta-1|}{c\theta-1}-\frac{|c\theta+1|}{c\theta+1}+2\right)\right)^n$$

Here is a GeoGebra shot of this in action. There are discrepancies between the formulas in the screenshot and those above, since I tried a little to simplify things above. The radial function is also plotted using Cartesian coordinates. I'm fairly certain that this is everywhere-smooth, once you plug the two holes at the lips.

Not a very good one: $r(\theta) = e^{-\dfrac{1}{20 \theta^2}}$

• Good start - not smooth at the far left though. – alex.jordan Jun 12 '13 at 18:38
• That's a butt... – Cole Johnson Jun 13 '13 at 23:03