1 example 1

Chain Rule
Recall the formula for the derivative of the composition of functions
(hereafter,
∂
∂x
% means Dx %, the derivative with respect to the variable x)
∂
∂x
∂
∂
f(g(x)) = ( ∂u
f(u))u=g(x) ( ∂x
g(x)) (1)
That is, the derivative of the composition is the product of two things:
1. The derivative of f with respect to its argument and then evaluated
at g(x)
2. The derivative of g(x) with respect to x.
In practice, let u(x) be some function in x, we often use the following
formulas
∂
∂x
∂
∂x
∂
∂x
∂
u(x)n = n u(n−1) ( ∂x
u(x)) (2)
∂
sin(u(x)) = cos(u(x)) ( ∂x
u(x)) (3)
∂
cos(u(x)) = −sin(u(x)) ( ∂x
u(x)) (4)
∂
∂x
tan(u(x)) =
∂
∂x u(x)
cos(u(x))2
(5)
In particular, for any constant k , (3), (4), (5) imply the followings
∂
∂x
∂
∂x
sin(k x) = k cos(kx ) (3a)
cos(k x) = (−k) sin(kx ) (4a)
∂
∂x
tan(k x) =
k
cos(kx )2
(5a)
In the first two examples, we will apply the very general form of the chain
rule (1). The other will make use of (2)-(6)
1
example 1
F:=x->(x^3-4*x^2+1)^100;
F := x → (x3 − 4 x2 + 1)100
We think of F(x) as the composition of two functions
>
f:=u->u^100; g:=x->x^3-4*x^2+1;
f := u → u100
g := x → x3 − 4 x2 + 1
In fact, the composition fog = f(g(x)) is
>
f(g(x));
(x3 − 4 x2 + 1)100
>
1
which is exactly F(x)
We can compute the derivatives of f and g easily by using the power rule
>
deriv_of_f:=u->diff(f(u),u); deriv_of_g:=x->diff(g(x),x);
deriv of f := u → diff(f(u), u)
deriv of g := x → diff(g(x), x)
Evaluating these
>
deriv_of_f(u);
100 u99
>
deriv_of_g(x);
3 x2 − 8 x
Evaluating the derivative of f at u = g(x) gives
>
subs(u=g(x),deriv_of_f(u));
100 (x3 − 4 x2 + 1)99
Finally, the derivative of the composition ( F(x)) is the product of the last
two things.
>
subs(u=g(x),deriv_of_f(u))*deriv_of_g(x);
100 (x3 − 4 x2 + 1)99 (3 x2 − 8 x)
Check with Maple
>
diff(F(x),x);
100 (x3 − 4 x2 + 1)99 (3 x2 − 8 x)
2
example 2
Consider the function
>
F:=x->cos(sin(x)) + tan(x^2+x);
F := x → cos(sin(x)) + tan(x2 + x)
We think of F(x) as the sum of two compositions
The first is composed by
>
f:=u->cos(u); g:=x->sin(x);
f := cos
g := sin
In fact, the composition fog = f(g(x)) is
>
f(g(x));
cos(sin(x))
which is exactly the first term in F(x).
The second term is composed by
>
p:=u->tan(u); q:=x->x^2+x;
p := tan
q := x → x2 + x
In fact, the composition is
>
p(q(x));
tan(x2 + x)
2
We can compute the derivatives of f and g easily by using the Trig rule
>
deriv_of_f:=u->diff(f(u),u); deriv_of_g:=x->diff(g(x),x);
deriv of f := u → diff(f(u), u)
deriv of g := x → diff(g(x), x)
Evaluating these
>
deriv_of_f(u);
−sin(u)
>
deriv_of_g(x);
cos(x)
Evaluating the derivative of f at u = g(x) gives
>
subs(u=g(x),deriv_of_f(u));
−sin(sin(x))
The derivative of the composition f(g(x)) is the product of the last two
things.
>
first_deriv:=subs(u=g(x),deriv_of_f(u))*deriv_of_g(x);
first deriv := −sin(sin(x)) cos(x)
We can compute the derivatives of p and q easily by using the Trig and power
rule
>
deriv_of_p:=u->diff(p(u),u); deriv_of_q:=x->diff(q(x),x);
deriv of p := u → diff(p(u), u)
deriv of q := x → diff(q(x), x)
Evaluating these
>
deriv_of_p(u);
1 + tan(u)2
>
deriv_of_q(x);
2x + 1
Evaluating the derivative of f at u = g(x) gives
>
subs(u=q(x),deriv_of_p(u));
1 + tan(x2 + x)2
The derivative of the composition p(q(x)) is the product of the last two
things.
>
second_deriv:=subs(u=q(x),deriv_of_p(u))*deriv_of_q(x);
second deriv := (1 + tan(x2 + x)2 ) (2 x + 1)
Finally, the derivative of F(x) is the sum of the derivatives found above.
>
first_deriv + second_deriv;
−sin(sin(x)) cos(x) + (1 + tan(x2 + x)2 ) (2 x + 1)
Check with Maple
>
diff(F(x),x);
−sin(sin(x)) cos(x) + (1 + tan(x2 + x)2 ) (2 x + 1)
3
3
example 3
Consider
>
F:=x->(sin(2*x)+2*cos(3*x))^100;
F := x → (sin(2 x) + 2 cos(3 x))100
Using (2) with n=100 and
>
u:=x->sin(2*x)+2*cos(3*x);
u := x → sin(2 x) + 2 cos(3 x)
we have
>
100*u(x)^99*Diff(u(x),x);
∂
100 (sin(2 x) + 2 cos(3 x))99 (
(sin(2 x) + 2 cos(3 x)))
∂x
For the derivative of u(x) we can use the formulas (3a) and (4a) with k = 2, 3
>
Diff(u(x),x) = 2*cos(2*x)-2*3*sin(3*x);
∂
(sin(2 x) + 2 cos(3 x)) = 2 cos(2 x) − 6 sin(3 x)
∂x
Finally,
>
Diff(F(x),x) = 100*u(x)^99*diff(u(x),x);
∂
(sin(2 x)+2 cos(3 x))100 = 100 (sin(2 x)+2 cos(3 x))99 (2 cos(2 x)−6 sin(3 x))
∂x
Using Maple, we have
>
Diff(F(x),x) = diff(F(x),x);
∂
(sin(2 x)+2 cos(3 x))100 = 100 (sin(2 x)+2 cos(3 x))99 (2 cos(2 x)−6 sin(3 x))
∂x
4
example 4
Consider
>
F:=x->sin((x^3+x)^50);
F := x → sin((x3 + x)50 )
Using (3) with
>
u:=x->(x^3+x)^50;
u := x → (x3 + x)50
we have
>
Diff(F(x),x)=cos(u(x))*Diff(u(x),x);
∂
∂
sin((x3 + x)50 ) = cos((x3 + x)50 ) (
(x3 + x)50 )
∂x
∂x
For the derivative of u(x) we can use the formulas (2) with n=50 and the
derivative of polynomials (power rule)
>
Diff(u(x),x) = 50*(x^3+x)^49*diff(x^3+x,x);
∂
(x3 + x)50 = 50 (x3 + x)49 (3 x2 + 1)
∂x
Finally,
>
Diff(F(x),x) = cos(u(x))*diff(u(x),x);
∂
sin((x3 + x)50 ) = 50 cos((x3 + x)50 ) (x3 + x)49 (3 x2 + 1)
∂x
4
Using Maple, we have
>
Diff(F(x),x) = diff(F(x),x);
∂
sin((x3 + x)50 ) = 50 cos((x3 + x)50 ) (x3 + x)49 (3 x2 + 1)
∂x
5