# Derivatives¶

## Outline¶

• Product rule
• Quotient rule
• Chain rule
• Partial differentation
• Differentials
• Total differentials
• Total derivative
• Derivative of implicit functions
• Inverse function rule

## Warm-up exercises¶

### Round 1¶

Calculate $\dfrac{dy}{dx}$ for the following functions:

🐑 $y = x^2$

🐑 $y = 5x^3 + 12$

🐑 $y = 5x^{-2}$

🐑 $y = \frac{7}{x}$

🐑 $y = 18\sqrt{x}$

### Round 2¶

🐑 $y = \ln(x)$

🐑 $y = \sin(x)$

🐑 Given the total-cost function $C = Q^3 - 5Q^2 + 12Q + 75$, write out a variable-cost ($VC$) function. Find the derivative of the VC function, and intepret the economic meaning of that derivative.

🐑 Provide a mathematical proof for the general result that, given a linear average curve, the corresponding marginal curve must have the same vertical intercept but will be twice as steep as the average curve.

## Product rule¶

${\dfrac{d}{dx}}[f(x)\cdot g(x)]= f(x)\cdot {\dfrac {d \ [g(x)]}{dx}}+g(x)\cdot {\dfrac{d \ [f(x)]}{dx}}$

$(f\cdot g)'=f'\cdot g+f\cdot g'$

Watch Khan Academy's video on the product rule and the proof.

How do you remember the product rule?

### Exercises¶

Calculate $f'(x)$ for the following functions:

🐑 $f(x) = 5x^4(3x - 7)$ by multiplying out first and by using the product rule.

🐑 $f(x) = (x^8 + 8)(x^6 + 11)$ by multiplying out first and by using the product rule.

🐑 $f(x) = (4x^2-3)(2x^5)$

🐑 $f(x) = 7x^9(3x^2-12)$

🐑 $f(x) = (2x^4+5)(3x^5-8)$

🐑 $f(x) = (3-12x^3)(5+4x^6)$

## Quotient rule¶

$f(x) = \dfrac{g(x)}{h(x)}$

$f'(x) = \dfrac{g'(x)h(x) - g(x)h'(x)}{[h(x)]^2}$

Watch Khan Academy's video on the quotient rule and the how the quotient rule can be derived from the product and chain rule.

How do you remember the quotient rule?

### Exercises¶

🐑 $f(x) = \dfrac{10x^8 - 6x^7}{2x}$ first by simplifying and then using the quotient rule.

🐑 $f(x) = \dfrac{3x^8-4x^7}{4x^3}$

🐑 $f(x) = \dfrac{4x^5}{1-3x}$ and $(x \neq \frac{1}{3})$

🐑 $f(x) = \dfrac{15x^2}{2x^2+7x-3}$

🐑 $f(x) = \dfrac{6x-7}{8x-5}$

🐑 $f(x) = \dfrac{5x^2-9x+8}{x^2+1}$

## Chain rule¶

If $F(x) = f(g(x))$ then $F'(x)=f'(g(x))g'(x).$

Or equivalently, ${\dfrac {dz}{dx}}={\dfrac {dz}{dy}}\cdot {\dfrac {dy}{dx}}$

Watch Khan Academy's video on the chain rule and the proof.

How do you remember the chain rule?

Remember the chain rule with the Matryoshka_doll. Each nested function is a doll.

### Exercises¶

🐑 $f(x) = (3x^4 + 5)^6$

🐑 $f(x) = (7x + 9)^2$

🐑 $f(x) = (x^2 + 3x - 1)^5$

🐑 $f(x) = -3(x^2 - 8x + 7)^4$

🐑 $f(x) = (\ln(2x^2 + 1))^4$

🐑 $f(x) = \sin(7x + \ln(2x^3 + \dfrac{14}{(x+2)^3}))$

So far we have been analysing functions of one variable, $x$. Now we consider functions of more than one variable:

$z = f(x,y)$

How do we evaluate the impact of a change in $x$ on $z$ ?

## Partial differentiation¶

Everything is the same. Just treat the other variables (in this case $y$) as constants.

\begin{align*} \dfrac{\partial z}{\partial x} \end{align*}

### Exercises¶

🐑 $z = 8x^2 + 14xy + 5y^2$

🐑 $z = 4x^3 + 2x^2y-7y^5$

🐑 $z = 6w^3 + 4wx + 3x^2 - 7xy - 8y^2$

🐑 $z = 2w^2 + 8wxy - x^2 + y^3$

🐑 $z = 3x^2(5x + 7y)$

🐑 $z = (9x-4y)(12x+2y)$

## Differentials¶

If you looked it up, a derivative is defined as $f'(a)=\lim _{h\to 0}{\frac {f(a+h)-f(a)}{h}}$ and so we we have been treating $f'(x)$ or $\frac{dy}{dx}$ as a single object.

We can also write $dy = f'(x)dx$ where $dy$ and $dx$ are the differentials.

See page 179 of Chiang and Wainwright more details.

### Exercises¶

Find the differential $dy$ for the following functions:

🐑 $y = (4x +3)(3x-8)$

🐑 $y = (11x+9)^3$

## Total differentials¶

Now use differentials on functions of several variables.

For the function $z = f(x,y)$

$dz = \dfrac{\partial z}{\partial x} dx + \dfrac{\partial z}{\partial y} dy$

Simply find the partial derivatives and substitute into the above formula.

See page 184 of Chiang and Wainwright for more details.

And here is a nice video that gives great example of how to use total differentials.

### Exercises¶

Find the total differential $dz = z_x dx + z_y dy$ for the following functions:

🐑 $z = 5x^3-12xy-6y^5$

🐑 $z = 3x^2(8x-7y)$

## Total derivative¶

Consider the case where $z = f(x,y)$ and we wish to calculate $\dfrac{dz}{dx}$. Before, we calculated a partial derivative by treating $y$ as a constant. What if $y$ is also a function of $x$ so that it no longer makes sense to change $x$ but keep $y$ constant? We then use the total derivative:

$\dfrac{dz}{dx} = z_x + z_y \dfrac{dy}{dx}$

Draw a dependency diagram.

See page 189 of Chiang and Wainwright for more details.

This video shows how we can use the total differential to derive the total derivative.

### Exercises¶

Find the total derivative $\dfrac{dz}{dx} = z_x + z_y \dfrac{dy}{dx}$ for the following functions:

🐑 $z = 6x^2 + 15xy + 3y^2$ where $y=7x^2$

🐑 $z = (13x - 18y)^2$ where $y = x + 6$

## Derivative of implicit functions (equations)¶

We have been working with functions of the form $y = f(x)$. What if we are given $g(x,y) = k$ and it is too difficult to convert the second form into the first?

Step 1: Differentiate both sides of the equation with respect to $x$ while treating $y$ as a function of $x$.

Step 2: Solve for $\dfrac{dy}{dx}$

Details on the derivation of this formula are on page 197 of Chiang and Wainwright.

Implicit differentiation is a little tricky. Khan Academy have a great video making it super simple and more advanced examples. You will need implicit differentiation in macro.

### Exercises¶

Use implicit differentiation to find the derivative $\dfrac{dy}{dx}$ for the following equations:

🐑 $4x^2 - y^3 = 97$

🐑 $3y^5 - 6y^4 + 5x^6 = 243$

🐑 $x^4y^6 = 89$

🐑 $2x^3 + 5xy + 6y^2 = 87$

🐑 $(2x^3+7y)^2 = x^5$

## Implicit Function Rule¶

Now suppose we don't have an equation, but just the function $f(x,y)$. How do we calculate $\dfrac{dy}{dx}$?

How could we derive a rule from the total differential? 🐑 |🐑

In general, if an implicit function is defined in the neighbourhood of $x$, then $\dfrac{dy}{dx}=-\dfrac{f_x}{f_y}$

We could also this formula for equations of the form $g(x,y) = k$.

### Exercise¶

Use the implicit function rule to find $\dfrac{dy}{dx}$.

🐑 $f(x,y) = 3x^2 +2xy + 4y^3$

🐑 $f(x,y)=12x^5-2y$

🐑 $f(x,y)=7x^2+2xy^2+9y^4$

🐑 $f(x,y)=6x^3-5y$

## Inverse function rule¶

If the function is a one-to-one mapping then

$\dfrac{dx}{dy} = \dfrac{1}{\dfrac{dy}{dx}}$

Watch Khan Academy's video on the inverse function rule.

### Exercises¶

🐑 Are the following functions strictly monotonic (one-to-one mapping)?

$y = -x^6 + 5$ for $x>0$

$y=4x^5 + x^3 + 3x$

For each strictly monotonic function, find $\dfrac{dx}{dy}$ by the inverse-function rule.

## Homework¶

### Exercise 1¶

Differentiate the following:

🐑 $f(x) = \dfrac{3x(2x-1)}{5x-2}$

🐑 $f(x) = 3x(4x-5)^2$

🐑 $f(x) = \dfrac{(8x-5)^3}{7x+4}$

### Exercise 2¶

Find all the partial derivatives of:

🐑 $z = (2x^2+6y)(5x-3y^3)$

🐑 $z = (w-x-y)(3w+2x-4y)$

🐑 $z = \dfrac{5x}{6x-7y}$

🐑 $z = \dfrac{x^2-y^2}{3x+2y}$

### Exercise 3¶

Find the total differential $dz = z_x dx + z_y dy$ for the following functions:

🐑 $z = 7x^2y^3$

🐑 $z = (5x^2+7y)(2x-4y^3)$

Find the total derivative $\dfrac{dz}{dw}$ for the following functions:

🐑 $z = 7x^2 + 4y^2$ where $x=5w$ and $y=4w$

🐑 $z = 10x^2 - 6xy - 12y^2$ where $x = 2w$ and $y = 3w$

### Exercise 4¶

Use the implicit function rule to find $\dfrac{dy}{dx}$ and $\dfrac{dy}{dz}$.

🐑 $f(x,y,z) = x^2y^3 + z^2 + xyz$

🐑 $f(x,y,z) = x^3z^2 + y^3 + 4xyz$