# 3.1: Functions given by formulas

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Most of the time we will discuss functions that take some real numbers as inputs, and give real numbers as outputs. These functions are commonly described with a formula.

## Example $$\PageIndex{1}$$

For the given function $$f$$, calculate the outputs $$f(2)$$, $$f(-3)$$, and $$f(-1)$$.

1. $$f(x)=3x+4$$
2. $$f(x)=\sqrt{x^2-3}$$
3. $$f(x)=\left\{\begin{array}{cl} 5 x-6 & , \text { for } \quad-1 \leq x \leq 1 \\ x^{3}+2 x & , \text { for } \quad 1<x \leq 5 \end{array}\right.$$
4. $$f(x)=\dfrac{x+2}{x+3}$$

Solution

We substitute the input values into the function and simplify.

1. \begin{aligned} f(2) &=3 \cdot 2+4=6+4=10 \\ f(-3) &=3 \cdot(-3)+4=-9+4=-5 \\ f(-1) &=3 \cdot(-1)+4=-3+4=1 \end{aligned} \nonumber
2. Similarly, we calculate \begin{aligned} f(2) &=\sqrt{2^{2}-3}=\sqrt{4-3}=\sqrt{1}=1 \\ f(-3) &=\sqrt{(-3)^{2}-3}=\sqrt{9-3}=\sqrt{6} \\ f(-1) &=\sqrt{(-1)^{2}-3}=\sqrt{1-3}=\sqrt{-2}=\text { undefined } \end{aligned} \nonumber For the last step, we are assuming that we only deal with real numbers. Of course, as we will see later on, $$\sqrt{-2}$$ can be defined as a complex number. But for now, we will only allow real solutions outputs.
3. The function $$f(x)=\left\{\begin{array}{cl} 5 x-6 & , \text { for } \quad-1 \leq x \leq 1 \\ x^{3}+2 x & , \text { for } \quad 1<x \leq 5 \end{array}\right.$$ is given as a piecewise defined function. We have to substitute the values into the correct branch: \begin{aligned} f(2) &=2^{3}+2 \cdot 2=8+4=12, \text { since } 1<2 \leq 5 \\ f(-3) &=\text { undefined, since }-3 \text { is not in any of the two branches } \\ f(-1) &=5 \cdot(-1)-7=-5-6=-11 \text{, since } -1 \leq-1 \leq 1 \end{aligned} \nonumber
4. Finally for $$f(x)=\dfrac{x+2}{x+3}$$, we have: \begin{aligned} f(2) &=\dfrac{2+2}{2+3}=\dfrac{4}{5} \\ f(-3) &=\dfrac{-3+2}{-3+3}=\dfrac{-1}{0}=\text { undefined } \\ f(-1) &=\dfrac{-1+2}{-1+3}=\dfrac{1}{2} \end{aligned} \nonumber

## Example $$\PageIndex{2}$$

Let $$f$$ be the function given by $$f(x)=x^2+2x-3$$. Find the following function values.

1. $$f(5)$$
2. $$f(2)$$
3. $$f(-2)$$
4. $$f(0)$$
5. $$f(\sqrt{5})$$
6. $$f(\sqrt{3}+1)$$
7. $$f(a)$$
8. $$f(a)+5$$
9. $$f(x+h)$$
10. $$f(x+h)-f(x)$$
11. $$\dfrac {f(x+h)-f(x)}{h}$$
12. $$\dfrac{f(x)-f(a)}{x-a}$$

Solution

The first four function values ((a)-(d)) can be calculated directly:

1. $$f(5)=5^{2}+2 \cdot 5-3=25+10-3=32$$
2. $$f(2)=2^{2}+2 \cdot 2-3=4+4-3=5$$
3. $$f(-2)=(-2)^{2}+2 \cdot(-2)-3=4+-4-3=-3$$
4. $$f(0)=0^{2}+2 \cdot 0-3=0+0-3=-3$$

The next two values ((e) and (f)) are similar, but the arithmetic is a bit more involved.

1. $$f(\sqrt{5})=\sqrt{5}^{2}+2 \cdot \sqrt{5}-3=5+2 \cdot \sqrt{5}-3=2+2 \cdot \sqrt{5}$$
1. \begin{aligned} f(\sqrt{3}+1) &=(\sqrt{3}+1)^{2}+2 \cdot(\sqrt{3}+1)-3 \\ &=(\sqrt{3}+1) \cdot(\sqrt{3}+1)+2 \cdot(\sqrt{3}+1)-3 \\ &=\sqrt{3} \cdot \sqrt{3}+2 \cdot \sqrt{3}+1 \cdot 1+2 \cdot \sqrt{3}+2-3 \\ &=3+2 \cdot \sqrt{3}+1+2 \cdot \sqrt{3}+2-3 \\ &=3+4 \cdot \sqrt{3} \end{aligned}

The last five values ((g)-(l)) are purely algebraic.

1. $$f(a)=a^{2}+2 \cdot a-3$$
2. $$f(a)+5=a^{2}+2 \cdot a-3+5=a^{2}+2 \cdot a+2$$
1. \begin{aligned} f(x+h) &=(x+h)^{2}+2 \cdot(x+h)-3 \\ &=x^{2}+2 x h+h^{2}+2 x+2 h-3 \end{aligned}
1. \begin{aligned} f(x+h)-f(x) &=\left(x^{2}+2 x h+h^{2}+2 x+2 h-3\right)-\left(x^{2}+2 x-3\right) \\ &=x^{2}+2 x h+h^{2}+2 x+2 h-3-x^{2}-2 x+3 \\ &=2 x h+h^{2}+2 h \end{aligned}
1. \begin{aligned} \dfrac{f(x+h)-f(x)}{h} &=\dfrac{2 x h+h^{2}+2 h}{h} \\ &=\dfrac{h \cdot(2 x+h+2)}{h}\\ &=2 x+h+2 \end{aligned}
1. \begin{aligned} \dfrac{f(x)-f(a)}{x-a} &=\dfrac{\left(x^{2}+2 x-3\right)-\left(a^{2}+2 a-3\right)}{x-a} \\ &=\dfrac{x^{2}+2 x-3-a^{2}-2 a+3}{x-a}=\dfrac{x^{2}-a^{2}+2 x-2 a}{x-a} \\ &= \dfrac{(x+a)(x-a)+2(x-a)}{x-a}=\dfrac{(x-a)(x+a+2)}{(x-a)}=x+a+2 \end{aligned}

The quotients $$\dfrac{f(x+h)-f(x)} h$$ and $$\dfrac{f(x)-f(a)}{x-a}$$ as in the last two examples Example $$\PageIndex{2}$$ (k) and (l) will become particularly important in calculus. They are called difference quotients. We now calculate some more examples of difference quotients.

## Example $$\PageIndex{3}$$

Calculate the difference quotient $$\dfrac{f(x+h)-f(x)}h$$ for

1. $$f(x)=x^3+2$$
2. $$f(x)=\dfrac 1 x$$

Solution

We calculate first the difference quotient step by step.

1. \begin{aligned} f(x+h)&=(x+h)^3+2 =(x+h)\cdot (x+h)\cdot (x+h)+2\\ & = (x^2+2xh+h^2)\cdot (x+h)+2\\ & = x^3+2x^2h+xh^2+x^2h+2xh^2+h^3+2\\ & = x^3+3x^2h+3xh^2+h^3+2\end{aligned} \nonumber

Subtracting $$f(x)$$ from $$f(x+h)$$ gives

\begin{aligned} f(x+h)-f(x)&= (x^3+3x^2h+3xh^2+h^3+2)-(x^3+2)\\ &=x^3+3x^2h+3xh^2+h^3+2-x^3-2\\ &=3x^2h+3xh^2+h^3\end{aligned} \nonumber

With this we obtain:

\begin{aligned} \dfrac{f(x+h)-f(x)}{h}&=\dfrac{3x^2h+3xh^2+h^3} h\\ &= \dfrac{h\cdot (3x^2+3xh+h^2)} h=3x^2+3xh+h^2\end{aligned} \nonumber

We handle part (b) similarly.

1. $f(x+h)=\dfrac{1}{x+h} \nonumber$

so that

$f(x+h)-f(x)= \dfrac 1 {x+h} - \dfrac 1 x \nonumber$

We obtain the solution after simplifying the double fraction:

\begin{aligned} \dfrac{f(x+h)-f(x)} h&= \dfrac{\frac{1}{x+h}-\frac{1}{x}}{h}=\dfrac{\frac{x-(x+h)}{(x+h)\cdot x}}{h}=\dfrac{\frac{x-x-h}{(x+h)\cdot x}}{h}=\dfrac{\frac{-h}{(x+h)\cdot x}}{h}\\ &= \dfrac{-h}{(x+h)\cdot x}\cdot \dfrac 1 h = \dfrac{-1}{(x+h)\cdot x}\end{aligned} \nonumber

So far, we have not mentioned the domain and range of the functions defined above. Indeed, we will often not describe the domain explicitly but use the following convention.

## Definition: Convention

Unless otherwise stated, a function $$f$$ has the largest possible domain, that is the domain is the set of all real numbers $$x$$ for which $$f(x)$$ is a well-defined real number. We refer to this as the standard convention of the domain. (In particular, under this convention, any polynomial has the domain $$\mathbb{R}$$ of all real numbers.)

The range is the set of all outputs obtained by $$f$$ from the inputs (see also the warning.)

## Example $$\PageIndex{4}$$

Find the domain of each of the following functions.

1. $$f(x)=4x^3-2x+5$$
2. $$f(x)=|x|$$
3. $$f(x)=\sqrt{x}$$
4. $$f(x)=\sqrt{x-3}$$
5. $$f(x)=\dfrac 1 x$$
6. $$f(x)=\dfrac{x-2}{x^2+8x+15}$$
7. $$f(x)=\left\{\begin{array}{cl} x+1 & , \text { for } 2<x \leq 4 \\ 2 x-1 & \text {, for } 5 \leq x \end{array}\right.$$

Solution

1. There is no problem taking a real number $$x$$ to any (positive) power. Therefore, $$f$$ is defined for all real numbers $$x$$, and the domain is written as $$D=\mathbb{R}$$.
2. Again, we can take the absolute value for any real number $$x$$. The domain is all real numbers, $$D=\mathbb{R}$$.
3. The square root $$\sqrt{x}$$ is only defined for $$x\geq 0$$ (remember we are not using complex numbers yet!). Thus, the domain is $$D=[0,\infty)$$.
4. Again, the square root is only defined for non-negative numbers. Thus, the argument in the square root has to be greater or equal to zero: $$x-3\geq 0$$. Solving this for $$x$$ gives

$x-3\geq 0 \quad\quad \stackrel {\text{(add 3)}}\implies \quad\quad x\geq 3 \nonumber$

The domain is therefore, $$D=[3,\infty)$$.

5. A fraction is defined whenever the denominator is not zero, so that in this case $$\dfrac 1 x$$ is defined whenever $$x\neq 0$$. Therefore the domain is all real numbers except zero, $$D=\mathbb{R}-\{0\}$$.
6. Again, we need to make sure that the denominator does not become zero; however we do not care about the numerator. The denominator is zero exactly when $$x^2+8x+15=0$$. Solving this for $$x$$ gives:

\begin{aligned} x^2+8x+15=0 & \implies & (x+3)\cdot(x+5)=0 \\ & \implies & x+3=0 \text{ or } x+5=0 \\ & \implies & x=-3 \text{ or } x=-5.\end{aligned} \nonumber

The domain is all real numbers except for $$-3$$ and $$-5$$, that is $$D=\mathbb{R}-\{-5,-3\}$$.

7. The function is explicitly defined for all $$2<x\leq 4$$ and $$5\leq x$$. Therefore, the domain is $$D=(2,4]\cup [5,\infty)$$.

This page titled 3.1: Functions given by formulas is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Thomas Tradler and Holly Carley (New York City College of Technology at CUNY Academic Works) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.