What’s better than an ordinary ellipse?   A super ellipse, of course.

And what’s better than a superellipse?   That’s right, a superellipse and a square.

But who can plot both of those luxury items?   Anyone, with a single function you can make at home.

Here are implicit function plots of a superellipse, two squares, and a handy almost-superellipse loop.

$$\require{begingroup} \begingroup \def \K { \kern-.5em } \def \p #1#2{ | {2 \over \large\raise.2ex\pi} #1 \kern.1em | ^ {#2} \! } \begin{matrix} &&&& \small\sf \rlap { In~the~lap~of~luxury } &&& &&&& \small\sf \rlap{ On~a~budget } \\[2ex] \small\sf Loop &&& \large {\raise.2ex 1 \over 2\surd2} &\K = &\K f(x,y) & \K = & \K \p x{2.5} + \p y{2.5} &&& 1 & \K = & \K h \, (x{+}y \, ,x{-}y) \\[1ex] \small\sf Square &&& 1 &\K = &\K g(x,y) & \K = & \K \p x\infty + \p y\infty &&& 0 & \K = & \K h \, (x{+}y \, ,x{-}y) \end{matrix} \kern2em \\ \tiny\strut \endgroup$$

The status- conscious among us may impress themselves by recognizing  $ {\raise.2ex 1 \over 2\surd2} = f(x,y) $  as nothing less than a genuine superellipse, yet the handy-dandy  $\raise-.5ex\strut 1 = h \, (x{+}y \, ,x{-}y) $  is almost identical, with 12 common points and less than .011 of maximum separation.

Counting typographically, $f(x,y)$ and $g(x,y)$ are defined by 19 and 15 raw components, respectively, including fraction lines, decimal points, and everything else after the equals signs.

       Can you define $h(x,y)$ with fewer than 10 raw components?

The only components available are those already present in the definitions of $f$ and $g$, as well as all other digits and constants, along with any other letters as long as they spell out trigonometric functions.   Every letter counts, so, for example, ${ \small\raise .5ex \unicode {8220} } \kern-2mu \sin \kern-3mu { \small\raise.5ex \unicode{8221} }$ would contribute 3 components.

Both loops pass through $( \pm { \Large\pi \over \large 4 } , \pm { \Large\pi \over \large4 } )$ and the squares’ sides are at $x = \pm { \Large\pi \over \large 2 }$ and $y = \pm { \Large\pi \over \large2 }$.   Portions of the Cartesian plane beyond the square may contain other points and curves.   Never mind that $g(x,y)$ is defined casually and without regard to the square’s vertices.

Online freebies that helped in preparation and could help in solution:
Function Grapher – Good with explicit plots; no ads.
MathGrapher at eMathHelp – Good with implicit plots, sometimes bad with pop-up ads.


2 Answers 2



$\cos~x + \cos~y$


Approximate the x and y intercepts of the loop as $\frac{\pi}{3}$ (since $2^{-\frac{8}{5}} \simeq \frac{1}{3.03}$). Then we need $h(\pm \frac{\pi}{3}, \pm \frac{\pi}{3}) = 1$, so to turn those $\pm\frac{\pi}{3}$s into something reasonable we probably need $\cos~x$ (there are other ways, of course, but it was hinted that we need trig and also it takes care of both positive and negative very compactly: $\cos~\frac{\pi}{3} = \cos~\frac{-\pi}{3} = \frac{1}{2}$). It's likely to be symmetric in $x$ and $y$ so try out $\cos~x + \cos~y$ for now. We've got the loop; now to check what that looks like when $h = 0$ so we can modify it for the square and woah we're already done.


Non-solution that may yet be of some interest:

If we write

$h(u,v)=2-\cos u-\cos v$

then (exactly) the right thing happens at $h=0$ and we are within the necessary bounds at $h=1$. But the definition is, alas!, 11 symbols long.

[EDITED to add:]

D'oh. Actually the above is the result of a mis-conversion from my MATLAB fiddlings, and doesn't in fact do the right thing at $h=0$. If I do the conversion correctly, what I should have written before was

$h(u,v)=\cos u+\cos v$

... but bmcfluff got there after the wrong version of my answer and before this correction. So it goes :-).

  • $\begingroup$ This is not a "non-solution" anymore but the an incredible virtual photo finish, within minutes (seconds?) after 3 days! $\endgroup$
    – humn
    Mar 1, 2017 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.