# What do we need functions for?

In this online functions course I have been teaching, and which is nearly halfway complete, a question has been kicking around in various forms. What do we need functions for?

There are many versions of this question. What do we need functions for (in middle school math)? What do we need functions for (in solving visual patterns tasks)? Et cetera.

One permutation of this question comes from the blogosphere’s own Michael Pershan. What do we need functions for (in mathematics more broadly)?

Here was my response to that question in class this morning. I do not consider this to be the definitive answer to it. Instead, it is an example. One of many, no doubt.

Apologies for the imperfect typesetting on the mathematics below. It’s good enough to get the point across and I don’t have time to look up all the relevant TEX commands to get it looking just right.

You know what blew my mind about functions on returning to higher math in graduate school? That we can make functions work for us—tirelessly like robots. My introduction to the idea that we can create functions that we can program to make something useful happen was the characteristic function. I am going to assume most of you have not taken graduate Real Analysis, so let me explain quickly.

The characteristic function of a set is defined to have the value 1 when the input is in the set, and to have the value 0 otherwise. Formally, that looks like this (UPDATE: apologies for broken math text):

That capital Xish thing is the Greek letter “Chi”. Here is the graph of .

So what, right? Well, the characteristic function links sets with functions. We can begin to talk about the size of a set based on the results of operations on the set’s characteristic function.

One question that mathematicians have been interested in dealing with over the years is how big is the set of rational numbers? By using the characteristic function , we can rephrase that question in terms of functions. Without giving away the first three weeks of graduate analysis, you can imagine the graph of this function as being a whole bunch of points on the x-axis and a whole bunch of points at y=1. Indeed, there are so many of each that you can’t see that the function is a function. It looks like two functions (Note; I have cheated and just plotted y=1 and y=0 below—I do not believe Desmos can work with the condition that x must be rational).

The question about the characteristic function on the rational numbers that corresponds to asking How big is the set of rational numbers? is this: What is the value of the integral of the characteristic function? That is, we ask what is the value of the following expression?

$\int_{[0,1]} \chi_{(Q)} (x)\,d \mu\$

Geometrically, we are asking how much area is shaded below (given that the points at y=1 correspond ONLY to the rational values of x in the interval 0≤x≤1).

The standard definition of integrals (the Riemann integral) cannot answer this question. One way of computing gives 0, another way gives 1, so we have to say that the integral does not exist. This function is not integrable in standard calculus.

So we invent the Lebesgue integral, which is defined in terms of sets rather than areas of rectangles. And we learn that the value of this integral is zero.

That is, the set of rational numbers is so small that we can say—relative to the size of the set of real numbers—that there are essentially none of them. The rational numbers are so few that we say the size of the measure of the set is zero.

They are infinite yet insignificant.

The machinery to prove all of that is the characteristic function.

That’s one thing that functions are good for.

Dig.