Absolute Bats

loopspace

2019-09-21

1 Introduction

In this post, I described an activity using quadratics to draw the Batman Logo. It was slightly inspired by the famous Batman Curve, but based on a different version of the Batman logo. One key difference was that my version was presented as a series of quadratics and lines outlining a region, whereas the original Batman Curve was expressed as a single curve.

Slightly out of idle curiosity, I wondered about making my version also into a single curve. I decided to take a different approach to the original Batman Curve, which exploits some features of computer graphics systems, and make much use of the absolute value function.

2 The Absolute Value Function

If functions were superheros, the absolute value function would definitely not be Batman. It would have to be one that had a secret identity as someone very unassuming, and Bruce Wayne is just too flamboyant. On the other side, the superhero part would have to be very powerful indeed. So we're talking someone like Clark Kent, Peter Parker, or Carol Danvers here.

The absolute value function is formally defined as:

 $\mid x\mid =\left\{\begin{array}{ll}x& x\ge 0\\ -x& x<0\end{array}$

Less formally, it forces what is inside it to be positive. So $\mid -3\mid =3$. In computing, it is one of the simplest functions to implement as it just throws away the sign of the number.

And yet it can do so much. What we need to use it for is to define the maximum and minimum of two things.

 $\begin{array}{rl}\mathrm{max}\left(a,b\right)& =\frac{1}{2}\left(a+b+\mid a-b\mid \right)\\ \mathrm{min}\left(a,b\right)& =\frac{1}{2}\left(a+b-\mid a-b\mid \right)\\ \end{array}$

We can also feed in functions into these and they give the pointwise maximum and minimum of those functions, as in Figure 1. Figure 1: The minimum of two functions

I want to use a more compact notation for these, particularly when functions are concerned:

 $\begin{array}{rl}f\wedge g& =\mathrm{min}\left(f,g\right)\\ f\vee g& =\mathrm{max}\left(f,g\right)\end{array}$

There is another use of the absolute value function. Given a function, say $f\left(x\right)$, we can consider $f\left(\mid x\mid \right)$. This has the effect of taking the part of the function on the positive $x$–side and reflecting it onto the negative $x$–side as in Figure 2. Figure 2: Reflecting a Function

3 Batman in Quadratics

Although the absolute value is not Batman, we'll stick to the Batman Logo1. I don't know of another logo that is so distinctive, but also relatively straightforward to draw.

1As one of my students started the activity, I heard them mutter "I bet it's Batman. It's always Batman."

I'm going to modify it slightly, though, as when I drew up the original I was more concerned with the numbers in the coefficients than any other feature. It'll be useful to have the upper and lower parts of the curve meet at "nice" coordinates. Also, the original was upside-down to delay the reveal but for this I'll turn it back the right way. The starting functions are therefore:

1. $y=-0.1{x}^{2}+14.1$

2. $y=0.05{x}^{2}+4$

3. $y=-0.25{x}^{2}+4.5x-16.15$

4. $y=-0.25{x}^{2}-4.5x-16.15$

5. $y=-0.3{x}^{2}+2.7x-5$

6. $y=-0.3{x}^{2}-2.7x-5$

7. $y=10x+14$

8. $y=-10x+14$

9. $y=5x+3$

10. $y=-5x+3$

11. $y=5.5$

Several of these are in pairs, where one is a reflection of the other in the $y$–axis. We can use the "inner absolute value" trick to condense these into a single function. This leaves us with the following list, illustrated in Figure 3:

1. ${\gamma }_{1}:y=-0.1{x}^{2}+14.1$

2. ${\gamma }_{2}:y=0.05{x}^{2}+4$

3. ${\gamma }_{3}:y=-0.25{x}^{2}+4.4\mid x\mid -16.15$

4. ${\gamma }_{4}:y=-0.3{x}^{2}+2.7\mid x\mid -5$

5. ${\gamma }_{5}:y=-10\mid x\mid +14$

6. ${\gamma }_{6}:y=5\mid x\mid +3$

7. ${\gamma }_{7}:y=5.5$ Figure 3: The Various Curves

4 Maxing Out

The lower part of the logo is the simplest. This is defined by curves ${\gamma }_{3}$ and ${\gamma }_{4}$ and we simply take their maximum, as in Figure 4. Thus:

 ${\gamma }_{low}={\gamma }_{3}\vee {\gamma }_{4}$ Figure 4: The Lower Part of the Curve

The upper part would be as simple if it were not for the head. That takes a little more thought. The inner part is the maximum of the lines ${\gamma }_{6}$ and ${\gamma }_{7}$, after which we take the minimum of that with ${\gamma }_{5}$, as in Figure 5. Thus:

 ${\gamma }_{head}={\gamma }_{5}\wedge \left({\gamma }_{6}\vee {\gamma }_{7}\right)$ Figure 5: The Head Curve

The inner part of the upper curve is then the maximum of this and ${\gamma }_{2}$, and the full upper curve is the minimum of that with ${\gamma }_{1}$ as in Figure 6:

 ${\gamma }_{high}={\gamma }_{1}\wedge \left({\gamma }_{2}\vee \left({\gamma }_{5}\wedge \left({\gamma }_{6}\vee {\gamma }_{7}\right)\right)\right)$ Figure 6: The Upper Curve

5 Tracing the Bat

We now have the upper and lower parts of the logo expressed as the graphs of functions. To put them together, though, requires treating them as parametrised curves. Thus rather than plotting $y={\gamma }_{low}\left(x\right)$, we have to plot $\left(x\left(t\right),y\left(t\right)\right)=\left(t,{\gamma }_{low}\left(t\right)\right)$. This is because the graph of a function cannot double back on itself horizontally. So what we want to do is something like:

 $t↦\left\{\begin{array}{ll}\left(t,{\gamma }_{low}\left(t\right)\right)& -11\le t\le 11\\ \left(22-t,{\gamma }_{high}\left(22-t\right)\right)& 11\le t\le 33\end{array}$

Only we'd like to do it without calling on a piecewise definition. Note that our adjustments to the functions mean that the upper and lower curves intersect at $x=±11$.

What we will do to achieve this is the following2. We start by creating a function that first traces out the upper path and then the lower (due to the nature of our functions, we can create that quite simply). This function will form the $y$–coordinate of our path. The "backtracking" will result from what happens to the $x$–coordinate. While the $y$–coordinate is along the upper part of the curve, the $x$–coordinate should simply increase, then when the $y$–coordinate moves to the lower part, the $x$–coordinate should reverse.

2I will freely admit that this is the second idea that I had to do this. The first method ended up with a formula that needed more than a full page to typeset.

To form the $y$–coordinate path, we start by translating the upper and lower paths so that they are side-by-side3 as in Figure 7.

3We exploit a bit symmetry here in that the lower path should be reflected as well as translated but we don't need to do that.

 ${\gamma }_{y}\left(t\right)={\gamma }_{high}\left(t+11\right)\vee {\gamma }_{low}\left(t-11\right)$ Figure 7: The Unravelled Curve

The $x$–coordinate path just needs to go from $-11$ to $11$ and back again.

$\begin{array}{rl}{\gamma }_{x}\left(t\right)& =11-\mid t\mid \\ {\gamma }_{y}\left(t\right)& ={\gamma }_{high}\left(t+11\right)\vee {\gamma }_{low}\left(t-11\right)\end{array}$
 1

Putting that together, we get our final curve as:

 $\beta \left(t\right)=\left({\gamma }_{x}\left(t\right),{\gamma }_{y}\left(t\right)\right)$ Figure 8: The Full Parametrised Curve

6 Unrolling the Curves

Mathematical notation is designed to focus attention. By hiding unnecessary details, it allows us to work on what is important or relevant without getting lost in a morass of symbols. The form of our curve in Equation 1 has this property. We can see enough of the definition without having to know too much about how ${\gamma }_{low}$ and ${\gamma }_{high}$ are defined.

It is with some trepidation, therefore, that I am going to unroll the definition of ${\gamma }_{y}$ back to a function of $t$.

Thanks to the left and right shifts, we can rearrange the final form of ${\gamma }_{y}$ slightly.

 $\begin{array}{rl}{\gamma }_{y}\left(t\right)& ={\gamma }_{high}\left(t+11\right)\vee {\gamma }_{low}\left(t-11\right)\\ & =\left({\gamma }_{1}\left(t+11\right)\vee {\gamma }_{3}\left(t-11\right)\vee {\gamma }_{4}\left(t-11\right)\right)\\ & \phantom{=}\wedge \left({\gamma }_{2}\left(t+11\right)\vee \left({\gamma }_{5}\left(t+11\right)\wedge \left({\gamma }_{6}\left(t+11\right)\vee {\gamma }_{7}\left(t+11\right)\right)\right)\right)\\ & =\left(\left(-0.1{t}^{2}-2.2t+2\right)\vee \left(-0.25{t}^{2}+5.5t-46.4+4.4\mid t-11\mid \right)\\ & \phantom{=\left(}\vee \left(-0.3{t}^{2}+6.6t-41.3+2.7\mid t-11\mid \right)\right)\\ & \phantom{=}\wedge \left(\left(0.05{t}^{2}+1.1t+10.05\right)\vee \left(\left(-10\mid t+11\mid +14\right)\wedge \left(\left(5\mid t+11\mid +3\right)\vee 5.5\right)\right)\right)\\ & =\begin{array}{ccc}\left(\begin{array}{c}-0.1{t}^{2}-2.2t+2\\ \vee \\ -0.25{t}^{2}+5.5t-46.4+4.4\mid t-11\mid \\ \vee \\ -0.3{t}^{2}+6.6t-41.3+2.7\mid t-11\mid \end{array}\right)& \wedge & \left(\begin{array}{c}0.05{t}^{2}+1.1t+10.05\\ \vee \\ \left(\begin{array}{c}-10\mid t+11\mid +14\\ \wedge \\ \left(\begin{array}{c}5\mid t+11\mid +3\\ \vee \\ 5.5\end{array}\right)\end{array}\right)\end{array}\right)\end{array}\end{array}$

Putting the $x$ and $y$ parts together, we get:

 $\left(\begin{array}{c}11-\mid t\mid ,\begin{array}{ccc}\left(\begin{array}{c}-0.1{t}^{2}-2.2t+2\\ \vee \\ -0.25{t}^{2}+5.5t-46.4+4.4\mid t-11\mid \\ \vee \\ -0.3{t}^{2}+6.6t-41.3+2.7\mid t-11\mid \end{array}\right)& \wedge & \left(\begin{array}{c}0.05{t}^{2}+1.1t+10.05\\ \vee \\ \left(\begin{array}{c}-10\mid t+11\mid +14\\ \wedge \\ \left(\begin{array}{c}5\mid t+11\mid +3\\ \vee \\ 5.5\end{array}\right)\end{array}\right)\end{array}\right)\end{array}\end{array}\right)$