(*Video 1: Chain rule*)

(*Chain rule:to differentiate a composition,take the derivative of outside function computed at the inside function and multiply by the derivative of the inside function*)
D[f[g[x]],x]
D[g[f[x]],x]

(*Example 1*)
f[x_]:=E^x
g[x_]:=x^2+3x+1

f[g[x]] 
D[f[g[x]],x]

g[f[x]]
D[g[f[x]],x]

(*Example 2*)
D[Cos[4 x+2],x]

(*Example 3*)
D[Sin[E^(7x)],x]

(*More layers,apply rule inductively*)
D[a[f[g[h[x]]]],x]

(*Example 4*)
D[E^(Sin[2x^2]),x]