Skip to main content
\( \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section2.3Functions

Subsection2.3.1Overview

When two variables are related, it is sometimes the case that knowing one of the variables allows us to predict the value of the other variable. Other times, knowing one variable is not enough to determine the value of the other variable. Finding and describing such predictive relationships is at the heart of all quantitative sciences. If a predictive relationship can be found, then it can used, naturally enough, to make predictions. If a predictive relationship can not be found, then scientists explore the system attempting to find additional variables that make predictive relationships. The ability for one variable to predict another corresponds to the mathematical idea of a function.

This section explores the foundational ideas necessary to talk about functions. We begin with mathematical relationships between variables, represented by equations, to define one variable as an explicit function of another. The process of starting with an equation to create such an explicit function corresponds to solving the equation for the dependent variable. This requires a brief review of the role of mathematical operations, their order of precedence, and inverse operations. Because some functions might not come from explicit formulas, we introduce the mathematical description of a function with a corresponding function notation. We conclude with examples.

Subsection2.3.2Functions from Equations

A function is a relationship between two variables such that knowing one variable (the independent variable) allows us to predict the exact value of the other variable (the dependent variable). Conveniently, an equation in two variables defines a relationship between those variables. If we can solve such an equation so that one variable is equal to an expression involving only the other variable, then we have written that variable as an explicit function of the other.

Definition2.3.1Explicit Function

Given an independent variable \(x\) and a dependent variable \(y\), we say that \(y\) is an explicit function of \(x\) if we have an equation where \(y\) equals an expression involving \(x\) but not \(y\).

Example2.3.2

The following are examples of a dependent variable written as an explicit function of an independent variable.

  • \(y=x^2+1\), where \(x\) is independent and \(y\) is dependent

  • \(P=1000e^{-0.1t}\), where \(t\) is independent and \(P\) is dependent

  • \(t=10\ln(1000/P)\), where \(P\) is independent and \(t\) is dependent

When an equation is given where the dependent variable is not written as an explicit function of the independent variable, we try to solve the equation for the dependent variable, usually by trying to isolate the dependent variable. This really means that we are finding an equivalent equation where the desired variable is isolated. We find equivalent equations by applying the same operation on both sides, so long as the operations are invertible.

Think of an expression as a package. The mathematical operations represent layers of wrapping or packaging. However, instead of unwrapping the package by tearing layers off, imagine that each type of packaging material has an inverse material that when layered next to one another dissolve both (like anti-matter). To unwrap the package, we choose the appropriate inverse materials and wrap it with inverses until all the desired layers have been dissolved. The mathematical challenge is being able to look at an expression, identify which operation is the last step (the outermost packaging) and select the appropriate inverse operation to remove that step (the inverse material).

The order of operations determines the order in which operations are applied in a mathematical expression. This is often summarized using an acronym PEMDAS. The letters represent the words “parentheses”, “exponents”, “multiplication”, “division”, “addition” and “subtraction”. Multiplication and division are inverse operations and actually have the same priority as one another. Similarly, the operations of addition and subtraction are inverses with equal priority. Even better, you should view these as a single operation involving inverse elements. That is, division is multiplication by an inverse (reciprocal) and subtraction is addition by an inverse (negative). The operation of exponents in algebra really should be generalized to any function (like square roots, logarithms, trigonometric functions, etc.).

Example2.3.3

Identify the last operation for each of the following expressions.

  • \(x^2-3xy\): The last operation is subtraction. This expression is a difference of the expressions \(x^2\) and \(3xy\). Alternatively, we can think of subtraction as addition by an inverse, \(x^2+-3xy\), so that the last operation is technically addition by the inverse of \(3xy\), which we can write \(-3xy\)

  • \(3xy\): The last operation is multiplication. In particular, since parentheses are not used to indicate a different order, the last operation is the last multiplication so that the expression is a product of the terms \(3x\) and \(y\). (The properties of commutativity and associativity means that the order of different multiplications doesn't matter, so we could also think of \(3y\) and \(x\) as being multiplied.)

  • \(5e^{2x}\): The last operation is multiplication. The expression is a product of the number \(5\) and the expression \(e^{2x}\).

  • \(\displaystyle \frac{2x+y}{3x}\): It might be tempting to think that the last operation is addition. However, division written in fraction form has implied parentheses, \((2x+y) \div (3x)\). So the last operation is division and the expression is a quotient of the expressions \(2x+y\) and \(3x\). Or we could say the expression is a product of \(2x+y\) and the reciprocal (or multiplicative inverse) of \(3x\), which might be written \(\div(3x)\).

Once the last operation of an expression is identified, apply the inverse operation to both sides of the equation to remove that operation from the expression of interest.

Example2.3.4

Solve the equation for \(y\) as a function of \(x\). \begin{equation*}3xy+4 = 5y+x\end{equation*}

Solution

Sometimes, an equation can be solved for either variable. For example, there is nothing fundamentally special about \(x\) that says it should always be the independent variable. If we can solve for \(x\) as an explicit function of \(y\), then \(y\) would be the independent variable.

Example2.3.5

Solve the equation, \begin{equation*}3xy+4 = 5y+x,\end{equation*} for \(x\) as a function of \(y\).

Solution

When an equation can be solved for each of the variables as an explicit function of the other variable, then the equation defines a one-to-one relationship. In this case, we call the two resulting functions inverse functions. We will discuss inverse functions in more depth in a few sections to motivate the ideas of roots and logarithms. Later, we will connect inverse functions to the idea of function composition.

Subsection2.3.3Function Notation

When we solve an equation to write \(y\) as an explicit function of \(x\), we might want to actually make a prediction for the value of \(y\) for particular values of \(x\). For example, if \(y=x^2+1\), we might want to know the predicted value of \(y\) when \(x=2\). From the equation, we know \(y=x^2+1=2^2+1=5\). That is, we used the number 2 in place of the variable \(x\) in the expression defining \(y\). Instead of always saying the value of \(y\) when \(x=2\), mathematics provides function notation.

The function, in the simplest case defined by an expression involving the independent variable, is represented by a name or a symbol, often a single letter like \(f\) or \(g\). To show that the symbol is a function and not a variable, parentheses are placed after (to the right of) the symbol and an input value or expression to be used as the independent variable is written inside of the parentheses. The combined symbol of the function name with the input in parentheses is interpreted as a single expression giving the corresponding value of the output. For example, \(f(3)\) is interpreted as “the value of the function \(f\) when the independent variable has a value 3,” and is usually read more simply “\(f\) of 3.”

It is essential to note that the parentheses do not refer to multiplication. It is unfortunate that mathematics does not have distinct notation for the parentheses used for grouping and multiplication and the parentheses used for functions. It is simpler to write with only one type of parentheses, but requires more interpretation on the part of the reader.

Example2.3.6

Interpret the expressions involving a function, where \(f(x)=\sqrt{x+1}\).

  • \(f(3)\): This expression is simply the output value of the function \(f\) when the input is 3, which we would more simply say, “\(f\) of 3.” Because 3 is a specific number or a constant, this expression is also a constant. Specifically, \(f(3) = \sqrt{3+1}=\sqrt{4}=2\).

  • \(f(t)\): This expression is simply the output value of the function \(f\) when the input is the variable \(t\), or “\(f\) of \(t\).” Because the input \(t\) is a variable, the expression \(f(t)\) is also a variable, more specifically a dependent variable, \(f(t)=\sqrt{t+1}\).

  • \(x \cdot f(2x+1)\): This expression is a product of the variable \(x\) and the output of a function \(f\) with an input using the expression \(2x+1\). More simply, we would say, “\(x\) times the value of \(f\) of \(2x+1\).” The value of this expression would be \begin{equation*}f(2x+1) = \sqrt{(2x+1)+1} = \sqrt{2x+2},\end{equation*} which has no further simplification.

  • \(\displaystyle \frac{f(a)}{f(b)}\): This expression is a quotient involving the output of a function \(f\) with an input \(a\) divided by the output of the same function \(f\) with an input \(b\). Using the formula, we have \begin{equation*}\frac{f(a)}{f(b)} = \frac{\sqrt{a+1}}{\sqrt{b+1}}.\end{equation*}

  • \(\displaystyle f(\frac{a}{b})\): This expression is the value of a function \(f\) for an input computed by dividing \(a\) by \(b\). This is fundamentally different than the previous expression, \begin{equation*} f(\frac{a}{b}) = \sqrt{\frac{a}{b}+1}.\end{equation*}

As emphasized in the second and third expressions of the above example, functions do not apply separately to the terms making up the input expression. For example, the expression \(f(2x+1)\) is often mistakenly rewritten as \(f(2x)+f(1)\). Most likely, this mistake is a consequence of seeing the parentheses as multiplication, which it is not. In a similar way, some students might rewrite \((x+y)^2\) as \(x^2+y^2\), which is incorrect. There is no such thing as distributing a function, which includes powers, to the terms inside.

In addition to a name, a function requires defining the set of all possible inputs. This set is called the domain of the function. For example, the equation \(y=\sqrt{x}\) defines \(y\) as an explicit function of \(x\). However, this equation only makes sense when \(x \ge 0\). If we defined the function \(\mathrm{sqrt}(x) = \sqrt{x}\), then the domain of \(\mathrm{sqrt}\) is defined as \begin{equation*}\mathrm{dom}(\mathrm{sqrt}) = \{x : x \ge 0\} = [0,\infty). \end{equation*} Similarly, the equation \(\displaystyle w=\frac{3}{z-2}\) defines \(w\) as an explicit function of \(z\). If we defined a function \(f\) to match this equation, \begin{equation*}f(z) = \frac{3}{z-2},\end{equation*} then the output will be defined for every value of \(z\) except \(z=2\), which we write as \begin{equation*}\mathrm{dom}(f) = \{ z : z \ne 2 \} = (-\infty,2) \cup (2,\infty).\end{equation*} For a review of sets and interval notation, see the Appendix A.1.2.

Similarly, a function should specify a set from which the output values are selected, and this set is called the target or co-domain. The set of all actual output values is called the range of the function. Usually, the target is chosen as a set that describes the type of value for the dependent variable. The simplest choice for the target would just be the set of real numbers. If we knew that the predicted variable was guaranteed to be non-negative, then we might instead choose a target to be the interval \([0,\infty)\). If the predicted variable was measuring a probability, then the target might be chosen as \([0,1]\).

To state that a function has a given domain and target, we introduce mapping notation. Suppose \(D\) is the domain and \(T\) is the target for a function \(f\). We would write \begin{equation*}f : D \to T.\end{equation*} If we also have an explicit formula for a given input value \(x\), then we can add this information as well using \begin{equation*}f : D \to T; x \mapsto f(x),\end{equation*} where \(f(x)\) is replaced by the appropriate explicit formula. When a function is defining a relation between state variables, we can also use mapping notation to indicate the independent and dependent variables.

Example2.3.7

The square-root function \(\mathrm{sqrt}(x) = \sqrt{x}\) introduced earlier can be written more precisely using mapping notation as \begin{equation*} \mathrm{sqrt} : [0,\infty) \to [0,\infty); x \mapsto \sqrt{x}. \end{equation*}

Example2.3.8

Consider a population of plants growing in a plot of land. Let \(P\) be the number of plants. Each plant will either grow to maturity and seed or will die prematurely. We can consider \(\phi\) (Greek letter phi) to be the variable that measures the fraction of plants that reach maturity. We expect that there should be a relation between the population \(P\) and the fraction that seed \(\phi\). We consider \(P\) to be our independent variable and \(\phi\) to be our dependent variable, because we want to use our population size to predict the fraction that seed.

In this setting, the domain would be a set \(D_0\) of integers, \begin{equation*} D_0 = \{0, 1, 2, 3, \ldots, P_{\hbox{max}}\}, \end{equation*} where \(P_{\hbox{max}}\) is the greatest possible number of plants that can be grown on the plot. This is called a discrete domain. In calculus, we usually work with continuous functions which requires a domain made from intervals rather than just integers. So for our mathematical model, we might adjust the domain to be the interval of real numbers \begin{equation*}D = [0,P_{\hbox{max}}].\end{equation*} (Note: When \(P=0\), the fraction of plants that survive is not physically defined. But in a model, we can still be interested in that case as a limiting value.)

The target for our model needs to be a set that describes what type of number the dependent variable \(\phi\) will be. Because \(\phi\) is a measurement, it must be a real number. So we might choose our target set as the set of all possible real numbers \(\mathbb{R}\). We know that the fraction must be non-negative, so \([0,\infty)\) would also be acceptable. However, the best choice would probably be a target of \begin{equation*} T=[0,1]\end{equation*} because \(\phi\) measures the fraction of plants that seed which can never exceed 1.

If we named our function \(f\), we would write \begin{equation*}f : [0,P_{\hbox{max}}] \to [0,1]; P \mapsto \phi.\end{equation*} Note that although we do not know an explicit formula for our function, we used the dependent variable from the state of our system. That is, we use the mapping notation to indicate which variable is the input and which is the output. A mathematical model might try to find a formula that approximates this relationship.

Example2.3.9

Consider the same population of plants as in the previous example. Let \(P\) be the number of plants in the plot. Of those plants that successfully seed, the number of seeds will almost certainly vary from plant to plant. But we might expect the average number of seeds on plants that survive to reproduce could be predicted based on knowing \(P\). Let \(\sigma\) (Greek letter sigma) be the variable representing this average number of seeds. We could define the function \(g\) by writing: \begin{equation*} g : [0,P_{\hbox{max}}] \to [0,\infty); P \mapsto \sigma. \end{equation*}

This mathematical statement defining \(g\) captures all of the basic information for our function. It tells us that the input value, or independent variable, is the state variable \(P\). The domain of possible values for \(P\) is the interval \([0,P_{\hbox{max}}]\). The output value, or dependent variable, will be \(\sigma\), the average number of seeds on surviving plants, which could be any non-negative number.

Note that in these last two examples, the emphasis was not in finding an explicit formula for the functions but in characterizing the role of the function. This consisted in clearly describing the independent and dependent variables (input and output) with their corresponding domain and target sets. To use these functions in a practical sense, we would want to associate a particular rule, model or formula to determine actual values. Nevertheless, describing a function more abstractly allows us flexibility to describe general relationships that depend on the role of a function rather than the explicit formula that it might use.

Subsection2.3.4Abstract Functions

In mathematics, we want to describe functions, even when we do not have a formula. The mathematical definition of a function captures the concept of a predictive relationship between two variables.

Definition2.3.10Function

Given a set \(D\) (domain) and a set \(T\) (target), a relationship \(f\) is a function \(f : D \to T\) if for every value \(x \in D\), the rule for the relationship defines a unique value \(y \in T\), and we write \(y=f(x)\).

Recall that an equation in two variables, say \(x\) and \(y\), can define a curve in the plane. If we choose a particular value on the \(x\)-axis and drew a vertical line, the graph might intersect the line at one or more points. If there is only one intersection point, we can use the \(y\)-value of the point to predict the value of \(y\) for that value of \(x\). However, if there are multiple points of intersection, then knowing the value of \(x\) is not enough to predict \(y\). (Does this remind you of something called the vertical line test?) The mathematical idea of a function is designed specifically to capture the idea of using one variable to predict another.