This site is supported by donations to The OEIS Foundation.

# Functions

(Redirected from Function)

A function takes a value or group of values (the arguments), performs an operation on those values, and returns the result. Generally, letters of the Greek alphabet or italicized letters of the Latin alphabet are used for this purpose, with ${\displaystyle f}$ generally being a generic function.

For example, ${\displaystyle f(n)=n^{2}+n+1}$ is a function that takes the integer ${\displaystyle n}$, squares it, adds that to it and 1, and returns the result of that operation.

More formally, we can define a function "from a set ${\displaystyle S}$ to a set ${\displaystyle T}$" as "a rule that assigns to each element of ${\displaystyle S}$ a unique element of ${\displaystyle T}$. We write ${\displaystyle f:S\to T}$."[1] The function may give the same result for two or more different arguments, but if it gives two or more results for the same argument, then it is not considered a function. For example,

${\displaystyle f(x)={\begin{cases}-1&{\text{ if }}x\leq 2\\\;\;\;x&{\text{ if }}x>2\end{cases}}}$[2]

is a function, even though it gives –1 as a result for infinitely many values of ${\displaystyle x}$. It would not be considered a function if the second condition was ${\displaystyle x\geq 2}$ instead, because then ${\displaystyle f(2)}$ would be ambiguous: it could be ${\displaystyle f(2)=1}$ or it could be ${\displaystyle f(2)=2}$.

Thus technically the square root is not a function, since, for example, ${\displaystyle {\sqrt {1}}=1}$ but also ${\displaystyle {\sqrt {1}}=-1}$. What is usually implemented as the square root function would more correctly be called the principal square root function, where the "principal" square root is taken to be the positive real root in the case of positive real arguments, the positive imaginary root in the case of negative real arguments, etc.

Given ${\displaystyle f:S\to T}$, the set ${\displaystyle S}$ may be finite, countably infinite or uncountably infinite; the same goes for ${\displaystyle T}$. Furthermore, it may be the case that ${\displaystyle S=T}$, with the most obvious example being the identity function ${\displaystyle id:\mathbb {C} \to \mathbb {C} }$, and the principal square root function being a less obvious example. Now, to give examples where ${\displaystyle S\neq T}$, we present the real part function ${\displaystyle \Re :\mathbb {C} \to \mathbb {R} }$[3] and the floor function ${\displaystyle \lfloor \rfloor :\mathbb {R} \to \mathbb {Z} }$.[4] Lastly, to give an example where ${\displaystyle T}$ is finite, we exhibit the Möbius function ${\displaystyle \mu :\mathbb {Z} ^{+}\to \{-1,0,1\}}$.

In the OEIS, ${\displaystyle a(n)}$ is usually a function that returns the ${\displaystyle n}$th value of the sequence under consideration.

1. Steven G. Krantz, Calculus Demystified, 2nd. Edition. New York: McGraw-Hill (2011): 35.
2. This is Example 1.32 in Krantz (2011).
3. The imaginary part function makes for a somewhat less straightforward example.
4. The ceiling function would work equally well for this example.