In mathematics, a function is written as a map that uniquely assigns to every element from the domain a corresponding element from the range .
This is expressed by .
Alternatively, when considering particular elements and , you write .
Here, is called the name of the function and is its value when applied to . Here, is sometimes called the argument of . Let's first look at an example before considering functions in Python.
For example, and . This function maps two real numbers to their difference.
In mathematics, functions can have numbers, vectors, matrices, and even other functions as arguments. Here is an example of a function with mixed arguments:
In this case, a real number is returned. When working with functions, we have to distinguish between two different steps:
- The definition of the function
- The evaluation of the function, that is, the computation of for a given value of
The first step is done once, while...