A Little Bit of Piecewise Philosophy

August 30, 2021 | 13 minutes, 21 seconds

A little bit of piecewise philosophy

*Ramblings of a crazy girl

Note: This post is mostly my ramblings on piecewise. This is not another conceptual demonstration like my previous posts. Thanks.

Piecewise notation is an interesting concept in and of itself. It denotes a set of functions or relations on a set, or sets, of conditions based on variables or truth functions. It does, in fact, do so quite succinctly. For example, rather than writing out, in full, the definitions of a function with set builder notation (or whatever you'd like to call it) several times, you simply write out the function once, with a bit of piecewise notation, and its domain, as usual.

An example of this is the widely-known absolute value, or modulus, function:

\[ f:\mathbb{R}\to\mathbb{R}^+\cup\left\{0\right\}, f(x)=\begin{cases} x & x\geq 0 \\ -x & x \leq 0\end{cases}\]

This is more tediously written:

\[ f:\mathbb{R}^+\cup\left\{0\right\}\to\mathbb{R}^+\cup\left\{0\right\},f(x)=x\\ f:\mathbb{R}^-\cup\left\{0\right\}\to\mathbb{R}^+\cup\left\{0\right\},f(x)=-x\]

And so \(f\) is defined on \(\mathbb{R}\), but partially. I also note the use of the degenerate domain \(x=0\) in both partial definitions to sneakily note that \(f\) on the real numbers is indeed a function, and continuous (\(f(0)=0\) for both definitions).

Now interestingly, the use of piecewise notation is a common idea that's been adopted in even pre-calculus level classes, in the context of graphing, for example, time plots. This is an example of such a function. Now, such a function could be a time plot, based on some abstract or physical idea or measurement such as distance. That is largely irrelevant. Where we hit a 'snag' is when we decide how we can interpret such a function. That is,

If we consider a piecewise function \(f\), how does it relate to a piecewise function \(g\) defined on all the same domains as \(f\)?

Such examples of groups of functions include a function and its derivative(s), which may not always be continuous or even well-defined, integrals, areas, and all of their respective physical interpretations. So the question is: How do we relate these? And why do we care?

In purest form, two piecewise functions can be compared on their respective (sub-)domains. Equality, inequality, all defined nicely under ideal circumstances. This gives a straightforward idea: If \(f\) and \(g\) are mutually related to one another, that is, operations on \(f\) affect \(g\) and vice versa, then one could perform operations on \(f\) to get to \(g\) on that subdomain. Then, we consider other subdomains and do the same operations as with the first case. This algorithm effectively describes operations on piecewise functions and their "cases". As you may have noticed, however, this is almost equivalent to a bruteforce method - you have to find a singular set of steps in order to reach \(g\) from \(f\) that work over each subdomain. This begs the question - can we do better?

Why should we care about the relation of such functions? Well, for starters, there are instances where we do want to find the derivative of a piecewise function, the integral of a piecewise function - or even the equation of another piecewise function in terms of simpler ones. It is, therefore, an important idea consider. Now, taking motivation from my previous (paragraph/conjecture/whatnot), one might argue that an operation on a piecewise function is an operation on all of its cases. This is a special case of an unexpected mentality that I personally have been working with:

All cases of piecewise functions are inter-related. They are not independent. To call them independent is like calling a sequence a set; without order (and also just plain wrong).

This mentality rises very quickly when working with piecewise functions. But this is not a mentality that would arise when considering piecewise functions without the notation we've so very conveniently handed to it. The reason being is that piecewise notation is written in such a way it can be expressed in a singular expression. But another question that might arise is how you might express a piecewise function as a combination of elementary functions, as opposed to a function on several domains. Perhaps the most unexpected, for those who do not know of the absolute value function, is the notion that \(|x|=\sqrt{x^2}\). Let me be clear: this is only half correct and I'll get to that later. But the root in this equality is the principal root, an idea and consequence I've covered in one of my previous conceptual demonstrations on this website.

You can, yourself, show that \(\sqrt{x^2}\) does in fact satisfy the definition of \(|x|\). In fact, it even satisfies the derivative of the absolute value function and the integral, where both are defined at any rate. So clearly, it means \(|x|\) must always equal \(\sqrt{x^2}\)...right?

A trap in the idea that piecewise cases are intimately related to one another is that it is far too easy to assume that the piecewise function defines the characteristic and exact behaviour of the function, when in fact, that is far from the case. In fact, a little bit of trivial investigation will show you that \(\sqrt[2n]{x^{2n}}\) for \(n\in\mathbb{Z}^+\cup\left\{0\right\}\) over the reals will also satisfy the definition of \(|x|\). Or, more extremely, \(\cosh^{-1}(\cosh(x))\) also does. In fact, every even function which has a principal left-inverse will satisfy the same definition. I digress. This begs the question: Why should we have a single characteristic representation of any piecewise function? And my very simple answer to my above question is: It's not about shouldn't, it's that there doesn't exist a single characteristic representation.

Piecewise notation and definitions define a class of functions, or class of compositions of functions, that satisfy all the properties defined piecewise, as opposed to a single function.

Does this mean finding the 'formula' of a piecewise function is fruitless, pointless or misguided? No, it doesn't. But a small correction should be made: finding a formula, noting that any formula you find will come with restrictions. But it also means in its purest forms, you can only represent piecewise functions in terms of other piecewise functions, in the strictest sense of piecewise. Furthermore, while this may not invalidate the notion of performing, say, calculus on the characteristic representations of piecewise functions, it makes it largely pointless. Why would you differentiate an almost-certainly more complicated function when you can differentiate piecewise as I argued above, for example, anyway? Indeed, it is a silly idea to do so in the strictest sense, but perhaps for memorisation techniques may be helpful.

This notion is of course excluding the idea that any and every function is piecewise. For example, a domain is a union of smaller domains contained within it, and so a function can be partially defined on those smaller domains respectively. Does it makes sense to do this? No... unless the function is not well-defined, or even defined at all, in some domain. And at that point should you want to 'extend' the partially-defined function on a domain, there are infinitely more functions that satisfy anything you could extend it to. And this is an important idea: not all piecewise functions are nicely defined everywhere. In fact, in the realm of polynomial interpolation, a piecewise function actually represents a set of coordinate mappings (i.e. \(x\mapsto y\)) that can be manipulated in such a way that an equation can be found. In fact, it behaves almost the same way as a piecewise function above.

Now, as it turns out, piecewise functions definitely don't have to have finitely many cases. Functions such as the floor or ceiling functions have infinitely many cases. You might even consider these functions to be a mix of sets of points and functions, as they make discrete continuous inputs; i.e. they map \(\mathbb{R}\to\mathbb{Z}\). This makes sense; no one said, for example, that cases in piecewise functions had to have finite domains - so why would there be a limit on the number of cases? On the other hand, how does one represent an uncountably infinite number of cases? Should there exist a method to? If you could, you could represent, say, the irrational numbers, piecewise - and consequently be able to map them all to (all) rational numbers. Wait - that's impossible. Now there's a classic proof. Maybe that's not a requirement, but it is certainly an intriguing idea. With that being said, uncountable sets can be represented using continuous domain notation.

I find myself digressing yet again, and yet, I've still not my made my point on the usefulness of the notation we've invented and thrown aside so quickly. Piecewise notation is inherently notation designed to be tools to quicken up the process of evaluating certain functions. Laplace transforms? Unit step functions. A primitive representation of functions for quick evaluation. Pre-calculus? Graphing. Integration? Notational simplicity. Probability, potentially one of the biggest use cases? Again, notational simplicity. I thus beg the question: Why don't we look into piecewise as something far greater than it's currently been used for?

Perhaps I find myself a hypocrite, having written this post and yet worked towards finding formulas, equations, whathaveyou, for such interesting phenomena like cubes in higher dimensions, the batman logo, the sticking together of functions, the interpolation of polynomials and subsequent of two major historical methods for such things. Or perhaps not, because these ideas are inherently intriguing and while may not necessarily be computationally efficient, open up a world of ideas to anyone wishing to create their own magical objects. I am of course inherently intrigued by finding formulas for piecewise representations of functions. The techniques required to do so give rise to some interesting algebraic techniques on these piecewise functions. But have I gone so far without realising the uselessness of all of this? This is a question I ask myself everyday, and yet still find myself more and more intrigued.

Piecewise notation is a unifying notation. We can represent mappings, functions, truth tables and logic gates using it, and in computers they're more or less equivalent to if-else statements. Yet they are more than that. And to this day, as a first year university student, I'm finding more and more ideas to apply in the context of piecewise functions. The calculus I'm taking, 3 dimensional surfaces and planes and space curves, parameterisations, differential equations. Even the introductory maths classes I took last year which built up my understanding of set theory and notation before contributed. And so the question is, what more can we do with it and just how far can the very idea that the cases are inter-related go? Just how extensive is piecewise notation? They certainly work well with vectors too, and not just real numbers.

For a final point, I would like to mention the specifics of just how piecewise notation is written and represented in text. Where I personally prefer a minimalistic approach; no "if" words or commas between function definitions and conditions, not everyone does this. I would furthermore be inclined to disagree strongly on the definitions written by Mathworld and Wikipedia; piecewise notation is far more than just functions defined over subintervals. I would argue that \(\pm\), for example, a symbol and/or operator that high school education relishes in abusing, something that, like piecewise notation, simplifies function or variable definitions significantly, is itself piecewise (where we have two tautologies for conditions, or whatever is appropriate):

\[ a\pm b=\begin{cases}a+b & \top \\ a-b & \top \end{cases}\]

One might also be inclined to define it such that \(x=a\pm b\iff(x-a)^2-b^2=0\). This also gives motivation to the idea that the null factor law might be written alternatively piecewise... That's one to explore for later.

And that has been enough of my rambling and opinions on piecewise and its philosophy, haha. I could be misguided, I might not be. But what I would like more than anything is to have some interactivity and conversation about this topic, as that would open up my world. Please, if you've made it this far, contact me. You'll find my email address on my about page and I'm always open to talking about this or other maths topics I'm mildly familiar with.