# Differentiation Techniques Pt.3

The **extended power rule** states that, supposing that \(g(x)\) is a differentiable function of \(x\). Then, for any real number \(k\),

\[\frac{d}{dx}[g(x)]^k = k[g(x)]^{k-1} \cdot \frac{d}{dx}g(x)\]

Taking a detour into function compositions, a **composed** function \(f \circ g\), the **composition** of \(f\) and \(g\), is defined as

\[(f \circ g)(x) = f(g(x))\]

Suppose we want to calculate how much it costs to heat a house on a particular day of the year. The cost to heat a house will depend on the average daily temperature, and in turn, the average daily temperature depends on the particular day of the year. Just like that, we have defined two relationships. The cost depends on the temperature, and the temperature depends on the day.

Using variables, we could say that the cost is \(C(T)\) and the temperature is \(T(d)\). So for any given day

\[C(T(d))\]

By combining these two relationships into one function, we have performed **function composition**.

Function composition is only one way to combine existing functions. Another way is to carry out the usual algebraic operations (addition, subtraction, multiplication, and division) on functions. We do this by performing the operations with the function outputs, defining the result as the output of our new function. Of course, both methods accept as many functions as we want, not just two.

In short, when the output of one function is used as the input of another, we call the entire operation a composition of functions. For any input \(x\) and functions \(f\) and \(g\), this action defines a **composite function**, which we write as \(f \circ g\).

This leads to the **chain rule**, which states that the derivative of a composition \(f \circ g\) is given by

\[\frac{d}{dx}[(f \circ g)(x)] = \frac{d}{dx}[f(g(x))] = f^{\prime}(g(x)) \cdot g^{\prime}(x)\]

## Example

A new product is placed on the market and becomes very popular. It’s quantity sold \(N\) is given as a function of time \(t\), where \(t\) is measured in weeks:

\[N(t) = \frac{250000t^2}{(2t + 1)^2}\]

for \(t > 0\). Let’s differentiate this function, then use the derivative to evaluate \(N^\prime(52)\) and \(N^\prime(208)\), and interpret the results.

```
from sympy import *
import matplotlib.pyplot as plt
N, t = symbols("N, t")
f = (250000 * t**2) / (2*t + 1)**2
derivative = simplify(diff(f, t))
derivative
```

`## 500000*t/(2*t + 1)**3`

`derivative.evalf(subs = {t: 52})`

`## 22.4597775618184`

`derivative.evalf(subs = {t: 208})`

`## 1.43425104300046`

After 52 weeks (1 yr), the quantity sold is increasing by about 22.5 units per week, After 208 weeks (4 yr), the quantity sold is increasing by about 1.4 units per week. The market is perhaps becoming saturated and sales are levelling off. Although sales may continue increasing, the rate of speed of these sales is slowing down.

```
def rate(t):
return 500000 * t / (2*t + 1)**3
def sales(t):
return (250000 * t**2) / (2*t + 1)**2
sales = [sales(t) for t in range(0, 500)]
sales_rate = [rate(t) for t in range(0, 500)]
plt.plot(range(0, 500), sales_rate, label = "rate of sales")
plt.plot(range(0, 500), sales, label = "sales")
plt.legend(frameon=False)
```