Chain Rule

When to Use the Chain Rule

When one function is inside another, usually brackets with an exponent is a good sign to use it:

y=(5x+2)4

How to Apply the Chain Rule

The chain rule is sometimes given the name Outside/Inside Rule, we take the derivative of the outside function and then multiply it by the inside function:

y=(5x+2)4

dy/dx = (Outside Derivative)*(Inside Derivative) = 4(5x+2)3 * (5)

In the above case we took the outside derivative, which moved the 4 to the front of the brackets and then multiplied it by the inside derivative, which is the 5.

Chain Rule in Python 3

Sympy

Import sympy as sym

x = sym.Symbol('x')
sym.diff((5x+2)**4,x) # Derivative of x

The above will output the solution: 20(5x + 2)**3. Depending on your interpreter you may have to wrap it in a print function to get this.

References

https://www.youtube.com/watch?v=H-ybCx8gt-8

https://docs.sympy.org/latest/tutorial/calculus.html

https://towardsdatascience.com/taking-derivatives-in-python-d6229ba72c64