The Chain Rule Derivative Explained with Comics

It all started when Seth stumbled upon the mythical “Squaring Machine”:

Johnny Burns
Towards Data Science

--

dirivative function for x²
Photo from Pixnio

Legend has it, whatever you place into the Squaring Machine, the machine will give you back that number of objects squared.

Photo from Wikimedia

So Billy brought the giant diamond to the Squaring Machine, and they placed it inside.

Wait a minute….

But Billy was already on to bigger ideas…

Photo from Wikimedia

So they put in 3 bottles, and 9 came out!

Then, Billy wondered “what happens if we put a 3-pack of shampoo into the squaring machine?”

And so they did, and again, 9 bottles came out!

Billy discovered that if you put “x” bottles in, you get “x²” bottles out, but also noticed something else very interesting:

He realized that you can describe this machine in terms of value packs. If you put “x” value packs in, you get “3x²” value packs out.

^Let this sink in. This is this is the most difficult part of the “chain rule” to wrap your head around.

Billy discovered you can also state the derivative of this machine in terms of terms of “bottles” or “value packs”:

  1. How does the machine respond to adding/removing a shampoo?

The derivative of X² is of-course 2x.

2. How does the machine respond to adding/removing a value pack?

A 3-in-1 value pack is 3x. If you replace the “x” in the above example with “3x”, you get a derivative of 2(3x), or 6x.

Billy now knows how the squaring machine moves relative to a value pack, which will turn out to be very useful later…

The Plot Thickens

They find a second magical machine. This one is called the “Tripling Machine”. If you place an item in the “Tripling Machine”, it gives you back a 3- pack!

Photo from geograph.org

Seth and Billy jump for joy and eagerly place a shampoo bottle in the Tripling Machine (not realizing that they could have put the diamond in there).

As promised, a 3-pack pops out.

Seth begins to become power hungry. He wants to eradicate greasy hair from the face of the earth.

He decides to “chain” to two machines together. He plans to place items in the “Tripling Machine”, then connect the two machines so that the value packs produced by the Tripling Machine go straight into the “Squaring Machine”.

Seth wonders: “how can I calculate the total derivative of the new combined function?”

Billy thinks to himself.

It is then that Billy realizes: we know how the Tripling Machine moves relative to shampoo bottles (3x), and we know how the Squaring Machine moves relative to 3-packs (6x). We can multiply these together and figure out how a change in “x” impacts the Squaring Machine’s final output.

3x * 6x = 18x

This concept holds true for all “chain” type functions. If we calculate how the outer function moves relative to the inner function, and we figure out how the inner function moves relative to x, we can multiply these to discover how the total output moves relative to x.

How Do We Calculate How the Outer Function Moves Relative To the Inner Function?

To calculate how the Squaring Machine moves relative to (3x), We take the derivative of x², but replace x with (3x).

(3x)²

Becomes:

2(3x)
6x

If we wanted to instead calculate how the Squaring Machine moves relative to a “sin(x)” machine, pass in sin(x), take the derivative of the outer portion, and simplify.

(sin(x))²

2 * sin(x)

Moral of the Story: Everything is Relative

Imagine you’ve set up a “cars -> horsepower” calculator.

If a car has 10 “horsepower”, our function is f(x) = 10x.

If we pass in 5 (cars), we correctly get back 50 horsepower.

If you pass in 1 (airplane), you’re going to get back 10 horsepower, which is incorrect, because the function is a measure of horsepower relative to cars.

However, if we have a “airplane -> carpower” calculator, we can multiply the two functions to figure out how much “horsepower” an airplane has.

About the Author

I’m Johnny Burns, founder of FlyteHub.org, a repository of free open-source workflows to perform Machine Learning with no coding. I believe that collaborating on AI will lead to better products.

--

--