# Introduction to functions

A function is an expression of the form $$$ \Tred{y} = 2\Tblue{x}+5.$$$ It relates an **input** $$\Tblue{x}$$ to an **output** $$\Tred{y}$$. We sometimes write $$y$$ as $$\Tred{f}(x)$$ to show the dependency with $$x$$. Formally, the function is $$\Tred{f}$$.

The value of the function $$\Tred{y} = 2\Tblue{x}+5$$ for the input $$\Tgreen{4}$$ is $$$ \Tred{y} = 2\times \Tgreen{4} + 5 = 13.$$$

The input can be any number. It is represented by a letter, called the variable. The letter is generally $$\Tblue{x}$$, but it can be anything.

The functions $$\Tred{y}= \Tblue{t}^2$$ and $$\Tred{y} = \Tblue{x}^2$$ are the same, because the letters for the variable and for the function don't matter.

The function $$\Tred{y} = 2 \Tblue{x} -3$$ can be represented by a **table** for several inputs.

$$$x$$$ | $$$-2$$$ | $$$-1$$$ | $$$0$$$ | $$$1$$$ | $$$2$$$ | $$$3$$$ | $$$4$$$ |
---|---|---|---|---|---|---|---|

$$$y$$$ | $$$-7$$$ | $$$-5$$$ | $$$-3$$$ | $$$-1$$$ | $$$1$$$ | $$$3$$$ | $$$5$$$ |

A simple way to represent a function is by drawing its graph. For each **input** $$\Tblue{x}$$ on the horizontal axis, called the $$x$$-axis, we plot the corresponding **output** $$\Torange{y}$$ are on the vertical axis, called the $$y$$-axis.

The graph is a two-dimensional representation of the input / output table associated with a function.

x | -2 | -1 | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|---|---|

y | -7 | -5 | -3 | -1 | 1 | 3 | 5 |

A function is constant if it only ever takes one value. Any input is mapped to the same number by the function. Constant functions are of the form $$$y = \Tblue{a}$$$ where $$\Tblue{a}$$ is a fixed number.

The function $$y=\Tblue{-2}$$ and the function $$z = \Tblue{0}$$ are both constant functions.

The function $$y = 2 x$$ is not constant because it takes different values. For example, $$y=0$$ for $$x = 0$$ and $$y=2$$ for $$x=1$$.

The graph of a constant function is a **horizontal straight line**.

A linear function has a straight line as its graph. Linear functions take the form $$$y = \Tgreen{a} x + \Tblue{b}$$$ for two numbers $$\Tgreen{a}$$ and $$\Tblue{b}$$.

All constant functions are linear ($$\Tgreen{a}=0$$).

$$y = \Tgreen{-2}x +\Tblue{2}$$ is not constant, but it is linear.

Functions such as $$y = x^2$$ are not linear.

The number $$\Tblue{b}$$ is the value of the function at $$x=0$$. It is the intercept with the $$y$$-axis.

The number $$\Tgreen{a}$$ is the gradient of the function, or slope. For any two arbitrary values $$x_1\ne x_2$$, the gradient is the ratio $$$ \Tgreen{a} = \frac{y_2 - y_1}{x_2 - x_1}. $$$

For $$y = -x +2$$, we can check that $$$\Tblue{b} = 2,\qquad \Tgreen{a} = \frac{1-2}{1} = -1.$$$

A quadratic function takes the form $$$ y = \Tred{a}x^2 + \Tgreen{b}x + \Tblue{c}$$$ for three numbers $$\Tred{a}\ne0$$, $$\Tgreen{b}$$ and $$\Tblue{c}$$.

$$y = \Tred{-2} x^2 + \Tblue{1}$$ and $$y = \Tred{2}x^2 \Tgreen{-3} x - \Tblue{6}$$ are quadratic.

Constant functions and linear functions are NOT quadratic because they correspond to $$\Tred{a}=0$$.

The functions $$x^3$$ and $$1/x$$ are not quadratic.

- If $$\Tred{a}\gt 0$$, the graph has a
**U shape**. It is symmetrical across the vertical line through its**minimum**point. - If $$\Tred{a}\lt 0$$, the graph has an
**inverted U shape**. It is symmetrical across the vertical line through its**maximum**point.

The number $$\Tblue{c}$$ is the value of the function for $$x=0$$. It is the intercept with the $$y$$-axis.

A reciprocal function takes the form $$$ y = \frac{\Tblue{a}}{x}$$$ for a number $$\Tblue{a}$$. We can also write the function as $$\Tblue{a}/x$$ or $$\Tblue{a} x^{-1}$$.

$$\displaystyle\frac{\Tblue{1}}{x}$$ and $$\displaystyle\frac{\Tblue{-2}}{x}$$ are reciprocal functions.

The number $$\Tblue{a}$$ is the value of the function at $$x=1$$.

The reciprocal function is defined for $$x\ne0$$. It has no value at $$0$$.

For positive $$x$$, $$y = \Tblue{1}/x$$ becomes bigger as $$x$$ gets smaller. $$$f(1) = 1,\; f(0.5) = 2,\; f(0.1) = 10,\; f(0.01) = 100.$$$ As positive values of $$x$$ tend to $$0$$, the graph gets closer to the upper $$y$$-axis but never crosses it. Similarly, for negative $$x$$, the graph gets closer to the lower $$y$$-axis.

We say that the $$y$$-axis is a vertical asymptote of $$1/x$$.

A power function is a function of the form $$$y = \Tblue{a} x^{\Torange{n}}.$$$ The number $$n$$ is the power. It is often an integer.

Power functions have special name depending on the value of the power.

function | reciprocal | constant | linear | quadratic | cubic |
---|---|---|---|---|---|

power $$\Torange{n}$$ | $$-1$$ | $$0$$ | $$1$$ | $$2$$ | $$3$$ |

$$2^{\Torange{n}}$$ | $$0.5$$ | $$1$$ | $$2$$ | $$4$$ | $$8$$ |

A power function with a **negative exponent** is not defined for $$x=0$$.

A number raised to a negative power is the reciprocal of the number at the positive power. $$$ \Tblue{3}^{-\Torange{2}} = \frac{1}{\Tblue{3}^{\Torange{2}}} = \frac{1}{\Tgreen{9}}.$$$

The graph of the **sum of power functions** is obtained by adding, for each $$x$$, the $$y$$-values of each individual function.

An exponential function is a function of the form $$$ y = \Tblue{k} \Torange{a}^{x}.$$$ The number $$\Torange{a}$$ is **positive**.

The computation without a calculator is difficult for a general $$x$$. However, it can be done when $$x$$ is rational.

- When $$x$$ is an
**integer**: $$y$$ is the usual $$\Torange{a}$$ to the power of $$x$$. $$$ 2^{\Tred{1}} = 2,\; 2^{\Tred{2}} = 2\times2 = 4,\; 2^{\Tred{3}} = 2^2\times 2 = 8,\; 2^{\Tred{4}} = 16.$$$ - When $$x$$ is the
**reciprocal**of an integer: $$y$$ is the $$x$$-th root of $$\Torange{a}$$, i.e. the number that is $$\Torange{a}$$ when raised to the power $$x$$ $$$ 2^{1/\Tred{2}} = \sqrt{2} \simeq 1.41,\; 2^{1/\Tred{3}} = \sqrt[\Tred{3}]{2}\simeq 1.26,\; 2^{1/\Tred{4}} = \sqrt[\Tred{4}]{2}\simeq 1.19.$$$ - When $$x$$ is
**rational**($$p/q$$): $$y$$ is the $$q$$-th root of $$\Torange{a}$$ raised to the power $$p$$ $$$ 2^{\Tblue{3}/\Tred{2}} = (\sqrt{2})^\Tblue{3} \simeq (1.41)^\Tblue{3}\simeq 1.58,\; 2^{\Tblue{2}/\Tred{3}} = (\sqrt[\Tred{3}]{2})^\Tblue{2}\simeq 2.83$$$