Functions: Basic notation

Functions, also called maps or mappings, are ubiquitous in mathematics. When the laymen hears the term function, they usually thinks of things like \(f(x) = x + 1\). But the concept is much more general. Anything can be thought of as a function as long as it takes a fixed number of arguments as its input and returns some output. Crucially, the output is not allowed to vary when the input is kept the same.

Sticking with numbers, suppose \(f(x)\) randomly maps \(x\) to either \(x+2\) or \(x \times 2\). This is not a function because one and the same input can produce different outputs. Yes, \(f(2)\) would always yield \(4\) because \(2 + 2 = 4\) and \(2 \times 2 = 4\). But for \(3\), the two diverge: \(3 + 2 = 5\) but \(3 \times 2 = 6\). So \(f(3)\) would sometimes be \(5\) and sometimes \(6\), which means that \(f\) is not a function.

However, if we turned \(f\) into a binary function that takes some number \(x\) as its first argument and some operation \(\oplus\) as its second argument and maps that to \(x \oplus 2\), then \(f\) is a function. In that case, \(f(3, +) = 3 + 2 = 5\) and \(f(3, \times) = 3 \times 2 = 6\). Now it is okay that the outputs vary because we are also varying the inputs.

A car wash can be regarded as a function that takes as input a car and returns as its output a clean car (in an ideal world, at least). A dirty Dodge Viper comes out as a clean Dodge Viper, and a clean Audi A4 still comes out as a clean Audi A4. The output is always perfectly predictable from the input.

English has a construction where a word is doubled and its beginning replaced with shm, as in rules shmules or fancy shmancy. This construction, called shm-reduplication, is borrowed from Yiddish and conveys a kind of derision. We can regard this as a function that takes a word as its input and returns the corresponding shm-form.

Speakers vary as to what they accept as the correct shm-reduplicant for some words. For example, some speakers turn breakfast into shmeakfast, replacing both b and r, whereas other only replace b, yielding shmreakfast. Explain why this does not contradict the claim that shm-reduplication can be regarded as a function.

Let \(f\) be a function that takes as its input a number \(n\) and returns \(n+1\) on a workday and \(n+2\) on the weekend.

  • Is \(f\) a function?
  • What if \(f\) instead takes two arguments: a number \(n\), and the name of the day of the week. Is this version of \(f\) a function?

The fact that functions cannot map one and the same input to multiple outputs is known as right uniqueness. Right uniqueness guarantees that functions are deterministic in the sense that one can predict the output from the input with 100% accuracy.

Caution: The functions used in programming languages are not necessarily functions in the mathematical sense. In programming, the output of a function can vary even if the arguments to the function stay the same.

Recap