The Chain Rule
When you have a complicated function, you can make life simpler by breaking the function into simpler parts.
For example, you might want the derivative of the function
$$ y = ( 3x + 1 )^2 $$
If you were going to calculate \( y \) given \( x \), you would procede in two steps. You would first calculate \( 3x + 1 \). You would then square that.
To find the derivative, let's look at that first step, \( 3x + 1 \), and call it \( u = g(x)\). Now the problem looks like this:
$$ u = 3x + 1 $$
$$ y = u^2 $$
You can then get the derivative of each part, and combine them into one derivative using the Chain Rule:
If \( y = f( g( x ) ) \) and \( u = g( x ) \) then:
$$ {\operatorname{d}\!y \over \operatorname{d}\!x} = {\operatorname{d}\!y \over \operatorname{d}\!u} \dot {\operatorname{d}\!u \over \operatorname{d}\!x} $$
Let's start by differentiating the last part, the square, using the power rule:
$$ { {\operatorname{d}\! \over \operatorname{d}\!u} \left [ ( 3x + 1 )^2 \right ] } = { 2 ( 3x + 1 ) } $$
Then we differentiate \( 3x + 1 \):
The derivative of a sum is the sum of the derivatives.
$$ { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x + 1 \right ] } = { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x \right ] + {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 1 \right ] } $$
If f is a constant function, the derivative is zero.
$$ { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x + 1 \right ] } = { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x \right ] } $$
A constant factor can be moved through the derivative.
$$ { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x + 1 \right ] } = { 3 {\operatorname{d}\! \over \operatorname{d}\!x} \left [ x \right ] } $$
The slope of \( y = x \) is one, so \( { \operatorname{d}\! \over \operatorname{d}\!x} \left [ x \right ] \) is one:
$$ { {\operatorname{d}\! \over \operatorname{d}\!x} \left [ 3x + 1 \right ] } = { 3 } $$
Then we multiply \( {\operatorname{d}\!y \over \operatorname{d}\!u} \) times \( {\operatorname{d}\!u \over \operatorname{d}\!x} \):
$$ {\operatorname{d}\!y \over \operatorname{d}\!x} = 2 ( 3x + 1 ) ( 3 ) $$
And simplify:
$$ {\operatorname{d}\!y \over \operatorname{d}\!x} = 6 ( 3x + 1 ) $$