5 minutes read

If you have any programming experience, you know exactly what a "function" is. But the fact is that the mathematical meaning of this term is quite different from its use in coding; and in this topic you will learn what mathematicians call a function and what a map has to do with it.

What is a function?

A function is a mathematical object, or a "machine", that takes the xx value as an input and produces a unique value yy as an output. It's crucial that there exists only one value for yy for every input value of xx. This relationship is commonly denoted as y=f(x)y = f(x). It reads "yy is equal to ff of xx", where xx is an input or an argument, and yy is an output or a value. Sometimes yy or f(x)f(x) is called a dependent variable because it depends on the value xx, and xx is called an independent variable.

Function

Notice that f(x)f(x) does not mean "ff multiplied by xx". It means that "ff is a function of xx". You take an input xx, produce an output according to the rule ff typically, but not necessarily by performing some calculation, and get an output yy.

For example:

Example of a function

The most common name for the function is ff", but you can give it other names like gg, hh, murmurmurmur, coolfunctioncoolfunction, etc. Notice that xx is there to show us where the input goes and what happens to it. Thus, f(x)=5x+10f(x) = 5x+10 is the same function as f(r)=5r+10f(r) = 5r + 10, or f(w)=5w+10f(w) = 5w + 10, or f(Z)=5Z+10f(Z) = 5Z + 10.

Occasionally, a function has no name:y=x3.y = x^3.

But there is still an input xx, a relationship (the cube) and an output yy.

A formal definition

Suppose you have a set of inputs XX (domain) and a set of possible outputs YY (codomain). A function is a set of ordered pairs (x,y)(x,y), where xXx \in X, yYy \in Y, every element of XX belongs to some pair, and there can be only one pair with the same value of xx.

You can say that ff is a function from XX to YY as f ⁣:XYf \colon X \to Y.

Sometimes instead of the term "function" we call ff the map or mapping.

The element yy belonging to the pair (x,y)(x,y) is denoted f(x)f(x) (pronounced "ff of xx") and called the output of ff for the input xx, or the value of ff at xx, or the image of xx under ff.

The set of all values of ff taken together is called the range of ff or the image of XX under ff. Symbolically,

Domain, codomain and range

Thus, the first item in each pair is an element of XX, the second item is an element of YY, every element in the domain appears as the first item of one and only one of the pairs and no two pairs have the same first element. It is said that a function is single valued. Note that this topic considers only functions with a single argument.

Examples

We are given a set AA. To each element in AA, we assign one and only one element from BB.

Two sets

Notice that the domain and the range can contain the same thing (in our example, the number 1) or different things (bb and "python").

In this example, the domain is the set of integers 1 to 6, and the range might be the union of the set of integers, the set of letters, or the set of programming languages: A={1,2,3,4,5,6}A = \{1, 2, 3, 4, 5, 6\} and B={b,8, python, C++,1}B = \{b, 8, \ \text{python, C++}, 1\}.

In this case, 1 is mapped into bb, 2 is mapped into bb, 3 is mapped into 8, 4 is mapped into python\text{python}, 5 is mapped into C++\text{C++}, 6 is mapped into 1. Thus, the set of ordered pairs is set {(1,b),(2,b),(3,8),(4,python),(5,C++),(6,1)}\{(1, b), (2, b), (3, 8), (4, \text{python}), (5, \text{C++}), (6, 1)\}.

Note that the following relationship is not a function:

This relationship is not a function

"4" and "5" in AA have no relations in BB, and "3" is related to more than one value in BB ("h" in BB has no relationship, but it does not matter).

Conclusion

The concept of a function is widely used in math, computer science, physics, and other fields. Informally, it is a rule we can use to obtain an output from an input. A more formal definition includes pairs of elements, the first of which belongs to the set of possible inputs (known as domain) and the second belongs to the set of possible outputs (a codomain). As you can see, this concept is quite similar to what programmers use, but in strict form it describes a more general idea.

333 learners liked this piece of theory. 22 didn't like it. What about you?
Report a typo