# Calculus/Functions

 ← Trigonometry Calculus Graphing linear functions → Functions

## What functions are and how are they described

Whenever one quantity uniquely determines the value of another quantity, we have a function. That is, the set ${\displaystyle X}$ uniquely determines the set ${\displaystyle Y}$. You can think of a function as a kind of machine. You feed the machine raw materials, and the machine changes the raw materials into a finished product.

 A function in everyday life Think about dropping a ball from a bridge. At each moment in time, the ball is a height above the ground. The height of the ball is a function of time. It was the job of physicists to come up with a formula for this function. This type of function is called real-valued since the "finished product" is a number (or, more specifically, a real number).
 A function in everyday life (Preview of Multivariable Calculus) Think about a wind storm. At different places, the wind can be blowing in different directions with different intensities. The direction and intensity of the wind can be thought of as a function of position. This is a function of two real variables (a location is described by two values - an ${\displaystyle x}$ and a ${\displaystyle y}$) which results in a vector (which is something that can be used to hold a direction and an intensity). These functions are studied in multivariable calculus (which is usually studied after a one year college level calculus course). This a vector-valued function of two real variables.

We will be looking at real-valued functions until studying multivariable calculus. Think of a real-valued function as an input-output machine; you give the function an input, and it gives you an output which is a number (more specifically, a real number). For example, the squaring function takes the input 4 and gives the output value 16. The same squaring function takes the input -1 and gives the output value 1.

There are many ways which people describe functions. In the examples above, a verbal descriptions is given (the height of the ball above the earth as a function of time). Here is a list of ways to describe functions. The top three listed approaches to describing functions are the most popular and you could skip the rest if you like.

1. A function is given a name (such as ${\displaystyle f}$) and a formula for the function is also given. For example, ${\displaystyle f(x)=3x+2}$ describes a function. We refer to the input as the argument of the function (or the independent variable), and to the output as the value of the function at the given argument. (Note: more on this notation is described in the next section.)
2. A function is described using an equation and two variables. One variable is for the input of the function and one is for the output of the function. The variable for the input is called the independent variable. The variable for the output is called the dependent variable. For example, ${\displaystyle y=3x+2}$ describes a function. The dependent variable appears by itself on the left hand side of equal sign.
3. A verbal description of the function.

When a function is given a name (like in number 1 above), the name of the function is usually a single letter of the alphabet (such as ${\displaystyle f}$ or ${\displaystyle g}$). Some functions whose names are multiple letters (like the sine function ${\displaystyle y=\sin(x)}$ .

 Plugging a value into a function If we write ${\displaystyle f(x)=3x+2}$ , then we know that The function ${\displaystyle f}$ is a function of ${\displaystyle x}$ . To evaluate the function at a certain number, replace the ${\displaystyle x}$ with that number. Replacing ${\displaystyle x}$ with that number in the right side of the function will produce the function's output for that certain input. In English, the definition of ${\displaystyle f}$ is interpreted, "Given a number, ${\displaystyle f}$ will return two more than the triple of that number." How would we know the value of the function ${\displaystyle f}$ at 3? We would have the following three thoughts: ${\displaystyle f(3)=3(3)+2}$ ${\displaystyle 3(3)+2=9+2}$ ${\displaystyle 9+2=11}$ and we would write ${\displaystyle f(3)=3(3)+2=9+2=11}$. The value of ${\displaystyle f}$ at 3 is 11. Note that ${\displaystyle f(3)}$ means the value of the dependent variable when ${\displaystyle x}$ takes on the value of 3. So we see that the number 11 is the output of the function when we give the number 3 as the input. People often summarize the work above by writing "the value of ${\displaystyle f}$ at three is eleven", or simply "${\displaystyle f}$ of three equals eleven".

## Notation

Functions are used so much that there is a special notation for them. The notation is somewhat ambiguous, so familiarity with it is important in order to understand the intention of an equation or formula.

Though there are no strict rules for naming a function, it is standard practice to use the letters ${\displaystyle f}$ , ${\displaystyle g}$ , and ${\displaystyle h}$ to denote functions, and the variable ${\displaystyle x}$ to denote an independent variable. ${\displaystyle y}$ is used for both dependent and independent variables.

When discussing or working with a function ${\displaystyle f}$ , it's important to know not only the function, but also its independent variable ${\displaystyle x}$ . Thus, when referring to a function ${\displaystyle f}$, you usually do not write ${\displaystyle f}$, but instead ${\displaystyle f(x)}$ . The function is now referred to as "${\displaystyle f}$ of ${\displaystyle x}$". The name of the function is adjacent to the independent variable (in parentheses). This is useful for indicating the value of the function at a particular value of the independent variable. For instance, if

${\displaystyle f(x)=7x+1}$ ,

and if we want to use the value of ${\displaystyle f}$ for ${\displaystyle x}$ equal to ${\displaystyle 2}$ , then we would substitute 2 for ${\displaystyle x}$ on both sides of the definition above and write

${\displaystyle f(2)=7(2)+1=14+1=15}$

This notation is more informative than leaving off the independent variable and writing simply '${\displaystyle f}$' , but can be ambiguous since the parentheses next to ${\displaystyle f}$ can be misinterpreted as multiplication, ${\displaystyle 2f}$. To make sure nobody is too confused, follow this procedure:

1. Define the function ${\displaystyle f}$ by equating it to some expression.
2. Give a sentence like the following: "At ${\displaystyle x=c}$, the function ${\displaystyle f}$ is..."
3. Evaluate the function.

## Modern understanding of functions

The formal definition of a function states that a function is actually a mapping that associates the elements of one set called the domain of the function, ${\displaystyle A}$, with the elements of another set called the range of the function, ${\displaystyle B}$. For each value we select from the domain of the function, there exists exactly one corresponding element in the range of the function. The definition of the function tells us which element in the range corresponds to the element we picked from the domain. An example of how is given below.

 Let function ${\displaystyle f(x)=5x+{\frac {5x}{2}}}$ for all ${\displaystyle x}$. For what value of ${\displaystyle x}$ gives ${\displaystyle f(x)=225{\frac {1}{2}}}$? In mathematics, it is important to notice any repetition. If something seems to repeat, keep a note of that in the back of your mind somewhere. Here, notice that ${\displaystyle f(x)=5x+{\frac {5x}{2}}}$ and ${\displaystyle f(x)=225{\frac {1}{2}}}$. Because ${\displaystyle f(x)}$ is equal to two different things, it must be the case that the other side of the equal sign to ${\displaystyle f(x)}$ is equal to the other. This property is known as the transitive property and could thus make the following equation below true: ${\displaystyle 225{\frac {1}{2}}=5x+{\frac {5x}{2}}}$ Next, simplify — make your life easier rather than harder. In this instance, since ${\displaystyle 5x+{\frac {5x}{2}}}$ has ${\displaystyle x}$ as a like-term, and the two terms are fractions added to the other, put it over a common denominator and simplify. Similar, since ${\displaystyle 225{\frac {1}{2}}}$ is a mixed fraction, ${\displaystyle 225{\frac {1}{2}}=225+{\frac {1}{2}}}$. ${\displaystyle 225{\frac {1}{2}}=5x+{\frac {5x}{2}}}$ ${\displaystyle \Rightarrow {\frac {225}{1}}+{\frac {1}{2}}={\frac {5x}{1}}+{\frac {5x}{2}}}$ ${\displaystyle \Rightarrow {\frac {500}{2}}+{\frac {1}{2}}={\frac {10x}{2}}+{\frac {5x}{2}}}$ ${\displaystyle \Rightarrow {\frac {501}{2}}={\frac {15x}{2}}}$ Multiply both sides by the reciprocal of the coefficient of ${\displaystyle x}$, ${\displaystyle {\frac {2}{15}}}$ from both sides by multiplying by it. ${\displaystyle {\frac {2}{15}}\cdot {\frac {501}{2}}=x}$ ${\displaystyle {\frac {501}{15}}=x}$ or ${\displaystyle x={\frac {501}{15}}}$. The value of ${\displaystyle x}$ that makes ${\displaystyle f(x)=225{\frac {1}{2}}}$ is ${\displaystyle x={\frac {501}{15}}}$.${\displaystyle \blacksquare }$.

Classically, the element picked from the domain is pictured as something that is fed into the function and the corresponding element in the range is pictured as the output. Since we "pick" the element in the domain whose corresponding element in the range we want to find, we have control over what element we pick and hence this element is also known as the "independent variable". The element mapped in the range is beyond our control and is "mapped to" by the function. This element is hence also known as the "dependent variable", for it depends on which independent variable we pick. Since the elementary idea of functions is better understood from the classical viewpoint, we shall use it hereafter. However, it is still important to remember the correct definition of functions at all times.

To make it simple, for the function ${\displaystyle f(x)}$, all of the possible ${\displaystyle x}$ values constitute the domain, and all of the values ${\displaystyle f(x)}$ (${\displaystyle y}$ on the x-y plane) constitute the range. To put it in more formal terms, a function ${\displaystyle f}$ is a mapping of some element ${\displaystyle a\in A}$, called the domain, to exactly one element ${\displaystyle b\in B}$, called the range, such that ${\displaystyle f:A\to B}$. The image below should help explain the modern definition of a function:

From the definitions above, new questions now arise. Here are the three main ones: can a function be (1) one-to-one? (2) many-to-one? (3) one-to-many? Consider each case.

1. A function is considered one-to-one if an element ${\displaystyle a\in A}$ from domain ${\displaystyle A}$ of function ${\displaystyle f}$, leads to exactly one element ${\displaystyle b\in B}$ from range ${\displaystyle B}$ of the function. By definition, since only one element ${\displaystyle b}$ is mapped by function ${\displaystyle f}$ from some element ${\displaystyle a}$, ${\displaystyle f:a\to b}$ implies that there exists only one element ${\displaystyle b}$ from the mapping. Therefore, there exists a one-to-one function because it complies with the definition of a function. This definition is similar to the image at the left of this text.
2. A function is considered many-to-one if some elements ${\displaystyle \left(a_{1},a_{2},\ldots a_{n}\right)\in A}$ from domain ${\displaystyle A}$ of function ${\displaystyle f}$ maps to exactly one element ${\displaystyle b\in B}$ from range ${\displaystyle B}$ of the function. Since some elements ${\displaystyle \left(a_{1},a_{2},\ldots a_{n}\right)\in A}$ must map onto exactly one element ${\displaystyle b\in B}$ or ${\displaystyle f:\left(a_{1},a_{2},\ldots a_{n}\right)\to b}$, the mapping of the function ${\displaystyle f}$ must be compliant with the definition of a function. Therefore, there exists a many-to-one function.
3. A function is considered one-to-many if exactly one element ${\displaystyle a\in A}$ from domain ${\displaystyle A}$ of function ${\displaystyle f}$ maps to some elements ${\displaystyle \left(b_{1},b_{2},\ldots b_{n}\right)\in B}$ from range ${\displaystyle B}$ of the function. If some element ${\displaystyle a}$ maps onto many distinct elements ${\displaystyle b}$ or ${\displaystyle f:a\to \left(b_{1},b_{2},\ldots b_{n}\right)}$, then the mapping of ${\displaystyle f:A\to B}$ is non-functional since there exists many distinct elements ${\displaystyle b}$. Given many-to-one is non-compliant to the definition of a function, there exists no function that is one-to-many.

The modern definition describes a function sufficiently such that it helps us determine whether some new type of "function" is indeed one. Now that each case is defined above, you can now prove whether functions are one of these function cases. Here is an example problem:

 Given: ${\displaystyle f(x)=ax+b}$, where ${\displaystyle a}$ and ${\displaystyle b}$ are constant and ${\displaystyle a\neq 0}$. Prove: function ${\displaystyle f}$ is one-to-one. Notice that the only changing element in the function ${\displaystyle f}$ is ${\displaystyle x}$. To prove a function is one-to-one by applying the definition may be impossible because although two random elements of domain set ${\displaystyle A}$ may not be many-to-one, there may be some elements ${\displaystyle \left(a_{1},a_{2},\ldots a_{n}\right)\in A}$ that may make the function many-to-one. To account for this possibility, we must prove that it is impossible to have some result like that. Assume there exists two distinct elements ${\displaystyle x_{1}}$ and ${\displaystyle x_{2}}$ that will result in ${\displaystyle f\left(x_{1}\right)=f\left(x_{2}\right)}$. This would make the function many-to-one. In consequence, ${\displaystyle ax_{1}+b=ax_{2}+b}$ Subtract ${\displaystyle b}$ from both sides of the equation. ${\displaystyle \Rightarrow ax_{1}=ax_{2}}$ Subtract ${\displaystyle ax_{2}}$ from both sides of the equation. ${\displaystyle \Rightarrow ax_{1}-ax_{2}=0}$ Factor ${\displaystyle a}$ from both terms to the left of the equation. ${\displaystyle \Rightarrow a\left(x_{1}-x_{2}\right)=0}$ Multiply ${\displaystyle {\frac {1}{a}}}$ to both sides of the equation. ${\displaystyle \Rightarrow \left(x_{1}-x_{2}\right)=0}$ Add ${\displaystyle x_{2}}$ to both sides of the equation. ${\displaystyle \Rightarrow x_{1}=x_{2}}$ Notice that ${\displaystyle x_{1}=x_{2}}$. However, this is impossible because ${\displaystyle x_{1}}$ and ${\displaystyle x_{2}}$ are distinct. Ergo, ${\displaystyle f\left(x_{1}\right)\neq f\left(x_{2}\right)}$. No two distinct inputs can give the same output. Therefore, the function must be one-to-one.

There are a few more important ideas to learn from the modern definition of the function, and it comes from knowing the difference between domain, range, and codomain. We already discussed some of these, yet knowing about sets adds a new definition for each of the following ideas. Therefore, let us discuss these based on these new ideas. Let ${\displaystyle A}$ and ${\displaystyle B}$ be a set. If we were to combine these two sets, it would be defined as the cartesian cross product ${\displaystyle A\times B}$. The subset of this product is the function. The below definitions are a little confusing. The best way to interpret these is to draw an image. To the right of these definitions is the image that corresponds to it.

• The domain is defined to be a set ${\displaystyle A}$ with all elements ${\displaystyle a\in A}$ mapping to at least one unique ${\displaystyle b\in B}$.
• The set of elements in ${\displaystyle B}$ is the range of the function mapping ${\displaystyle f:A\to B}$ in the cartesian cross product, whereby the set of all elements ${\displaystyle a\in A}$ maps to some element ${\displaystyle b\in B}$. That is, the range is the set of all elements that was mapped by some ${\displaystyle a\in A}$.
• The codomain is the set ${\displaystyle B}$, where it is not necessarily the case that all elements ${\displaystyle b\in B}$ was mapped by some ${\displaystyle a\in A}$. That is, the set of all elements found in ${\displaystyle B}$ is the codomain.

The abstract concepts can also be made less confusing by using a function that can put these concepts into more concrete terms. Assume there is a function ${\displaystyle f}$ whereby ${\displaystyle x\neq 2}$. Let this function be ${\displaystyle f(x)=2x-1}$ where ${\displaystyle y=f(x)}$. Let us write down what the domain, range, and codomain is for this particular function:

• Domain: ${\displaystyle x\in (-\infty ,2)\cup (2,\infty )}$ or ${\displaystyle \left\{x|x\in \mathbb {R} ,x\neq 2\right\}}$ or simply ${\displaystyle x\neq 2}$. In this instance, the domain is the set of all elements of ${\displaystyle A}$ except ${\displaystyle x=2}$, since this one cannot be mapped to some element in ${\displaystyle B}$.
• Range: ${\displaystyle y\in (-\infty ,3)\cup (3,\infty )}$ or ${\displaystyle \left\{y|y\in \mathbb {R} ,y\neq f(2)\right\}}$ or simply ${\displaystyle y\neq f(2)}$. In this instance, the range is the set of all elements of ${\displaystyle B}$ except ${\displaystyle y=f(2)}$, since this one cannot be mapped by some element in ${\displaystyle A}$.
• Codomain: ${\displaystyle y\in (-\infty ,\infty )}$ or ${\displaystyle \left\{y|y\in \mathbb {R} \right\}}$ or ${\displaystyle y\in \mathbb {R} }$. This includes the one element that we were not allowed to map.

There is one more final aspect that needs to be defined. We already have a good idea of what makes a function a function (e.g. it cannot be many-to-one). However, three more definitions that you will often hear will be necessary to talk about: injective, surjective, bijective.

• A function is injective if it is one-to-one. That is, for ${\displaystyle a_{1}\in A}$ and ${\displaystyle a_{2}\in A}$, if ${\displaystyle f(a_{1})=f(a_{2})}$, then ${\displaystyle a_{1}=a_{2}}$. Otherwise, it cannot be one-to-one. The same definition from before applies for one-to-one still applies (realize that the one here and the one from before are the same).
• A function is surjective if it is "onto." That is, the mapping ${\displaystyle f:A\to B}$ has ${\displaystyle B}$ as the range of the function, where the codomain and the range of the function are the same.
• A function is bijective if it is both surjective and bijective.

Again, the above definitions are often very confusing. Again, another image is provided to the right of the bullet points. Along with that, another example is also provided. Let us analyze the function ${\displaystyle g(x)=ax^{2}}$.

 Given: ${\displaystyle g(x)=ax^{2}}$, where ${\displaystyle a}$ is constant and ${\displaystyle a\neq 0}$. Prove: function ${\displaystyle g}$ is non-surjective and non-injective. Notice that the only changing element in the function ${\displaystyle g}$ is ${\displaystyle x}$. Let us check to see the conditions of this function. Is it injective? Let ${\displaystyle g(x)=y}$, and solve for ${\displaystyle x}$. First, divide by ${\displaystyle a}$. ${\displaystyle y=ax^{2}}$ ${\displaystyle \Rightarrow {\frac {y}{a}}=x^{2}}$ Then take the square root of ${\displaystyle x^{2}}$. By definition, ${\displaystyle {\sqrt {x^{2}}}=\pm {\sqrt {x^{2}}}=\pm x}$, so ${\displaystyle {\frac {y}{a}}=x^{2}}$ ${\displaystyle \Rightarrow \pm {\sqrt {\frac {y}{a}}}=\pm x}$ Notice, however, what we learned from the above manipulation. As a result of solving for ${\displaystyle x}$, we found that there are two solutions for ${\displaystyle x}$. However, this resulted in two different values from ${\displaystyle {\frac {y}{a}}}$. This means that for some individual ${\displaystyle x}$ that gives ${\displaystyle y}$, there are two different inputs that result in the same value. Because ${\displaystyle f(x_{1})=f(x_{2})}$ when ${\displaystyle x_{1}\neq x_{2}}$, this is by definition non-injective. Is it surjective? As a natural consequence of what we learned about inputs, let us determine the range of the function. After all, the only way to determine if something is surjective is to see if the range applies to all real numbers. A good way to determine this is by finding a pattern involving our domains. Let us say we input a negative number for the domain: ${\displaystyle f(-x)=a(-x)^{2}=a\cdot (-x)\cdot (-x)=ax^{2}}$. This seemingly trivial exercise tells us that negative numbers give us non-negative numbers for our range. This is huge information! For ${\displaystyle x\in \mathbb {R} }$, the function always results ${\displaystyle y>0}$ for our range. For the set ${\displaystyle B}$, we have elements in that set that have no mappings from the set ${\displaystyle A}$. As such, ${\displaystyle y\leq 0}$ is the codomain of set ${\displaystyle B}$. Therefore, this function is non-surjective!

Functions are an important foundation of mathematics. This modern interpretation is a result of the hard work of the mathematicians of history. It was not until recently that the definition of the relation was introduced by René Descartes in Geometry (1637). Nearly a century later, the standard notation (${\displaystyle f(x)=y}$) was first introduced by Leonhard Euler in Introductio in Analysin Infinitorum and Institutiones Calculi Differentialis. The term function was also a new innovation during Euler's time as well, being introduced Gottfried Wilhelm Leibniz in a 1673 letter "to describe a quantity related to points of a curve, such as a coordinate or curve's slope." Finally, the modern definition of the function being the relation among sets was first introduced in 1908 by Godfrey Harold Hardy where there is a relation between two variables ${\displaystyle x}$ and ${\displaystyle y}$ such that "to some values of ${\displaystyle x}$ at any rate correspond values of ${\displaystyle y}$." For the person that wants to learn more about the history of the function, this page has been provided for you.

## Remarks

The following arise as a direct consequence of the definition of functions:

1. By definition, for each "input" a function returns only one "output", corresponding to that input. While the same output may correspond to more than one input, one input cannot correspond to more than one output. This is expressed graphically as the vertical line test: a line drawn parallel to the axis of the dependent variable (normally vertical) will intersect the graph of a function only once. However, a line drawn parallel to the axis of the independent variable (normally horizontal) may intersect the graph of a function as many times as it likes. Equivalently, this has an algebraic (or formula-based) interpretation. We can always say if ${\displaystyle a=b}$ , then ${\displaystyle f(a)=f(b)}$ , but if we only know that ${\displaystyle f(a)=f(b)}$ then we can't be sure that ${\displaystyle a=b}$ .
2. Each function has a set of values, the function's domain, which it can accept as input. Perhaps this set is all positive real numbers; perhaps it is the set {pork, mutton, beef}. This set must be implicitly/explicitly defined in the definition of the function. You cannot feed the function an element that isn't in the domain, as the function is not defined for that input element.
3. Each function has a set of values, the function's range, which it can output. This may be the set of real numbers. It may be the set of positive integers or even the set {0,1}. This set, too, must be implicitly/explicitly defined in the definition of the function.
This is an example of an expression which fails the vertical line test.

## The vertical line test

The vertical line test, mentioned in the preceding paragraph, is a systematic test to find out if an equation involving ${\displaystyle x}$ and ${\displaystyle y}$ can serve as a function (with ${\displaystyle x}$ the independent variable and ${\displaystyle y}$ the dependent variable). Simply graph the equation and draw a vertical line through each point of the ${\displaystyle x}$-axis. If any vertical line ever touches the graph at more than one point, then the equation is not a function; if the line always touches at most one point of the graph, then the equation is a function.

(There are a lot of useful curves, like circles, that aren't functions (see picture). Some people call these graphs with multiple intercepts, like our circle, "multi-valued functions"; they would refer to our "functions" as "single-valued functions".)

## Important functions

 Constant function ${\displaystyle f(x)=c}$ It disregards the input and always outputs the constant ${\displaystyle c}$ , and is a polynomial of the zeroth degree where ${\displaystyle f(x)=cx^{0}=c(1)=c}$ . Its graph is a horizontal line. Linear function ${\displaystyle f(x)=mx+c}$ Takes an input, multiplies by ${\displaystyle m}$ and adds ${\displaystyle c}$ . It is a polynomial of the first degree. Its graph is a line (slanted, except ${\displaystyle m=0}$ ). Identity function ${\displaystyle f(x)=x}$ Takes an input and outputs it unchanged. A polynomial of the first degree, ${\displaystyle f(x)=x^{1}=x}$ . Special case of a linear function. Quadratic function ${\displaystyle f(x)=ax^{2}+bx+c}$ A polynomial of the second degree. Its graph is a parabola, unless ${\displaystyle a=0}$ . (Don't worry if you don't know what this is.) Polynomial function ${\displaystyle f(x)=a_{n}x^{n}+a_{n-1}x^{n-1}+\cdots +a_{2}x^{2}+a_{1}x+a_{0}}$ The number ${\displaystyle n}$ is called the degree. Signum function ${\displaystyle {\mbox{sgn}}(x)=\left\{{\begin{matrix}-1&{\text{if}}&x<0\\0&{\text{if}}&x=0\\1&{\text{if}}&x>0\end{matrix}}\right.}$

## Example functions

Some more simple examples of functions have been listed below.

 ${\displaystyle h(x)=\left\{{\begin{matrix}1,&{\mbox{if }}&x>0\\-1,&{\mbox{if }}&x<0\end{matrix}}\right.}$ Gives ${\displaystyle 1}$ if the input is positive or ${\displaystyle -1}$ if the input is negative. Note that the function only accepts negative and positive numbers, not ${\displaystyle 0}$ . Mathematics describes this condition by saying ${\displaystyle 0}$ is not in the domain of the function ${\displaystyle h(x)}$. Under more formal conditions, other notation may be used. For example, ${\displaystyle \left\{x|x\neq 0,\,x\in \mathbb {R} \right\}}$ or ${\displaystyle \left(-\infty ,0\right)\cup \left(0,\infty \right)}$. ${\displaystyle g(y)=y^{2}}$ Takes an input and squares it. ${\displaystyle g(z)=z^{2}}$ Exactly the same function, rewritten with a different independent variable. This is perfectly legal and sometimes done to prevent confusion (e.g. when there are already too many uses of ${\displaystyle x}$ or ${\displaystyle y}$ in the same paragraph.) ${\displaystyle f(x)=\left\{{\begin{matrix}5^{x^{2}},&{\mbox{if }}&x>0\\0,&{\mbox{if }}&x\leq 0\end{matrix}}\right.}$ Note that we can define a function by a totally arbitrary rule. Such functions are called piecewise functions.

It is possible to replace the independent variable with any mathematical expression, not just a number. For instance, if the independent variable is itself a function of another variable, then it could be replaced with that function. This is called composition, and is discussed later.

## Manipulating functions

### Addition, Subtraction, Multiplication and Division of functions

For two real-valued functions, we can add the functions, multiply the functions, raised to a power, etc.

 Example: Adding, subtracting, multiplying and dividing functions which do not have a name If we add the functions ${\displaystyle y=3x+2}$ and ${\displaystyle y=x^{2}}$ , we obtain ${\displaystyle y=x^{2}+3x+2}$ . If we subtract ${\displaystyle y=3x+2}$ from ${\displaystyle y=x^{2}}$ , we obtain ${\displaystyle y=x^{2}-(3x+2)}$ . We can also write this as ${\displaystyle y=x^{2}-3x-2}$ . If we multiply the function ${\displaystyle y=3x+2}$ and the function ${\displaystyle y=x^{2}}$ , we obtain ${\displaystyle y=(3x+2)x^{2}}$ . We can also write this as ${\displaystyle y=3x^{3}+2x^{2}}$ . If we divide the function ${\displaystyle y=3x+2}$ by the function ${\displaystyle y=x^{2}}$ , we obtain ${\displaystyle y={\frac {3x+2}{x^{2}}}}$ .

If a math problem wants you to add two functions ${\displaystyle f}$ and ${\displaystyle g}$ , there are two ways that the problem will likely be worded:

1. If you are told that ${\displaystyle f(x)=3x+2}$ , that ${\displaystyle g(x)=x^{2}}$ , that ${\displaystyle h(x)=f(x)+g(x)}$ and asked about ${\displaystyle h}$ , then you are being asked to add two functions. Your answer would be ${\displaystyle h(x)=x^{2}+3x+2}$ .
2. If you are told that ${\displaystyle f(x)=3x+2}$ , that ${\displaystyle g(x)=x^{2}}$ and you are asked about ${\displaystyle f+g}$ , then you are being asked to add two functions. The addition of ${\displaystyle f}$ and ${\displaystyle g}$ is called ${\displaystyle f+g}$ . Your answer would be ${\displaystyle (f+g)(x)=x^{2}+3x+2}$ .

Similar statements can be made for subtraction, multiplication and division.

 Example: Adding, subtracting, multiplying and dividing functions which do have a name Let ${\displaystyle f(x)=3x+2}$ and: ${\displaystyle g(x)=x^{2}}$ . Let's add, subtract, multiply and divide. {\displaystyle {\begin{aligned}(f+g)(x)&=f(x)+g(x)\\&=(3x+2)+(x^{2})\\&=x^{2}+3x+2\,\end{aligned}}} , {\displaystyle {\begin{aligned}(f-g)(x)&=f(x)-g(x)\\&=(3x+2)-(x^{2})\\&=-x^{2}+3x+2\,\end{aligned}}} , {\displaystyle {\begin{aligned}(f\times g)(x)&=f(x)\times g(x)\\&=(3x+2)\times (x^{2})\\&=3x^{3}+2x^{2}\,\end{aligned}}} , {\displaystyle {\begin{aligned}\left({\frac {f}{g}}\right)(x)&={\frac {f(x)}{g(x)}}\\&={\frac {3x+2}{x^{2}}}\\&={\frac {3}{x}}+{\frac {2}{x^{2}}}\end{aligned}}} .

### Composition of functions

We begin with a fun (and not too complicated) application of composition of functions before we talk about what composition of functions is.

 Example: Dropping a ball If we drop a ball from a bridge which is 20 meters above the ground, then the height of our ball above the earth is a function of time. The physicists tell us that if we measure time in seconds and distance in meters, then the formula for height in terms of time is ${\displaystyle h=-4.9t^{2}+20}$ . Suppose we are tracking the ball with a camera and always want the ball to be in the center of our picture. Suppose we have ${\displaystyle \theta =f(h)}$ The angle will depend upon the height of the ball above the ground and the height above the ground depends upon time. So the angle will depend upon time. This can be written as ${\displaystyle \theta =f(-4.9t^{2}+20)}$ . We replace ${\displaystyle h}$ with what it is equal to. This is the essence of composition.

Composition of functions is another way to combine functions which is different from addition, subtraction, multiplication or division.

The value of a function ${\displaystyle f}$ depends upon the value of another variable ${\displaystyle x}$ ; however, that variable could be equal to another function ${\displaystyle g}$ , so its value depends on the value of a third variable. If this is the case, then the first variable is a function ${\displaystyle h}$ of the third variable; this function (${\displaystyle h}$) is called the composition of the other two functions (${\displaystyle f}$ and ${\displaystyle g}$).

 Example: Composing two functions Let ${\displaystyle f(x)=3x+2}$ and: ${\displaystyle g(x)=x^{2}}$ . The composition of ${\displaystyle f}$ with ${\displaystyle g}$ is read as either "f composed with g" or "f of g of x." Let ${\displaystyle h(x)=f(g(x))}$ Then {\displaystyle {\begin{aligned}h(x)&=f(g(x))\\&=f(x^{2})\\&=3(x^{2})+2\\&=3x^{2}+2\,\end{aligned}}} . Sometimes a math problem asks you compute ${\displaystyle (f\circ g)(x)}$ when they want you to compute ${\displaystyle f(g(x))}$ , Here, ${\displaystyle h}$ is the composition of ${\displaystyle f}$ and ${\displaystyle g}$ and we write ${\displaystyle h=f\circ g}$ . Note that composition is not commutative: ${\displaystyle f(g(x))=3x^{2}+2}$ , and {\displaystyle {\begin{aligned}g(f(x))&=g(3x+2)\\&=(3x+2)^{2}\\&=9x^{2}+12x+4\,.\end{aligned}}} so ${\displaystyle f(g(x))\neq g(f(x))}$ .

Composition of functions is very common, mainly because functions themselves are common. For instance, squaring and sine are both functions:

${\displaystyle {\mbox{square}}(x)=x^{2}}$
${\displaystyle {\mbox{sine}}(x)=\sin(x)}$

Thus, the expression ${\displaystyle \sin ^{2}(x)}$ is a composition of functions:

 ${\displaystyle \sin ^{2}(x)}$ ${\displaystyle ={\mbox{square}}(\sin(x))}$ ${\displaystyle ={\mbox{square}}({\mbox{sine}}(x))}$

(Note that this is not the same as ${\displaystyle {\mbox{sine}}({\mbox{square}}(x))=\sin(x^{2})}$ .) Since the function sine equals ${\displaystyle {\tfrac {1}{2}}}$ if ${\displaystyle x={\frac {\pi }{6}}}$ ,

${\displaystyle {\mbox{square}}\left(\sin \left({\tfrac {\pi }{6}}\right)\right)={\mbox{square}}\left({\tfrac {1}{2}}\right)}$ .

Since the function square equals ${\displaystyle {\frac {1}{4}}}$ if ${\displaystyle x={\frac {\pi }{6}}}$ ,

${\displaystyle \sin ^{2}\left({\tfrac {\pi }{6}}\right)={\mbox{square}}\left(\sin \left({\tfrac {\pi }{6}}\right)\right)={\mbox{square}}\left({\tfrac {1}{2}}\right)={\frac {1}{4}}}$ .

### Transformations

Transformations are a type of function manipulation that are very common. They consist of multiplying, dividing, adding or subtracting constants to either the input or the output. Multiplying by a constant is called dilation and adding a constant is called translation. Here are a few examples:

${\displaystyle f(2\times x)}$ Dilation
${\displaystyle f(x+2)}$ Translation
${\displaystyle 2\times f(x)}$ Dilation
${\displaystyle 2+f(x)}$ Translation
Examples of horizontal and vertical translations
Examples of horizontal and vertical dilations

Translations and dilations can be either horizontal or vertical. Examples of both vertical and horizontal translations can be seen at right. The red graphs represent functions in their 'original' state, the solid blue graphs have been translated (shifted) horizontally, and the dashed graphs have been translated vertically.

Dilations are demonstrated in a similar fashion. The function

${\displaystyle f(2\times x)}$

has had its input doubled. One way to think about this is that now any change in the input will be doubled. If I add one to ${\displaystyle x}$, I add two to the input of ${\displaystyle f}$, so it will now change twice as quickly. Thus, this is a horizontal dilation by ${\displaystyle {\frac {1}{2}}}$ because the distance to the ${\displaystyle y}$-axis has been halved. A vertical dilation, such as

${\displaystyle 2\times f(x)}$

is slightly more straightforward. In this case, you double the output of the function. The output represents the distance from the ${\displaystyle x}$-axis, so in effect, you have made the graph of the function 'taller'. Here are a few basic examples where ${\displaystyle a}$ is any positive constant:

 Original graph ${\displaystyle f(x)}$ Rotation about origin ${\displaystyle -f(-x)}$ Horizontal translation by ${\displaystyle a}$ units left ${\displaystyle f(x+a)}$ Horizontal translation by ${\displaystyle a}$ units right ${\displaystyle f(x-a)}$ Horizontal dilation by a factor of ${\displaystyle a}$ ${\displaystyle f\left(x\times {\tfrac {1}{a}}\right)}$ Vertical dilation by a factor of ${\displaystyle a}$ ${\displaystyle a\times f(x)}$ Vertical translation by ${\displaystyle a}$ units down ${\displaystyle f(x)-a}$ Vertical translation by ${\displaystyle a}$ units up ${\displaystyle f(x)+a}$ Reflection about ${\displaystyle x}$-axis ${\displaystyle -f(x)}$ Reflection about ${\displaystyle y}$-axis ${\displaystyle f(-x)}$

## Domain and Range

### Domain

The domain of the function is the interval from -1 to 1

The domain of a function is the set of all points over which it is defined. More simply, it represents the set of x-values which the function can accept as input. For instance, if

${\displaystyle f(x)={\sqrt {1-x^{2}}}}$

then ${\displaystyle f(x)}$ is only defined for values of ${\displaystyle x}$ between ${\displaystyle -1}$ and ${\displaystyle 1}$, because the square root function is not defined (in real numbers) for negative values. Thus, the domain, in interval notation, is ${\displaystyle [-1,1]}$ . In other words,

${\displaystyle f(x){\mbox{ is defined for }}x\in [-1,1],{\mbox{ or }}\{x:-1\leq x\leq 1\}}$ .
The range of the function is the interval from 0 to 1

### Range

The range of a function is the set of all values which it attains (i.e. the y-values). For instance, if:

${\displaystyle f(x)={\sqrt {1-x^{2}}}}$

then ${\displaystyle f(x)}$ can only equal values in the interval from ${\displaystyle 0}$ to ${\displaystyle 1}$ . Thus, the range of ${\displaystyle f}$ is ${\displaystyle [0,1]}$ .

### One-to-one Functions

A function ${\displaystyle f(x)}$ is one-to-one (or less commonly injective) if, for every value of ${\displaystyle f}$, there is only one value of ${\displaystyle x}$ that corresponds to that value of ${\displaystyle f}$ . For instance, the function ${\displaystyle f(x)={\sqrt {1-x^{2}}}}$ is not one-to-one, because both ${\displaystyle x=1}$ and ${\displaystyle x=-1}$ result in ${\displaystyle f(x)=0}$ . However, the function ${\displaystyle f(x)=x+2}$ is one-to-one, because, for every possible value of ${\displaystyle f(x)}$, there is exactly one corresponding value of ${\displaystyle x}$ . Other examples of one-to-one functions are ${\displaystyle f(x)=x^{3}+ax}$ , where ${\displaystyle a\in [0,\infty )}$ . Note that if you have a one-to-one function and translate or dilate it, it remains one-to-one. (Of course you can't multiply ${\displaystyle x}$ or ${\displaystyle f}$ by a zero factor).

#### Horizontal Line Test

If you know what the graph of a function looks like, it is easy to determine whether or not the function is one-to-one. If every horizontal line intersects the graph in at most one point, then the function is one-to-one. This is known as the Horizontal Line Test.

#### Algebraic 1-1 Test

You can also show one-to-oneness algebraically by assuming that two inputs give the same output and then showing that the two inputs must have been equal. For example, Is ${\displaystyle f(x)={\frac {1-2x}{1+x}}}$ a 1:1 function?

${\displaystyle f(a)=f(b)}$

${\displaystyle {\frac {1-2a}{1+a}}={\frac {1-2b}{1+b}}}$

${\displaystyle (1+b)(1-2a)=(1+a)(1-2b)}$

${\displaystyle 1-2a+b-2ab=1-2b+a-2ab}$

${\displaystyle 1-2a+b=1-2b+a}$

${\displaystyle 1-2a+3b=1+a}$

${\displaystyle 1+3b=1+3a}$

${\displaystyle a=b}$

Therefore by the algebraic 1:1 test, the function ${\displaystyle f(x)}$ is 1:1.

You can show that a function is not one-to-one by finding two distinct inputs that give the same output. For example, ${\displaystyle f(x)=x^{2}}$ is not one-to-one because ${\displaystyle f(-1)=f(1)}$ but ${\displaystyle -1\neq 1}$ .

### Inverse functions

We call ${\displaystyle g(x)}$ the inverse function of ${\displaystyle f(x)}$ if, for all ${\displaystyle x}$ :

${\displaystyle g(f(x))=f(g(x))=x}$

A function ${\displaystyle f(x)}$ has an inverse function if and only if ${\displaystyle f(x)}$ is one-to-one. For example, the inverse of ${\displaystyle f(x)=x+2}$ is ${\displaystyle g(x)=x-2}$ . The function ${\displaystyle f(x)={\sqrt {1-x^{2}}}}$ has no inverse.

#### Notation

The inverse function of ${\displaystyle f}$ is denoted as ${\displaystyle f^{-1}(x)}$ . Thus, ${\displaystyle f^{-1}(x)}$ is defined as the function that follows this rule

${\displaystyle f(f^{-1}(x))=f^{-1}(f(x))=x}$

To determine ${\displaystyle f^{-1}(x)}$ when given a function ${\displaystyle f}$ , substitute ${\displaystyle f^{-1}(x)}$ for ${\displaystyle x}$ and substitute ${\displaystyle x}$ for ${\displaystyle f(x)}$ . Then solve for ${\displaystyle f^{-1}(x)}$ , provided that it is also a function.

Example: Given ${\displaystyle f(x)=2x-7}$ , find ${\displaystyle f^{-1}(x)}$ .

Substitute ${\displaystyle f^{-1}(x)}$ for ${\displaystyle x}$ and substitute ${\displaystyle x}$ for ${\displaystyle f(x)}$ . Then solve for ${\displaystyle f^{-1}(x)}$ :

${\displaystyle f(x)=2x-7}$
${\displaystyle x=2[f^{-1}(x)]-7}$
${\displaystyle x+7=2[f^{-1}(x)]}$
${\displaystyle {\frac {x+7}{2}}=f^{-1}(x)}$

To check your work, confirm that ${\displaystyle f^{-1}(f(x))=x}$ :

${\displaystyle f^{-1}(f(x))=}$

${\displaystyle f^{-1}(2x-7)={}}$

${\displaystyle {\frac {(2x-7)+7}{2}}={\frac {2x}{2}}=x}$

If ${\displaystyle f}$ isn't one-to-one, then, as we said before, it doesn't have an inverse. Then this method will fail.

Example: Given ${\displaystyle f(x)=x^{2}}$ , find ${\displaystyle f^{-1}(x)}$.

Substitute ${\displaystyle f^{-1}(x)}$ for ${\displaystyle x}$ and substitute ${\displaystyle x}$ for ${\displaystyle f(x)}$ . Then solve for ${\displaystyle f^{-1}(x)}$ :

${\displaystyle f(x)=x^{2}}$
${\displaystyle x=(f^{-1}(x))^{2}}$
${\displaystyle f^{-1}(x)=\pm {\sqrt {x}}}$

Since there are two possibilities for ${\displaystyle f^{-1}(x)}$ , it's not a function. Thus ${\displaystyle f(x)=x^{2}}$ doesn't have an inverse. Of course, we could also have found this out from the graph by applying the Horizontal Line Test. It's useful, though, to have lots of ways to solve a problem, since in a specific case some of them might be very difficult while others might be easy. For example, we might only know an algebraic expression for ${\displaystyle f(x)}$ but not a graph.