## Introduction

In the natural sciences, we often encounter quantities depending on each other. For example we may consider the quantity of water in a tank that has both an inflow and an outflow. We measure the height $$f(t)$$, say in inches, of the water as a function of time. It is evident that the rate of change of $$f(t)$$ can be different at different moments of time.

## What arederivatives?

How do we define the rate of change of a general function $$f(x)$$? First consider a linear function, for which the rate of change is constant.

A linear function has the form
$$L(x) = m x + b.$$
The number $$m$$ is often called its slope. For example, $$L(x) = 2 x + 1$$ would have slope $$m = 2$$. For a linear function $$L$$, the slope can be computed with the rise-over-run formula:

$$\text{slope}=\frac{\Delta f}{\Delta x}=\frac{f(x)-f(y)}{x-y}$$

where $$x, y$$ are points not equal to each other. The formula computes exactly the rate of change of the linear function: the ratio between the change in the values of the function and the change in the independent variable $$x$$.

In other words, the slope of a linear function tells us how fast the linear function changes. For example, if $$m=10$$, the linear function would increase by $$10$$ units if $$x$$ is increased by one unit. On the other hand, if $$m=-5$$ the linear function would decrease by $$5$$ units if (x) is increased by one unit.

Suppose that $$f(x)$$ is a more general type of function, for example a polynomial, exponential or trigonometric function. Is there a a concept that generalizes the slope of a linear function?

The concept that generalizes the slope of a linear function is the derivative $$f'(x)$$. The derivative $$f'(x)$$ in general depends on the base point $$x$$ and is equal to slope of the tangent at this point.

Have a look a the following graph of a function $$f(x)$$. By hovering over the graph, you can make the tangent appear at any point. What can you say about the slope at interesting points, such as the maximum, the minimum and the inflection points?

At which points of the graph is the derivative zero, i.e. $$f'(x) = 0$$? At which points is the slope maximal?

## How arederivatives computed?

To compute the derivative/slope of the tangent we first need to define the secant. The secant is the line that passes through point $$(x, f(x))$$ and $$(y, f(y))$$. Move around the point $$y$$ to see how the secant turns into the tangent, by moving $$y$$ closer and closer to $$x$$.

To compute the slope of the secant between the points $$x$$ and $$y$$, use the rise over run formula:

$$\frac{\Delta f}{\Delta x} = \frac{f(y)-f(x)}{y-x}$$

The derivative/slope of the tangent at a point $$x$$ is defined to the limit

$$f'(x) = \lim_{y\to x}\frac{f(y)-f(x)}{y-x}.$$

Compute the derivative of $$f(x) = x^2$$ at any point $$x$$ using the definition. Start by writing $$y^2 - x^2 = (y-x)(y+x)$$ (this is the binomial formula).

Usually, you don't have to calculate every derivative from scratch using the definition. There are plenty of tables and rules you can apply, for example:

$$f(x) = x^n \quad \Longrightarrow \quad f'(x) = n x^{n-1}$$

$$f(x) = sin(x) \quad \Longrightarrow \quad f'(x) = cos(x)$$

$$f(x) = cos(x) \quad \Longrightarrow \quad f'(x) = -sin(x)$$

$$f(x) = e^{x} \quad \Longrightarrow \quad f'(x) = e^{x}$$

## Why arederivatives useful?

1. Derivatives measure the rate of change of the function (f) with respect to a change of $$x$$. In the beginning example, $$f(t)$$ was the height of water in a tank. The derivative $$f'(t) = \frac{df}{dt}(t)$$ is the instantaneous rate of change.
2. Derivatives can be used to approximate functions. To see this, we pick a base point $$x$$ at which the derivative $$f'(x)$$ is known. We can then use the linear function with slope $$f'(x)$$ as an approximation for $$f(y)$$: $$f(y)\approx f(x)+f'(x)\cdot (y-x).$$ This formula gives better answers for points $$y$$ close to the base point $$x$$.
3. We can use derivatives to find points at which the graph has a "peak" or a "valley". These are called local maxima and local minima. At such a point, the tangent is horizontal and its slope is zero. So if $$x$$ is a local maximum/minimum, then $$f'(x) = 0.$$

Try to get a feel for the approximation error, defined to be the absolute value of the difference between $$f(x)$$ and its linear approximation. Feel free to move the base point around in the following graph - the area where the approximation error is less than $$0.1$$ is highlighted.

At which points does the linear approximation work well? At which points is the approximation good for a larger range of $$x$$ values? At which points is the approximation less good?