Friday, June 01, 2012

Functions, Expressions, Formulae, and the Like

Last weekend, I participated in a lively philosophical discussion about the nature of functions. We were on the right track, but got derailed by semantics -- particularly because we didn't fully establish the concept of range, and only dusted lightly upon the concept of domain.

My friend had the basic definition right, but we were struggling with the mapping rules because we hadn't established the underlying criteria successfully. My friend correctly argued that simply restating the formula for a circle, such as x^2+y^2=r^2 into the form y=f(x) did not magically convert it to a function. So, y=sqrt(r^2 - x^2) is not a function -- but why? The concept of a 1:1 mapping was brought forward by my friend. So, I used the standard counter to that, namely that y=x^2 is indeed a function. Since values of y are repeated, why is that any different than having values of x repeated? Similarly, y=cos(x) is a periodic function in which values of y are repeated an infinite number of times...  So, what gives? My friend was right, but something critical was missing from the discussion.

You see, because we hadn't really discussed the concept of range, it was difficult to come up with a clear and indisputable response to the mapping problem. So, the discussion got tabled. But, the question still needed to be reconciled. The rigorous definition of a function goes something like this: for all x that are elements of the domain, there exists one (and only one) y that is an element of the range such that y=f(x). That is how the mapping works, but the definition looks like utter and complete rubbish in English. When I studied number theory and set theory many years ago, we would have used the following shorthand:
The rules for a function
This shorthand conveys everything in the English definition above rather succinctly. It also reveals a set of  truths upon further reflection:

  • Each x can produce one (and only one) y
  • The same value y can appear an infinite number of times, and that's totally okay.
    • (Consider the expression y=3, and you'll get there quickly)
  • A function doesn't have to make any continuous sense from the standpoint of a a single mathematical expression or formula.
The third bullet is not necessarily intuitive, but the following abomination is a graph of a proper function that meets all of the rules:
A rather odd-looking function
In this freaky function, the domain has been constrained to all Real Numbers between -x1 and +x2. For each value of x within this domain, one and only one value of y is produced by the function. The range would be defined as the set of all Real Numbers between some -y1 and +y2 which, respectively, represent the lower and upper values that the graph covers in the y axis. So, even though trying to build this ugly graph with a single mathematical expression is highly unlikely, it meets all of the criteria of a function.

In fact, I could have made it look worse.  There doesn't have to be any semblance of "continuity" in the mapping to the range! So, you could chop the x axis into several bits, and come up with different mathematical expressions for each bit, and the resulting whole could still be a function as long as it meets the rules.  Here's an example, with a domain defined as all Real Numbers from -300 to +300:
  1. For x=-300 through x=-100, y = 7x^5 - 30x^3 + x - 40
  2. For x>-100 but <0, y = tan(x^2)
  3. For x=0 through x=10, y = -(3x^4) + 5
  4. For x>10 but <100, y = (12.345x)/6.789
  5. For x=100 through x=300, y=cosh(x)
That would be a convoluted graph, and I'm not going to pretend that I can draw it freehand in Photoshop with a mouse. But, the resultant insanity is indeed a valid function with a significantly huge range [(7 * ((-300)^5)) - (30 * ((-300)^3)) + (-300) - 40 = -1.700919 × 10^13], [cosh(300) = 9.71213198 × 10^129], and that [y=tan(x^2)] bit gets interesting all by itself (here's what it looks like from -100 to -99.9, and below is a wafer-thin slice that reaches the limits of what Google will plot!).

"...and that's all I have to say about that."