Friday, February 10, 2017

Introducing a new mathematical notation for functions

How it's usually done

I've always been quite unsatisfied with the standard mathematical notation for functions. Typically, if you wanted to define functions, you would say something like this:

I want to emphasize the difference between f and f(x), since I think it is worth noting. f represents the function, whereas f(x) represents the value you would get if you plug in x into the function. Another way of seeing this is that in this example, the "type" of f is "function", whereas the "type" of f(x) is "real number". Of course, f(x) doesn't mean anything unless you already know what x means.

So, with this in mind, you'll notice that the above notation, which was supposed to define the function f, only told us what would happen if you plugged in some number x. A real definition should have the symbol to be defined (in this example f) by itself on the left hand side, and the thing it represents on the right hand side. But here, f is not by itself on the left hand side. Since we lack the notation to say what f is, we introduce a new variable x and say what f(x) is. The implicit idea behind this is that there is only one function that transforms the input variable x into the output specified by that expression. This makes sense, but it is really an indirect workaround for the lack of actual function-definition notation.

As an (admittedly contrived) analogy, consider what we would do if we lacked the digit "5" in our notation, but we had all other digits. What if we wanted to define a number n to have the value five? We might resort to something like "Let x+1=6". Notice that this gives you enough information to know what x is, but is too indirect.

The standard way of defining functions also has some limitations of convenience. For example, it is not easily pluggable into expressions that use it. As an example, consider the function composition notation.

In case you need a refresher, function composition is when you create a new function by applying one function, and then another. In this case, the function f○g represents the result of applying g first, then f.

Let's make another analogy with numbers. Let's say you know already that a=3 and b=2. When you encounter an expression like a+b, you can replace the symbols with what they represent, resulting in the equivalent expression 3+2. Now what happens when we try this with the function composition above. We know what f and g are. But we don't have expressions for them! There's nothing we can plug in. We can try confusing f(x) with f. Then we the nonsensical notation:

It's not clear here how this should be interpreted. This is supposed to be true for all x. But if we plug in x=3, we get this weird result that has obviously lost all meaning:

Clearly, we need a better way of writing functions.

My way

I propose that we write the above function definitions like so:

Now f and g are defined directly. The function consists of curly braces with two clauses separated by a colon. The first clause introduces a temporary symbol to represent any arbitrary value in the domain, and the second clause is an expression in terms of this symbol showing the procedure of transforming the input value into the output.

If you have seen "set-builder notation" before, you might recognize it as similar to the notation that I am introducing.

In fact, the only difference is that instead of a value in the second clause of set-builder notation, there is a condition. If you view a condition as a boolean value (AKA a value that is either true/false), then a set is nothing but a function that results in a true or false value. So, these notations are compatible. If you're into set theory, you might already think of sets in your head as functions that result in booleans.

Let's see how we can plug the functions into expressions:

See how clear this is? You can see where the functions are really easily using this notation, and there is no "type confusion" between functions and numbers, so to speak.

Bonus features

Derivatives

With standard notation, you would probably write something like this:

Here, the function's independent variable is weirdly embedded within the differential operator. Also, the resulting function cannot be used in an expression. Even something like evaluating it at a x=3, which should be as simple as putting (3) at the end, is not easy. There are a few common special-purpose notations to solve this very specific issue:

But this is not required if we use my notation for functions. The derivative operator, in essence, takes a function and results in a function. So it can itself be viewed as a higher order function, let's call it D.


If you want, you can express the definition of the derivative like this:

Fourier Transform

This is how you might have seen the Fourier transform definition. It was probably explained to you in words (as opposed to math) that capital F is the transform of lowercase f.
(Note: this is the way I was taught it. It uses j as the imaginary unit, and there is no 2π in the forward transform. If you're used to a different definition, some of the properties/pairs are slightly different)

There was no good way to write a transform pair, so one was invented for that overly-specific purpose:

This notation relies on the "magic variables" t and ω to be the independent variables of the two functions.

With my notation, the Fourier transform may be expressed as a higher order function FT like this:

And a transform pair can be expressed like: