## Derivative

• A function maps an input to an output.
• Calculus provides a set of tools to study the relationship between a function and the change in its variables.
• There are different notations for showing a derivative: $$\frac{dy}{dx}$$ suggested by Leibniz, $$y'(x)$$, suggested by Lagrange, $$\dot y$$, suggested by Newton, and $$Dy$$, suggested by Euler. Sometimes, one notation is more convenient in a specific application.

### Slope

• Have a look at this classic graph of car speed vs time.

• The slop/gradient at each point of the graph shows acceleration.
• If we calculate acceleration at each point and plot it, it looks like the graph below.

• Note that the acceleration becomes zero, i.e. crosses the horizontal axis, at places where the speed graphs become flat and has gradient zero.
• We could take the derivative of acceleration with gives us the jerk of the car

• We can also think about taking the derivative of what function has resulted in the speed graph. To find it, we use antiderivative. This function, displacement, shows how much the car has moved with respect to time.

### Definition of derivative

• Gradient is “rise over run”
• Gradient at $$x \approx \frac{rise}{run} = \frac{f(x + \Delta x) - f(x)}{(x + \Delta x) - x} = \frac{f(x + \Delta x) - f(x)}{\Delta x}$$
• As we reduce $$\Delta x$$, our approximation becomes better and better: Gradient at $$x = f'(x) = \lim_{\Delta x\to 0}(\frac{f(x + \Delta x) - f(x)}{\Delta x})$$

### Derivation time-saving rules

#### Power rule

If $$f(x) = ax^b$$, then $$f'(x) = abx^{b-1}$$

• Example:
$f'(x^2) = 2x$

#### Sum rule

$\frac{d(f(x) + g(x))}{dx} = \frac{df(x)}{dx} + \frac{dg(x)}{dx}$
• Example:
$f(x) = 2x^2 + 4x^3$ $f'(x) = 4x + 12x^2$

#### Product rule

$\frac{d(f(x)g(x))}{dx} = \frac{df(x)}{dx} g(x) + \frac{dg(x)}{dx} f(x)$
• Example:
$f(x) = 2x^2 . sin(x)$ $f'(x) = 4x . sin(x) + 2x^2 . cos(x)$

#### Reciprocal rule

$\frac{d(\frac{1}{f(x)})}{dx} = \frac{-\frac{df(x)}{dx}}{f(x)^2}$
• Example:
$\frac{d}{dx}(\frac{1}{x}) = \frac{d}{dx}(x^{-1}) = -1x^{-2} = -\frac{1}{x^2}$

#### Quotient Rule

$\frac{d(\frac{f(x)}{g(x)})}{dx} = \frac{\frac{df(x)}{dx} g(x) - \frac{dg(x)}{dx} f(x)}{g(x)^2}$

#### Chain rule

$\frac{d}{dx}f(g(x)) = \frac{df(g(x))}{dg(x)} \times \frac{g(x)}{dx}$
• Example:
$\frac{d}{dx}(sin(x^2)) = cos(x^2) \times 2x$

### Special functions

#### Trigonometry

$\frac{d}{dx}(sin(x)) = cos(x)$ $\frac{d}{dx}(cos(x)) = -sin(x)$ $\frac{d}{dx}(tan(x)) = sec^2(x)$

#### Exponential

$\frac{d}{dx}(e^x) = e^x$ $\frac{d}{dx}(e^{f(x)}) = e^{f(x)} . \frac{d}{dx}f(x)$ $\frac{d}{dx}(b^{f(x)}) = b^{f(x)} . \ln b\frac{df(x)}{dx}$

For example, $$\frac{d}{dx}(10^{3x}) = 10^{3x} \times 3 \ln(10)$$.

$\frac{d}{dx}(\ln x) = \frac{1}{x}$ $\frac{d}{dx}(\log_{a}x) = \frac{1}{x \ln (a)}$ $\frac{d}{dx}(\ln f(x)) = \frac{d}{dx} f(x) \times \frac{1}{f(x)}$

## Multivariate derivation

• What if there is more than a single variable in a function?
• The solution is to consider the irrelevant variables as constant and take a “partial” derivative of the function with respect to a single variable.

### Vectors of derivatives

• If we take the partial derivative of a function with respect to all of its variables, and put those variables in a vector, we have a Jacobian.
• A Jacobian is a vector that when supplied with specific values of variables, points in the direction of the steepest uphill slope of a function.
• For a proof that Jacobian points in the direction of steepest ascend, consider the following.
• Each element of the vector specifies the rate of change of the function with respect to the standard basis, i.e., how fast the function changes when that variable is changed.
• But how fast would a function change with respect to an arbitrary direction instead of the standard basis?
• We can use an inner product to answer this question. Say that we want to evaluate the Jacobian at a given point a, so grad(f(a)) is the Jacobian defined at that point. The inner product of this vector with some arbitrary vector r is grad(f(a)).r = |grad(f(a))| |r| cos(θ). The inner product shows how fast the function is changing at a given point with respect to vector r. All we need is to find a vector r that the function changes maximally in its direction.
• The maximum value of the inner product is when both vectors are in the same direction, so cos(0)=1.
• So when r is in the direction of Jacobian, we get the highest value. In other words, Jacobian points to the steepest direction.
• By convention, Jacobian is a row vector, instead of a column vector.

## Exercises

1. What are the partial derivatives of the following function wrt $$x$$ and $$y$$? Note that $$\pi$$ and $$n$$ are constant parameters. $$f(x,y) = 2\pi x^4 + xy^2 + ny$$ (1 point)
1. What is the Jacobian of the function at $$x=2$$, $$y=3$$, and $$n=5$$? (1 point)
2. What does this vector show? (1 point)
2. Find the partial derivatives of the following function wrt to $$x$$, $$y$$, and $$z$$: $$f(x,y,z) = \epsilon ^ {2x}\sin (y)z^2 + \cos (z) \epsilon ^x \epsilon ^ y$$ (1 point)
Tags: