# Chain Rule

The Derivative tells us the slope of a function at any point.

There are rules we can follow to find many derivatives.

For example:

• The slope of a constant value (like 3) is always 0
• The slope of a line like 2x is 2, or 3x is 3 etc
• and so on.

If we know the rate of change for two related things, how do we work out the overall rate of change?

The Chain Rule tells us how!

Example: Sage the Dog can run 3 times faster than you, and you can run 2 times faster than me, so Sage can run 3 × 2 = 6 times faster than me.

Let's use some notation. Call the dog "y", me "x" and you can be "u":

• dydx is Sage's speed relative to me
• dydu is Sage's speed relative to you
• dudx is your speed relative to me

Then:

dy dx = dy du du dx

Example: Same example, but using the above notation:
• Sage can run 3 times faster than you, so dydu = 3
• You can run 2 times faster than me, so dudx = 2

dy dx = dy du du dx = 3 × 2 = 6

But it is not usually that easy!

Because one function can depend on the current value of the other (which is itself continually changing).

### Example: What is d dx sin(x2) ?

There are two functions happening here, sin() and x2.

But it is not sin(x), it is sin(the result of x2)

Let's use "u" for x2 so we can have:

dy dx = dy du du dx

Which becomes:

d dx sin(x2) = d du sin(u) d dx x2

The individual derivatives are:

• d du sin(u) = cos(u)
• d dx x2 = 2x

So:

d dx sin(x2) = cos(u) (2x)

Substitute back u = x2:

d dx sin(x2) = cos(x2) (2x)

Which is neater this way:

d dx sin(x2) = 2x cos(x2)

### Notations

There are several different notations that can be used!

Notation Chain Rule
Using d dx   dy dx = dy du du dx
Using ’ (meaning derivative of) f(g(x)) = f’(g(x))g’(x)
As "Composition of Functions" f º g = (f’ º g) × g’

Let's do the previous example again using f(g(x)) = f'(g(x))g'(x):

### Example: What is d dx sin(x2) ?

sin(x2) is made up of sin() and x2:

• f(g) = sin(g)
• g(x) = x2

The Chain Rule says:

the derivative of f(g(x)) = f'(g(x))g'(x)

The individual derivatives are:

• f'(g) = cos(g)
• g'(x) = 2x

So:

d dx sin(x2) = cos(g(x)) (2x)

= 2x cos(x2)

Same result as before (thank goodness!)

Another couple of examples:

### Example: What is ddx(1/cos(x)) ?

1/cos(x) is made up of 1/g and cos():

• f(g) = 1/g
• g(x) = cos(x)

The Chain Rule says:

the derivative of f(g(x)) = f’(g(x))g’(x)

The individual derivatives are:

• f'(g) = −1/(g2)
• g'(x) = −sin(x)

So:

(1/cos(x))’ = −1g(x)2(−sin(x))

= sin(x)cos2(x)

Note: sin(x)cos2(x) is also tan(x)cos(x) or many other forms.

### Example: What is ddx(5x−2)3 ?

The Chain Rule says:

the derivative of f(g(x)) = f’(g(x))g’(x)

(5x−2)3 is made up of g3 and 5x−2:

• f(g) = g3
• g(x) = 5x−2

The individual derivatives are:

So:

ddx(5x−2)3 = (3g(x)2)(5)

= 15(5x−2)2

6810, 6811, 6812, 24951, 24952, 24953, 24954, 24955, 24958, 24959, 24961, 24963