# Differentiation Techniques

Let \(y\) be a function of \(x\). A common way to express “the derivate of \(y\) with respect to \(x\)” is the notation

\[\frac{dy}{dy}\]

Using this notation, we can write that if \(y = f(x)\), then the derivative of \(y\) with respect to \(x\) is \(\frac{dy}{dx} = f^{\prime}(x)\).

There are a handful of rules that you can use when evaluating derivatives.

The **Power Rule** states that

\[\frac{d}{dx}x^k = kx^{k - 1}\]

The **derivative of a constant function** is 0.

\[\frac{d}{dx}c = 0\]

The **derivative of a constant times a function** is the constant times the derivative of the function.

\[\frac{d}{dx}[cf(x)] = c\frac{d}{dx}f(x)\]

The **derivative of a sum** is the sum of the derivatives.

\[\frac{d}{dx}[f(x) + g(x)] = \frac{d}{dx}f(x) + \frac{d}{dx}g(x)\]

The **derivative of a difference** is the difference of the derivatives.

\[\frac{d}{dx}[f(x) + g(x)] = \frac{d}{dx}f(x) - \frac{d}{dx}g(x)\]

All these rules, and more, are already encoded in your symbolic mathematical program of choice, Mathematica, Sympy, Sage, and so on. There’s nothing to memorize.

In general, you can use the derivative to find the slope of a tangent line.

Lastly, some functions are always increasing or always decreasing. The equation of the derivative of these function will tell you what behavior you can expect from the function.

Let’s look at some textbook problems.

Let’s say that the volume \(V\) of a spherical tumor can be approximated by

\[V(r) = \frac{4}{3}\pi r^3\]

where \(r\) is the radius of the tumor, in centimeters. (1) Find the rate of change of the volume with respect to the radius. (2) Find the rate of change of the volume at \(r = 1.2 cm\).

```
from math import pi
import numpy as np
from sympy import *
import matplotlib.pyplot as plt
r, v, x = symbols("r, v, x")
v = 4/3 * pi * r**3
fprime = diff(v, r)
fprime
```

`## 4.0*pi*r**2`

`fprime.evalf(subs = {r: 1.2})`

`## 18.0955736846772`

When the radius is \(1.2 cm\), the volume is changing at the rate of \(18 cm^3\).

Let’s take the case of an always increasing function \(f(x) = x^3 + 2x\).

```
def f(x):
return x ** 3 + 2 *x
x_values = np.linspace(-2, 2)
y_values = [f(x) for x in x_values]
plt.plot(x_values, y_values)
```

The derivative is

```
f = x ** 3 + 2 * x
fprime = diff(f, x)
fprime
```

`## 3*x**2 + 2`

Thus, for any \(x\)-value, \(x^2\) will be nonnegative.