### Limits

Limits quantify what happens to the values of a function as we approach a given point. This can be defined notationally as:

`$\lim_{x \rightarrow 6} f(x) = L$`

We can read this in simple terms as “the limit as *x* goes to 6 of f(x) approaches some value L”.

### Limit Definition of the Derivative

The *limit definition of the derivative* proves how to measure the instantaneous rate of change of a function at a specific point by looking at an infinitesimally small range of *x* values.

`$instantaneous\ rate\ of\ change\ = \lim_{h \rightarrow 0} \frac{f(x+h)}{h}$`

The animation provided shows that as we look at a smaller range of *x* values, we approach the instantaneous range of a point.

### Derivative Properties

The *derivative* is the slope of a tangent line at a specific point, and the derivative of a function *f(x)* is denoted as *f’(x)*. We can use the derivative of a function to determine where the function is increasing, decreasing, at a minimum or maximum value, or at an inflection point.

If *f’(x)* = 0, then the function is not changing. This can mean one of a few things.

- It may mean that the function has reached a
*local maximum*(or minimum). A local maximum is a value of x where*f’(x)*changes from positive to negative and thus hits 0 along the way. In*f(x)*, the local maximum is lower than all the points around it. - It may also mean that the function has reached what is called a
*local maximum*. Our local maximum is higher than the points around it. When*f’(x)*goes from negative values to 0 to positive values, a local maximum forms. - It may be an
*inflection point*. This is a point where a function has a change in the direction of curvature. For example, the curve of the function goes from “facing down” to “facing up.” Finding inflection points involves a second derivative test, which we will not get to in this lesson.

If *f’(x) > 0*, the function is increasing, and if *f’(x) < 0*, the function is decreasing.

### Derivatives in Python

We can use the `np.gradient()`

function from the NumPy library to calculate derivatives of functions represented by arrays. The code block shown shows how to calculate the derivative of the function *f(x) = x ^{3} + 2* using the

`gradient()`

function.```
from math import pow
# dx is the "step" between each x value
dx = 0.05
def f(x):
# to calculate the y values of the function
return pow(x, 3) + 2
# x values
f_array_x = [x for x in np.arange(0,4,dx)]
# y values
f_array_y = [f(x) for x in np.arange(0,4,dx)]
# derivative calculation
f_array_deriv = np.gradient(f_array_y, dx)
```

### Calculating Derivatives

To take the derivative of polynomial functions, we use the *power rule*. This states the following:

`$\frac{d}{dx}x^{n} = nx^{n-1}$`

There are rules even beyond the power rule. Many common functions have defined derivatives. Here are some common ones:

```
$\begin{aligned}
\frac{d}{dx}ln(x) = \frac{1}{x} \\
\frac{d}{dx}e^x = e^x \\
\frac{d}{dx}sin(x) = cos(x) \\
\frac{d}{dx}cos(x) = -sin(x)
\end{aligned}$
```

### Derivative Rules

There are general rules we can use to calculate derivatives.

The derivative of a constant is equal to zero:

`$\frac{d}{dx}c = 0$`

Derivatives are *linear operators*, meaning that we can pull constants out of derivative calculations:

`$\frac{d}{dx} c f(x) = c f'(x)$`

The derivative of a sum is the sum of the derivatives, meaning we can say the following:

`$\frac{d}{dx}(f(x) + g(x)) = \frac{d}{dx}f(x) + \frac{d}{dx}g(x)$`

We define the derivative of two products as the following:

```
$\begin{aligned}
\frac{d}{dx}(f(x) + g(x)) = \frac{d}{dx}f(x) + \frac{d}{dx}g(x) \\
f(x) = u(x)v(x) \rightarrow f'(x) =u(x)v'(x) + v(x)u'(x)
\end{aligned}$
```