# Functions

- 8 minutes read - 1674 wordsA **function** is a rule that maps each element of a set \(X\) to exactly one element of a set \(Y\). The set \(X\) is called the **domain** of the function, and the set \(Y\) is called the **codomain** of the function. A function that maps \(X\) to \(Y\) is usually denoted by \(f\colon X \to Y\). For each element \(x\in X\), we write \(f(x)\) and read “f of x” to denote the element of \(Y\) to which \(x\) is mapped. A function with codomain the set of real numbers \(\mathbb{R}\) is called a **real-valued function**. A function having the set of real numbers as its domain is called a **function of a real variable**. It is usual to omit these specializations whenever they are understood from context, and simply refer to functions \(f\colon \mathbb{R} \to \mathbb{R}\) as functions instead of real-valued functions of a real variable.

- The
*identity function*\(f\colon \mathbb{R} \to \mathbb{R}\) maps all real numbers to themselves, i.e., \(f(x) = x\) for all \(x\in\mathbb{R}\). - The
*logarithmic function*\(f\colon \mathbb{R}_{> 0} \to \mathbb{R}\) mapping positive real numbers to their logarithm, i.e., \(f(x) = \log x\) for all \(x\in \mathbb{R}_{> 0}\). - The
*exponential function*\(f\colon \mathbb{R} \to \mathbb{R}\) mapping real numbers to their exponentials, i.e., \(f(x) = \mathrm{e}^x\) for all \(x\in \mathbb{R}\).

## Graphs

The functions' graphs are among the most common and easily communicated ways to represent functions and depict their properties. As a mathematical object, the graph of a function is defined as a set. The **graph** of a function \(f \colon X \to Y\) is the subset of the Cartesian product \(X \times Y\) defined by
\[
\mathcal{G}(f) = \left\{(x, f(x)) \in X\times Y \colon\, x\in X \right\}.
\]
Graphs take familiar geometric representations of collections of points in the Cartesian coordinates for real-valued functions of one or two real variables.

The graphs of functions of two real variables are also called **surfaces**.

## One to One and Onto Functions

Although each \(x \in X\) is uniquely mapped to \(f(x)\), different elements of \(X\) can be mapped to the same element of \(Y\). A function that maps each element of \(X\) to a unique element of \(Y\) is called **one to one** or **injection**.

- The identity function \(f(x) = x\) is an injection.
- The constant function \(f\colon \mathbb{R} \to \mathbb{R}\) mapping all real numbers to the constant real number \(5\), i.e., \(f(x)=5\) for all \(x\in\mathbb{R}\), is not an injection.
- The logarithm and exponential functions are injections.

Not all elements of \(Y\) have to be necessarily used by the association rule of the function. The subset of the codomain \(Y\) used by the function’s rule is called **range**, and it is denoted by \(f(X)\). In general, we have \(f(X)\subseteq Y\), and if the last relation holds with equality, i.e., \(f(X) = Y\), we say that \(f\) is **onto** or a **surjection**. A function that is simultaneously an injection and a surjection is called a **bijection**.

- The identity function \(f(x) = x\) is an injection and a surjection, namely a bijection.
- The constant function \(f(x)=5\) is neither an injection nor a surjection.
- The \(f\colon \mathbb{R} \to \mathbb{R}\) that maps all real numbers to their absolute value (distance from zero), i.e., \(f(x)= \left|x\right|\) for all \(x\in\mathbb{R}\), is not a surjection.
- The logarithm is a surjection, but the exponential function is not a surjection.

## Functions of multiple variables

It is fruitful to define rules for associating things from multiple sets to a codomain set on some occasions. For example, sweet recipes use different combinations of essential ingredient quantities to prepare various desserts. Chocolate cakes use chocolate and sugar but no vanilla, while vanilla cakes use sugar and vanilla but not chocolate. If we let \(X_{1}\), \(X_{2}\), and \(X_{3}\) be the set of potential quantities for chocolate, sugar, and vanilla, and \(Y\) be the set of deserts, we could conceive recipes as functions of the form \(f: X_{1}\times X_{2}\times X_{3} \to Y\).

A mapping \(f\colon \times_{i=1}^{n} X_{i} \to Y\) is called a **function of multiple variables** (in this case \(n\) variables). We write \(f(x_{1}, x_{2}, \dots, x_{n})\in Y\) to denote the value of the an element \((x_{1}, x_{2}, \dots, x_{n}) \in \times_{i=1}^{n} X_{i}\). Sometimes, it is more convenient to think of the elements of the Cartesian product \(\times_{i=1}^{n} X_{i}\) as vectors and shorten the notation to \(f(x)\) with the implicit convention that \(x = (x_{1}, x_{2}, \dots, x_{n})\).

**Cobb-Douglas**function \(f\colon \mathbb{R}_{\ge 0}\times \mathbb{R}_{\ge 0} \to \mathbb{R}\), which has the form \[ f(x_{1}, x_{2}) = A x_{1}^{\alpha} x_{2}^{\beta}, \] where \(A\), \(\alpha\), and \(\beta\) are positive constants. In consumption theory, \(x_{1}\) and \(x_{2}\) denote consumption quantities and \(f(x_{1}, x_{2})\) denotes their associated utility. In production theory, \(x_{1}\) and \(x_{2}\) denote production factor quantities and \(f(x_{1}, x_{2})\) denotes their associated production output. In macroeconomics, \(x_{1}\) denotes labor quantities, \(x_{2}\) capital quantities, and \(f(x_{1}, x_{2})\) the total output of the economy.

## Linear Functions

Linear functions are special functions that preserve addition and (vector) multiplication. This property makes linear functions very useful in sciences because they allow us to calculate results of addition and multiplication in the codomain from the corresponding operations in the domain and vice-versa, which can significantly reduce the calculation complexities.

A function \(f\colon X \to Y\) is **linear** if (and only if)
\[
f(x_{1} + \alpha x_{2}) = f(x_{1}) + \alpha f(x_{2})
\]
for all \(x_{1}, x_{2} \in X\) and \(\alpha \in \mathbb{R}\). Linear functions necessarily satisfy the condition \(f(0) = 0\). Geometrically, linear functions of a single variable have line graphs passing through the origin of the Cartesian coordinates. Formally, not all lines are linear functions (although this misconception becomes increasingly more mainstream). Functions with line graphs that do not pass through the origin of the Cartesian coordinates are called affine. A function is **affine** if (and only if) it preserves convex combinations, i.e.
\[
f(\alpha x_{1} + (1 - \alpha) x_{2}) = \alpha f(x_{1}) + (1 - \alpha) f(x_{2}),
\]
for all \(x_{1}, x_{2} \in X\) and \(\alpha \in [0,1]\).

## Monotonic Functions

In general, the value of a function can erratically change when it is given different domain values. Monotonic functions constitute a special class of functions with more predictable value changes restricted in particular directions. There are two main types of monotonic functions, namely increasing and decreasing functions. Although each type can be specialized using stricter monotonicity concepts, these two types adequately (for this introduction) describe the basic idea of monotonicity. A real valued function \(f\) is **increasing** if for all \(x_{1}, x_{2}\in\mathbb{R}\) such that \(x_{1} \ge x_{2}\), we have \(f(x_{1}) \ge f(x_{2})\). A real valued function \(f\) is said to be **decreasing** if for all \(x_{1}, x_{2}\in\mathbb{R}\) such that \(x_{1} \ge x_{2}\), we have \(f(x_{1}) \le f(x_{2})\).

- The identity function \(f(x) = x\) is (strictly) increasing.
- The exponential function \(f(x) = \mathrm{e}^x\) is (strictly) increasing.
- The function \(f(x) = \mathrm{e}^{-x}\) is (strictly) decreasing.
- The logarithmic function \(f(x) = \log x\) is (strictly) increasing.
- The function \(f(x) = \sqrt{x}\) is (strictly) increasing.
- The function \(f(x) = \frac{1}{\sqrt{x}}\) is (strictly) decreasing.
- The constant function \(f(x) = 5\) is both increasing and decreasing.

## Inverse Function

Functions are well-defined rules mapping elements of a set \(X\) to elements of a set \(Y\). What happens, however, if we are interested in examining how elements of \(Y\) are associated with elements of \(X\) according to a given function? For example, suppose that \(c\) is a consumption policy function (typically found in macroeconomics and finance) associating wealth (measured in Euros) with optimal consumption choices (measured in Euros). Thus, for each wealth level \(w\), \(c(w)\) gives the optimal spending allocated to consumption commodities and services. Sometimes it is also relevant to inquire about the required wealth for which a particular consumption level is optimal. Such an inquiry associates consumption spending with wealth levels, which goes in the inverse direction of the association that \(c\) describes.

This idea of inversion generalizes in mathematics via the concept of the inverse function. However, function inversion is not always possible. Suppose that we are given a function \(f\colon X \to Y\). To have a well-defined inverse function one has to be able to associate each element of \(Y\) with exactly one element of \(X\). If for some \(y\in Y\), there exist two \(x_{1}, x_{2} \in X\) such that \(f(x_{1}) = y = f(x_{2})\) one cannot unambiguously define an association from \(Y\) to \(X\) based on \(f\) (which value of \(X\) should be chosen? \(x_{1}\) or \(x_{2}\)?). Thankfully, we do not encounter such problems if we are given a one-to-one function because such functions guarantee that each \(x\in X\) is mapped to a unique element of \(Y\). The **inverse function** of a function \(f\colon X \to Y\), if it exists, is a function undoing the operation of \(f\). Namely, it is a function \(f^{-1}\colon f(X) \to X\) such that \(f^{-1}(f(x)) = x\) for all \(x \in X\).

- Find the inverse of the function \(f(x) = 3x\)
- Find the inverse of the function \(f(x) = \mathrm{e}^{2x}\)
- Does the function \(f(x) = \sqrt{x}\) have an inverse?

## Topic's Concepts

- inverse function
- decreasing
- increasing
- affine
- linear
- cobb douglas
- function of multiple variables
- bijection
- surjection
- onto
- range
- injection
- one to one
- surfaces
- graph
- function of a real variable
- real valued function
- codomain
- domain
- function