
This article is aimed at students in high school or at university who struggle with understanding chain rule. I try to explain a concept in an intuitive yet different way, while building foundations for the concept of the ‘total derivative’ which will help you in the future. That said though, if you are just interested in Maths, then this article is also for you!
This is the first part of a Calculus series, where I will explain the concepts of Chain Rule for univariate problems and multivariate problems (after introducing Partial Differentiation). I intend to end the series by providing an intuitive feel for the concept of a ‘Material Derivative’.
Chain Rule is a very important concept in Data Science, especially if you are looking to understand how concepts such as Neural Networks work.
I will assume a knowledge of what a ‘derivative’ is throughout.
What is Chain Rule?
Chain Rule is a concept in Calculus, where the derivative of a compound function is not just the derivative of the parent function, but that it is also affected by the derivative of its child function(s).
So what does this look like?

The problem is a bit abstract isn’t it? Let’s first simplify it and then give it meaning.
Suppose that you are trying to measure how your happiness π changes, and it happens that food π makes you happy, sounds reasonable right?

Naturally, the real model is much more complex than that depicted above, but we can all relate to it nonetheless. When there is no food, we are not happy. When we have enough food, we are perfectly satisfied. When there is too much food, we are not happy.
Now suppose also that, food π is a function of time, so it would look something like this (this is especially the case when you have very hungry family members…):

Now, I’m very interested in measuring how my happiness will change as a function of time. Essentially:

As I’m sure your teachers / lecturers will have drilled you, ‘you must use the Chain rule because π is not directly a variable of π ‘. So:

Have you ever wondered why this works? Or what would happen if we had another variable in our happiness equation? What if our happiness depended on other things too?
An alternative point of view… the total derivative
Consider the concept of the total differential. For a simple case of a univariate problem (in our case, happiness π is only a function of food π ), it means:
The total change in π is given by: the derivative of π with respect to π , multiplied by a change in π .
So:

But why should we take the definition of the total derivative in the first place? Does it make sense that the derivative of π with respect to π , multiplied by the change in π gives us the change in π ?
Let’s examine this further:

Since we now understand why the total derivative makes sense, we can start applying it.
We know that happiness π is a function of food π , so we can write, using the total derivative of happiness:

We also know that food π is a function of time π , so we can write, using the total derivative of food:

Substituting the change in food π in the first expression by that in the second expression, we get this final expression:

Now, we invoke once more the assumption that the change in time is approaching 0. This allows us to convert the curvy d’s into straight d’s, so:

Check this animation if you are confused as to how the curvy d’s become straight ds:

We have now arrived to the expression of Chain rule!
Now to apply it…
Well, I hope you’ve now better understood the concept of the Chain rule, how it arises and why it makes sense.
I leave you with a question to solve…
The curves that I used to represent happiness and food are as follows:

Can you, using Chain rule, find the change in happiness with respect to time?
Note to reader:
I hope you enjoyed this article. I hope to inspire you to see maths not as a boring course at school, or a bunch of ugly symbols… rather a beautiful language that you can use to see the world in a different lens.
I hope that my rather ‘unorthodox’ method of introducing this concept has been helpful.
If you enjoy my content, please follow me as it will motivate me to create more… and don’t be shy to provide feedback through the comments! I’m always looking to learn something new π