Skip to main content

Section 2.1 All About Functions

A function \(y=f(x)\) is a rule for determining \(y\) when we're given a value of \(x\text{.}\) For example, the rule \(y=f(x)=2x+1\) is a function. Any line \(y=mx+b\) is called a linear function. The graph of a function looks like a curve above (or below) the \(x\)-axis, where for any value of \(x\) the rule \(y=f(x)\) tells us how far to go above (or below) the \(x\)-axis to reach the curve.

Functions can be defined in various ways: by an algebraic formula or several algebraic formulas, by a graph, or by an experimentally determined table of values. In the latter case, the table gives a bunch of points in the plane, which we might then interpolate with a smooth curve, if that makes sense.

Given a value of \(x\text{,}\) a function must give at most one value of \(y\text{.}\) Thus, vertical lines are not functions. For example, the line \(x=1\) has infinitely many values of \(y\) if \(x=1\text{.}\) It is also true that if \(x\) is any number (not 1) there is no \(y\) which corresponds to \(x\text{,}\) but that is not a problem—only multiple \(y\) values is a problem.

One test to identify whether or not a curve in the \((x,y)\) coordinate system is a function is the following.

In addition to lines, another familiar example of a function is the parabola \(y=f(x)=x^2\text{.}\) We can draw the graph of this function by taking various values of \(x\) (say, at regular intervals) and plotting the points \((x,f(x))=(x,x^2)\text{.}\) Then connect the points with a smooth curve.

The two examples \(y=f(x)=2x+1\) and \(y=f(x)=x^2\) are both functions which can be evaluated at any value of \(x\) from negative infinity to positive infinity. For many functions, however, it only makes sense to take \(x\) in some interval or outside of some “forbidden” region. The interval of \(x\)-values at which we're allowed to evaluate the function is called the domain of the function.

(a) \(f(x) = x^2 \)
(b) \(f(x)=\sqrt{x}\)
(c) \(f(x)=\frac{1}{x}\)
Figure 2.1. Graphs of functions.
Example 2.2. Domain of the Square-Root Function.

The square-root function \(y=f(x)=\sqrt{x}\) is the rule which says, given an \(x\)-value, take the nonnegative number whose square is \(x\text{.}\) This rule only makes sense if \(x\ge 0\text{.}\) We say that the domain of this function is \(x\ge 0\text{,}\) or more formally \(\left\{x\in\mathbb{R}\,:\,x\ge 0\right\}\text{.}\) Alternately, we can use interval notation, and write that the domain is \([0,\infty)\text{.}\) The fact that the domain of \(y=\sqrt{x}\) is \([0,\infty)\) means that in the graph of this function (see Figure 2.(b)) we have points \((x,y)\) only above \(x\)-values on the right side of the \(x\)-axis.

Another example of a function whose domain is not the entire \(x\)-axis is: \(y=f(x)=1/x\text{,}\) the reciprocal function. We cannot substitute \(x=0\) in this formula. The function makes sense, however, for any nonzero \(x\text{,}\) so we take the domain to be: \(\{x\in\mathbb{R}\,:\,x\ne 0\}\text{.}\) The graph of this function does not have any point \((x,y)\) with \(x=0\text{.}\) As \(x\) gets close to 0 from either side, the graph goes off toward infinity. We call the vertical line \(x=0\) an asymptote.

To summarize, two reasons why certain \(x\)-values are excluded from the domain of a function are the following.

Restrictions for the Domain of a Function.
  1. We cannot divide by zero, and

  2. We cannot take the square root of a negative number.

When the domain of a function is restricted, we say that the function is undefined at that point. We will encounter some other ways in which functions might be undefined later.

Another reason why the domain of a function might be restricted is that in a given situation the \(x\)-values outside of some range might have no practical meaning. For example, if \(y\) is the area of a square of side \(x\text{,}\) then we can write \(y=f(x)=x^2\text{.}\) In a purely mathematical context the domain of the function \(y=x^2\) is all of \(\mathbb{R}\text{.}\) However, in the story-problem context of finding areas of squares, we restrict the domain to positive values of \(x\text{,}\) because a square with negative or zero side makes no sense.

In a problem in pure mathematics, we usually take the domain to be all values of \(x\) at which the formulas can be evaluated. However, in a story problem there might be further restrictions on the domain because only certain values of \(x\) are of interest or make practical sense.

In a story problem, we often use letters other than \(x\) and \(y\text{.}\) For example, the volume \(V\) of a sphere is a function of the radius \(r\text{,}\) given by the formula \(V=f(r)=\frac{4}{3}\pi r^3\text{.}\) Also, letters different from \(f\) may be used. For example, if \(y\) is the velocity of something at time \(t\text{,}\) we may write \(y=v(t)\) with the letter \(v\) (instead of \(f\)) standing for the velocity function (and \(t\) playing the role of \(x\)).

The letter playing the role of \(x\) is called the independent variable, and the letter playing the role of \(y\) is called the dependent variable (because its value “depends on” the value of the independent variable). In story problems, when one has to translate from English into mathematics, a crucial step is to determine what letters stand for variables. If only words and no letters are given, then we have to decide which letters to use. Some letters are traditional. For example, almost always, \(t\) stands for time.

Example 2.3. Open Box.

An open-top box is made from an \(a\times b\) rectangular piece of cardboard by cutting out a square of side \(x\) from each of the four corners, and then folding the sides up and sealing them with duct tape. Find a formula for the volume \(V\) of the box as a function of \(x\text{,}\) and find the domain of this function.


The box we get will have height \(x\) and rectangular base of dimensions \(a-2x\) by \(b-2x\text{.}\) Thus,

\begin{equation*} V=f(x)=x(a-2x)(b-2x)\text{.} \end{equation*}

Here \(a\) and \(b\) are constants, and \(V\) is the variable that depends on \(x\text{,}\) i.e., \(V\) is playing the role of \(y\text{.}\)

This formula makes mathematical sense for any \(x\text{,}\) but in the story problem the domain is much less. In the first place, \(x\) must be positive. In the second place, it must be less than half the length of either of the sides of the cardboard. Thus, the domain is

\begin{equation*} \left\{x\in\mathbb{R}\,:\,0\lt x\lt {\frac{1}{2}}(\hbox{minimum of \(a\) and \(b\)})\right\}\text{.} \end{equation*}

In interval notation we write: the domain is the interval \((0,\min(a,b)/2)\text{.}\) You might think about whether we could allow 0 or (the minimum of \(a\) and \(b \)) to be in the domain. They make a certain physical sense, though we normally would not call the result a box. If we were to allow these values, what would the corresponding volumes be? Does that volume make sense?

Example 2.4. Circle of Radius \(r\) Centered at the Origin.

Is the circle of radius \(r\) centered at the origin the graph of a function?


The equation for this circle is usually given in the form \(x^2+y^2=r^2\text{.}\) To write the equation in the form \(y=f(x)\) we solve for \(y\text{,}\) obtaining \(y=\pm\sqrt{r^2-x^2}\text{.}\) But this is not a function, because when we substitute a value in the interval \((-r,r)\) for \(x\) there are two corresponding values of \(y\text{.}\) To get a function, we must choose one of the two signs in front of the square root. If we choose the positive sign, for example, we get the upper semicircle \(y=f(x)=\sqrt{r^2- x^2}\) (see graph below). The domain of this function is the interval \([-r,r]\text{,}\) i.e., \(x\) must be between \(-r\) and \(r\) (including the endpoints). If \(x\) is outside of that interval, then \(r^2-x^2\) is negative, and we cannot take the square root. In terms of the graph, this just means that there are no points on the curve whose \(x\)-coordinate is greater than \(r\) or less than \(-r\text{.}\)

Example 2.5. Domain.

Find the domain of

\begin{equation*} y=f(x)={\frac{1}{\sqrt{4x-x^2}}}\text{.} \end{equation*}

To answer this question, we must rule out the \(x\)-values that make \(4x-x^2\) negative (because we cannot take the square root of a negative number) and also the \(x\)-values that make \(4x-x^2\) zero (because if \(4x-x^2=0\text{,}\) then when we take the square root we get 0, and we cannot divide by 0). In other words, the domain consists of all \(x\) for which \(4x-x^2\) is strictly positive. The inequality \(4x-x^2>0\) was solved in Example 1.12. In interval notation, the domain is the interval \((0,4)\text{.}\)

A function does not always have to be given by a single formula as the next example demonstrates.

Example 2.6. Piecewise Velocity.

Suppose that \(y=v(t)\) is the velocity function for a car which starts out from rest (zero velocity) at time \(t=0\text{;}\) then increases its speed steadily to 20 m/sec, taking 10 seconds to do this; then travels at constant speed 20 m/sec for 15 seconds; and finally applies the brakes to decrease speed steadily to 0, taking 5 seconds to do this. The formula for \(y=v(t)\) is different in each of the three time intervals: first \(y=2x\text{,}\) then \(y=20\text{,}\) then \(y=-4x+120\text{.}\) The graph of this function is shown below:

This example leads to the following definition of a piecewise defined function.

Definition 2.7. Piecewise Defined Function.

A piecewise defined function \(f\) is defined by more than one rule:

\begin{equation*} f(x) = \begin{cases} f_{1}(x) \amp x \in \mathcal{D}_{f_{1}}\\ f_{2}(x) \amp x \in \mathcal{D}_{f_{2}}\\ \vdots \\ f_{n}(x) \amp x \in \mathcal{D}_{f_{n}} \end{cases} \end{equation*}

where \(\mathcal{D}_{f_{i}}\text{,}\) \(1 \leq i \leq n\text{,}\) are mutually exclusive domains.

Example 2.8. Piecewise Defined Function.

Sketch the graph of the function \(f\) defined by

\begin{equation*} f(x) = \begin{cases} -x \amp x \lt 0\\ \sqrt{x} \amp x \geq 0 \end{cases} \end{equation*}

The function \(f\) is defined in a piecewise fashion on the set of all real numbers. In the subdomain \(\left(-\infty ,0\right)\text{,}\) the rule for \(f\) is given by \(f(x) = -x\text{.}\) The equation \(y = -x\) is a linear equation in the slope-intercept form (with slope \(-1\) and intercept \(0\)).

Next, in the subdomain \(\left[0,\infty\right)\text{,}\) the rule for \(f\) is given by \(f(x) = \sqrt{x}\text{.}\) The values of \(f(x)\) corresponding to \(x = 0,1,2,3,4,9,16\) are shown in the following table:

\begin{equation*} \begin{array}{l|ccccccc} x \amp 0 \amp 1 \amp 2 \amp 3 \amp 4 \amp 9\amp 16 \\ \hline f(x) \amp 0 \amp 1 \amp \sqrt{2} \amp \sqrt{3} \amp 2 \amp 3 \amp 4 \end{array} \end{equation*}

Using these values, we sketch the graph of the function \(f\) as shown in below.

Our focus in this textbook will be on elementary functions . Examples of elementary functions include both algebraic functions, such as polynomials, rational functions, and powers, and transcendental functions, such as exponential, logarithmic, and trigonometric functions.

Exercises for Section 2.1.

Find the domain of each of the following functions:

  1. \(\ds y=x^2+1\)

    \(\ds \{x\mid x\in \R\}\)
  2. \(\ds y=f(x)=\sqrt{2x-3}\)

    \(\ds \{x\mid x\ge 3/2\}\)
    We need \(2x-3 \geq 0\text{.}\) The domain is thus \(\left[\frac{3}{2}, \infty\right)\text{.}\)
  3. \(\ds y=f(x)=1/(x+1)\)

    \(\ds \{x\mid x\not=-1\}\)
    Since we cannot have denominator equal to \(0\text{,}\) \(x \neq -1\text{.}\)
  4. \(\ds y=f(x)=1/(x^2-1)\)

    \(\ds \{x\mid x\not=1 \hbox{ and } x\not=-1\}\)
  5. \(\ds y=f(x)=\sqrt{-1/x}\)

    \(\ds \{x\mid x\lt 0\}\)
  6. \(\ds y=f(x)={\root 3 \of x}\)

    \(\ds \{x\mid x\in \R\}\)
    Unlike the square root, there are no domain restrictions here, since any negative number can be cube-rooted.
  7. \(\ds y=f(x)=\sqrt{r^2-(x-h)^2}\text{,}\) where \(r\) and \(h\) are positive constants.

    \(\ds \{x\mid h-r\le x\le h+r\}\)
  8. \(\ds y=f(x) = {\root 4 \of x}\)

    \(\ds \{x\mid x\ge0\}\)
  9. \(\ds y=\sqrt{1-x^2}\)

    \(\ds \{x\mid -1\le x\le 1\}\)

    The domain of \(y = \sqrt{1-x^2}\) is all \(x \in \mathbb{R}\) such that:

    \begin{equation*} \begin{gathered} 1-x^2 \geq 0 \\ x^2 \leq 1 \\ -1 \leq x \leq 1 \end{gathered} \end{equation*}

    Thus, the domain is \([-1,1]\text{.}\)

  10. \(\ds y=f(x)=\sqrt{1-(1/x)}\)

    \(\ds \{x\mid x\ge 1\}\)
  11. \(\ds y=f(x)=1/\sqrt{1-(3x)^2}\)

    \(\ds \{x\mid -1/3\lt x\lt 1/3\}\)
  12. \(\ds y=f(x)=\sqrt{x}+1/(x-1)\)

    \(\ds \{x\mid x\ge0 \hbox{ and } x\not=1\}\)
  13. \(\ds y=f(x)=1/(\sqrt{x}-1)\)

    \(\ds \{x\mid x\ge0 \hbox{ and } x\not=1\}\)

    The domain of \(f(x) = \frac{1}{\sqrt{x}-1}\) is the set of all \(x \in \mathbb{R}\) which satisfy the two conditions: \(\sqrt{x} \neq 1\text{,}\) and \(x \geq 0\text{.}\) Therefore, the domain is \([0,1) \cup (1,\infty)\text{.}\)

A farmer wants to build a fence along a river. He has 500 feet of fencing and wants to enclose a rectangular pen on three sides (with the river providing the fourth side). If \(x\) is the length of the side perpendicular to the river, determine the area of the pen as a function of \(x\text{.}\) What is the domain of this function?

\(A=x(500-2x)\text{,}\) \(\ds \{x\mid 0\le x\le 250\}\)

Let \(x\) be the length of fence along the side perpendicular to the river, and let \(y\) be the length of fence parallel to the river:

The total length of fencing is then \(x + x + y = 500\text{,}\) and so we must have that \(y = 500 - 2x\text{.}\) If we approximate the river by a straight line, the area enclosed by the fence and river can be given as a function of \(x\text{:}\)

\begin{equation*} A(x) = xy = x(500-2x)\text{.} \end{equation*}

Both the side length \(x\) and the total area \(A\) must be non-negative. Therefore, the domain of \(A\) will be all \(x \in \mathbb{R}\) such that \(x > 0\) and \(A(x) > 0 \implies 500 - 2x \geq 0 \implies x \leq 250\text{.}\) Hence, the domain is \((0, 250)\text{.}\)

A can in the shape of a cylinder is to be made with a total of 100 square centimetres of material in the side, top, and bottom; the manufacturer wants the can to hold the maximum possible volume. Write the volume as a function of the radius \(r\) of the can; find the domain of the function.

\(\ds V=r(50-\pi r^2)\text{,}\) \(\ds \{r\mid 0\lt r\le \sqrt{50/\pi}\}\)

You are given \(100\) cm\(^{2}\) of material with which to build a cylinder. Let \(r, h, V\) be the radius, height and volume (respectively) of the object. The material must cover the entire surface area,

\begin{equation*} 100 = 2\pi r h + 2\pi r^{2} \end{equation*}

Eventually, we want a formula for the volume of the can as a function of \(r\text{,}\) so let's write \(h\) as a function of \(r\text{:}\)

\begin{equation*} h(r) = \dfrac{100}{2\pi r} - r\text{,} \end{equation*}

assuming that \(r \neq 0\) (note that this would be an uninteresting case). The volume of the cyclinder can now be expressed as a function of \(r\text{,}\)

\begin{equation*} \begin{split} V(r) \amp = \pi r^{2}h(r) \\ \amp = \pi r^{2} \left( \dfrac{100}{2\pi r} - r \right) \\ \amp = r \left(50 - \pi r^{2}\right). \end{split} \end{equation*}

\(r\) and \(V\) both represent positive physical quantities, which, together with the assumption that \(r \neq 0\text{,}\) gives the domain \(0 \lt r \leq \sqrt{\frac{50}{\pi}}\text{.}\)

A can in the shape of a cylinder is to be made to hold a volume of one liter (1000 cubic centimetres). The manufacturer wants to use the least possible material for the can. Write the surface area of the can (total of the top, bottom, and side) as a function of the radius \(r\) of the can; find the domain of the function.

\(\ds A=2\pi r^2+2000/r\text{,}\) and \(\ds \{r\mid 0\lt r\lt \infty\}\)

Let \(f\) be the function defined by

\begin{equation*} f(x) = \begin{cases} -\frac{1}{2}x^{2}+3 \amp x \lt 1\\ 2x^{2}+1 \amp x \geq 1 \end{cases} \end{equation*}

Find \(f(-1)\text{,}\) \(f(0)\text{,}\) \(f(1)\text{,}\) and \(f(2)\text{.}\)

\(\frac{5}{2}\text{,}\) \(3\text{,}\) \(3\text{,}\) \(9\text{.}\)

For each of the following functions, sketch the graph and find the domain and range.

  1. \(f(x) = \begin{cases} x \amp x \lt 0\\ 2x+1 \amp x \geq 0 \end{cases}\)


    Domain is \(\left(-\infty ,\infty\right)\text{.}\) Range is \(\left(-\infty ,0\right) \cup \left[-\infty ,\infty\right)\text{.}\)

  2. \(f(x) = \begin{cases} -x+1 \amp x \leq 1\\ x^{2}-1 \amp x > 1 \end{cases}\)


    Domain is \(\left(-\infty , \infty\right)\text{.}\) Range is \(\left[0 , \infty\right)\text{.}\)

In \(2006\text{,}\) the Canadian postage for domestic lettermail was $\(0.51\) for the first \(30\) grams or a fraction thereof, $\(0.89\) over \(30\)g and up to \(50\)g, $\(1.05\) over \(50\)g and up to \(100\)g, $\(1.78\) over \(100\)g and up to \(200\)g, and $\(2.49\) over \(200\)g and up to \(500\)g. Any lettermail not exceeding $\(500\)g may be sent by domestic mail. Letting \(x\) denote the weight of a parcel in grams and \(f(x)\) the postage in dollars, complete the following description of the "lettermail function" \(f\text{:}\)

\begin{equation*} f(x) = \begin{cases} 0.51 \amp 0 \lt x \leq 30\\ \vdots \\ 2.49 \amp 200 \lt x \leq 500 \end{cases} \end{equation*}

Sketch the graph of \(f\) and state the domain.

\begin{equation*} f(x) = \begin{cases} 0.51 \amp 0 \lt x \leq 30\\ 0.89 \amp 30 \lt x \leq 50 \\ 1.05 \amp 50 \lt x \leq 100 \\ 1.78 \amp 100 \lt x \leq 200 \\ 2.49 \amp 200 \lt x \leq 500 \end{cases} \end{equation*}

\(x \in \left[0,500\right]\text{.}\)