MATRICES AND MATRIX OPERATIONS: Unit 27
Dr. Wlodzislaw Kostecki
The Papua New Guinea University of Technology (PNGUT)
Department of Electrical and Communication Engineering
Lae, Morobe Province
Papua New Guinea
Copyright © 2000 by Wlodzislaw Kostecki
All rights reserved
-------------------------------------------------------------------
(27) Differentiation of matrices comprising functions
OBJECTIVES :
• To state the condition necessary for a matrix containing functions of one variable to have a derivative with respect to this variable.
• To introduce the concept of a differentiable matrix.
• To provide a definition of matrix derivative in the form of a symbolic expression.
• To provide an example of a derivative of a rectangular matrix whose elements are functions.
• To provide an example how to determine the largest interval about the origin, in which the derivative of a matrix is defined.
• To specify and illustrate properties of matrix differentiation.
> restart : with(linalg, equal, inverse, orthog, transpose) :
If some or all elements of a matrix [
A
] are
functions
of
one
variable
t
,
it is convenient to denote the matrix as [
A
(
)
] when considering differentiation of such a matrix.
When the elements of a matrix [
A
(
)
] are functions of a
real
variable
and
all
are differentiable with respect to
in some common interval
<
<
,
then a
derivative
of [
A
(
)
] with respect to
may be defined. Then, also the matrix [
A
(
)
] is said to be
differentiable
in the interval
<
<
.
Consider a
(
×
)
matrix [
A
(
)] given as
> A(t) := matrix(2, 3, [a[11](t), a[12](t), a[13](t), a[21](t), a[22](t), a[23](t)]) : 'A(t)' = A(t) ;
The derivative of [
A
(
)
] with respect to
is defined to be the matrix of the same order with elements
, viz.
> `der(A)` := map(Diff, A(t), t) : Diff('A(t)', t) = matrix(`der(A)`) ;
This operation can be displayed in "like-in-a-book" form, viz.
> Diff(A(t), t) = matrix(`der(A)`) ;
For example, let the elements of a
(
×
)
matrix [
A
(
)
] be the functions as shown
> A(t) := matrix(2, 3, [cosh(t), sin(t), cosh(2*t), sinh(t), cos(t), sinh(2*t)]) : 'A(t)' = A(t) ;
The derivative of [
A
(
)
] is the following matrix:
> `der(A)` := map(diff, A(t), t) : Diff('A(t)', t) = matrix(`der(A)`) ;
or, in "like-in-a-book" form,
> Diff(A(t), t) = matrix(`der(A)`) ;
The following example illustrates how to determine the largest interval about the origin, in which a matrix derivative is defined.
Find the largest interval about the origin, in which the derivative of a matrix [ A ] is defined, given that
> A(t) := matrix(2, 3, [2*t^4, tan(t), ln(t^2-3)/2, 2*cos(t), t^2+6, cosh(t)]) : 'A(t)' = A(t) ;
Step 1 . Compute the derivative of [ A ]:
> `der(A)` := map(diff, A(t), t) : Diff('A(t)', t) = matrix(`der(A)`) ;
It may be easily noticed that the functions at locations (1,2) and (1,3) of this matrix have discontinuities. This implies that the matrix is not defined over the entire field of real numbers.
Consequently, it is necessary to determine the interval of either function in which it is continuous and find its part common to both functions.
Step 2 . Find the interval about the origin within which the element at location (1,2) is continuous:
It is a well-known fact that the branch of the function
that goes through the origin is asymptotic to the lines described by the equations
> t[n_a] := -Pi/2 : t[p_a] := Pi/2 : 't[n_a]' = t[n_a] ; 't[p_a]' = t[p_a] ;
where
and
are the end points of the interval with the central point at
within which the function is continuous.
Consequently, the branch of the function
is also asymptotic to the same lines and its values at both end points,
and
,
tend to infinity as shown
>
Limit([`der(A)`[1,2]], t=t[n_a]) = limit(`der(A)`[1,2], t=t[n_a]) ;
Limit([`der(A)`[1,2]], t=t[p_a]) = limit(`der(A)`[1,2], t=t[p_a]) ;
Therefore, the branch of the function
that goes through the origin is continuous in the open interval
(
/2,
/2).
Step 3 . Find the interval about the origin within which the element at location (1,3) is continuous:
It may be easily noticed that this function is discontinuous if its denominator becomes
.
Equating the denominator to
> Eq_denom(el13) := denom(`der(A)`[1,3]) = 0 : Eq_denom(el13) ;
and solving the resultant equation yield
> solution := solve({Eq_denom(el13)}) : solution ;
Let the numerical parts of the solution be assigned the names
and
.
Thus, the points at which the function
/
(
)
is discontinuous are
> t[n_d] := rhs(solution[2][1]) : t[p_d] := rhs(solution[1][1]) : 't[n_d]' = t[n_d] ; 't[p_d]' = t[p_d] ;
The points
and
are the end points of the interval with the central point at
within which the function exists and is continuous.
The function
/
(
)
is not only discontinuous at both end points but also it has no limiting values at these points as shown
>
Limit([`der(A)`[1,3]], t=t[n_d]) = limit(`der(A)`[1,3], t=t[n_d]) ;
Limit([`der(A)`[1,3]], t=t[p_d]) = limit(`der(A)`[1,3], t=t[p_d]) ;
Therefore, the function
/
(
)
is continuous in the open interval
(
,
).
Step 4 . Determine the interval common to both functions:
Since
> t[n_d] < t[n_a] ;
and
> t[p_a] < t[p_d] ;
both functions are continuous within the interval
/2
<
<
/2 and the derivative of matrix [
A
] is defined in this interval.
* * *
N.B.
If two matrices, [
A
(
)
] and [
B
(
)
], are conformable for addition and differentiable in some common interval, the derivative of their sum is equal to the sum of the derivatives of both matrices
For example, let
(
×
)
matrices [
A
(
)
] and [
B
(
)
] be given as
> A(t) := matrix(2, 3, [t, t^3, -1, t^2, 2*t, -3*t^2]) : B(t) := matrix(2, 3, [2, t^2, t^3, -2*t, 3*t^2, -1]) :
> 'A(t)' = A(t) ; 'B(t)' = B(t) ;
(a) The derivative of the sum of the two matrices is the following
(
×
)
matrix:
> `der(A+B)` := map(factor, map(diff, evalm(A(t)+B(t)), t)) :
> Diff(['A(t)' + 'B(t)'], t) = matrix(`der(A+B)`) ;
(b) The sum of the derivatives of both matrices is the following
(
×
)
matrix:
> `der(A) + der(B)` := map(factor, evalm(map(diff, A(t), t) + map(diff, B(t), t))) :
> Diff('A(t)', t) + Diff('B(t)', t) = matrix(`der(A) + der(B)`) ;
Both matrices of (a) and (b) are equal by inspection.
* * *
N.B. The derivative of the product of a scalar (number) and a matrix is equal to the product of the scalar and the matrix derivative
For example, consider a
(
×
)
matrix [
A
(
)
] given as
> A(t) := matrix(2, 3, [t, t^3, -1, t^2, 2*t, -3*t^2]) : 'A(t)' = A(t) ;
and the scalar
.
> k := 3 :
(a) The derivative of the product of the scalar and the matrix is the following
(
×
)
matrix:
> `der(kA)` := map(diff, evalm(k * A(t)), t) : Diff(['k*A(t)'], t) = matrix(`der(kA)`) ;
(b) The product of the scalar and the matrix derivative is the following
(
×
)
matrix:
> `k der(A)` := evalm(k * map(diff, A(t), t)) : 'k' * Diff('A(t)', t) = matrix(`k der(A)`) ;
Both matrices of (a) and (b) are equal by inspection.
* * *
N.B.
If two matrices, [
A
(
)
] and [
B
(
)
], are conformable for multiplication and differentiable in some common interval, the derivative of their product is equal to the product of the derivative of the pre-multiplier and the post-multiplier plus the product of the pre-multiplier and the derivative of the post-multiplier
For example, consider a
(
×
)
matrix [
A
(
)
] given as
> A(t) := matrix(2, 3, [t, t^3, -1, t^2, 2*t, -3*t^2]) : 'A(t)' = A(t) ;
and a
(
×
)
matrix [
B
(
)
] given as
> B(t) := matrix(3, 3, [2*t^2, -3*t, t, t^3, -3*t^2, 2, 2*t^3, -2*t, 2*t^2]) : 'B(t)' = B(t) ;
(a) The derivative of the matrix product is the following
(
×
)
matrix:
> `der(AB)` := map(sort, map(factor, map(diff, evalm(A(t) &* B(t)), t))) :
> Diff(['A(t)' * 'B(t)'], t) = matrix(`der(AB)`) ;
(b) The product of the derivative of the pre-multiplier and the post-multiplier plus the product of the pre-multiplier and the derivative of the post-multiplier is the following
(
×
)
matrix:
> `der(A) B + A der(B)` := map(sort, map(factor, evalm(map(diff, A(t), t) &* B(t) + A(t) &* map(diff, B(t), t)))) :
> Diff('A(t)', t) * 'B(t)' + 'A(t)' * Diff('B(t)', t) = matrix(`der(A) B + A der(B)`) ;
The equal function applied to the resultant matrices of (a) and (b), i.e.
> equal(`der(AB)`, `der(A) B + A der(B)`) ;
returns the
Boolean
value
, which verifies that both matrices are equal.
* * *
N.B.
It follows immediately from the above ( by setting [
B
(
)
]
=
[
A
(
)
] ) that for a square matrix [
A
(
)
], in general,
is not equal to
but
For example, consider a
(
×
)
matrix [
A
(
)
] given as
> A(t) := matrix(2, 2, [2, t^2, t^3, 1]) : 'A(t)' = A(t) ;
(a) The derivative of the matrix squared is the following
(
×
)
matrix:
> `der(A^2)` := map(diff, evalm(A(t)^2), t) : Diff(['A(t)']^2, t) = matrix(`der(A^2)`) ;
(b) The doubled product of the matrix and its derivative is the following
(
×
)
matrix:
> `2A der(A)` := evalm(2*A(t) &* map(diff, A(t), t)) : 2 * 'A(t)' * Diff('A(t)', t) = matrix(`2A der(A)`) ;
which is evidently not equal to the derivative of the matrix squared.
According to the formula for the derivative of [
A
(
)
]
^2,
its right-hand side is needed for display in the next step. This, however, turns out to be normally impossible due to
Maple
’
s internal evaluations, which yield this unwanted result
> Diff('A(t)', t) * 'A(t)' + 'A(t)' * Diff('A(t)', t) ;
To get around this problem, a special undocumented command gensym must be used. This command gen erates a syn onym for a variable, i.e. a variable, which looks the same as the original one, but has a different machine address and so is considered by Maple to be different.
(c) The product of the matrix derivative and the matrix plus the product of the matrix and its derivative is the following
(
×
)
matrix:
> `der(A) A + A der(A)` := evalm(evalm(map(diff, A(t), t) &* A(t)) + evalm(A(t) &* map(diff, A(t), t))) :
> Diff('A(t)', t) * `tools/gensym`(A)(t) + 'A(t)' * Diff('A(t)', t) = matrix(`der(A) A + A der(A)`) ;
which is equal to the derivative of the matrix squared.
* * *
N.B.
If a matrix [
A
(
)
] is an
orthogonal
matrix, then and
only
then
For example, consider a
(
×
)
matrix [
A
(
)
] given as
> A(t) := matrix(2, 2, [cos(t), -sin(t), sin(t), cos(t)]) : 'A(t)' = A(t) ;
(a) Check whether [
A
(
)
] is an orthogonal matrix:
> orthog(A(t)) ;
(b) The derivative of the matrix squared is the following
(
×
)
matrix:
> `der(A^2)` := map(combine, map(diff, evalm(A(t)^2), t)) : Diff(['A(t)']^2, t) = matrix(`der(A^2)`) ;
(c) The doubled product of the matrix and its derivative is the following
(
×
)
matrix:
> `2A der(A)` := map(combine, evalm(2*A(t) &* map(diff, A(t), t))) :
> 2 * 'A(t)' * Diff('A(t)', t) = matrix(`2A der(A)`) ;
Both matrices of (b) and (c) are equal by inspection.
* * *
N.B.
If the matrix [
A
(
)
] is a
non-singular
matrix, then the derivative of the matrix inverse is equal to the negative product of the matrix inverse, derivative, and inverse
For example, consider a
(
×
)
matrix [
A
(
)
] given as
> A(t) := matrix(2, 2, [1, t, 2, t^2]) : 'A(t)' = A(t) ;
(a) The derivative of the inverse of [
A
(
)
] is the following
(
×
)
matrix:
> `der(inv(A))` := map(simplify, map(diff, inverse(A(t)), t)) : Diff(Inv('A(t)'), t) = matrix(`der(inv(A))`) ;
(b) The negative product of the inverse of [
A
(
)
], derivative of [
A
(
)
], and inverse of [
A
(
)
] is the following
(
×
)
matrix:
> `-inv(A) der(A) inv(A)` := map(simplify, evalm(-inverse(A(t)) &* map(diff, A(t), t) &* inverse(A(t)))) :
> `–Inv`('A(t)') * Diff('A(t)', t) * Inv('A(t)') = matrix(`-inv(A) der(A) inv(A)`) ;
The equal function applied to the resultant matrices of (a) and (b), i.e.
> equal(`der(inv(A))`, `-inv(A) der(A) inv(A)`) ;
returns the
Boolean
value
, which verifies that both matrices are equal.
* * *
N.B. The derivative of a constant matrix [ K ] is the zero matrix of the same order
=
[
0
]
For example, consider a
(
×
)
matrix [
K
] given as
> K := matrix(2, 3, [1, b, a^2, a, b^2, c]) : K = matrix(K) ;
The derivative of [
K
] is the following
(
×
)
zero
matrix:
> `der(K)` := map(diff, K, t) : Diff(K, t) = matrix(`der(K)`) ;
* * *
N.B.
If two
square
non-singular
matrices, [
A
(
)
] and [
B
(
)
], are differentiable in some common interval, the derivative of the inverse of their product is equal to the product of the derivative of the inverse of the post-multiplier and the inverse of the pre-multiplier plus the product of the inverse of the post-multiplier and the derivative of the inverse of the pre-multiplier
For example, consider
(
×
)
matrices [
A
(
)
] and [
B
(
)
] given as
> A(t) := matrix(2, 2, [t, 1, -1, t^2]) : B(t) := matrix(2, 2, [2, t^2, t^3, 1]) : 'A(t)' = A(t) ; 'B(t)' = B(t) ;
(a) The derivative of the inverse of the product of both matrices is the following
(
×
)
matrix:
> `der(inv(AB))` := map(sort, map(factor, map(diff, inverse(evalm(A(t) &* B(t))), t))) :
> Diff(Inv('A(t)' * 'B(t)'), t) = matrix(`der(inv(AB))`) ;
(b) The product of the derivative of the inverse of the post-multiplier and the inverse of the pre-multiplier plus the product of the inverse of the post-multiplier and the derivative of the inverse of the pre-multiplier is the following
(
×
)
matrix:
> `der(inv(B)) inv(A) + inv(B) der(inv(A))` := map(sort, map(factor, evalm(map(diff, inverse(B(t)), t) &* inverse(A(t)) + inverse(B(t)) &* map(diff, inverse(A(t)), t)))) :
> Diff(Inv('B(t)'), t) * Inv('A(t)') + Inv('B(t)') * Diff(Inv('A(t)'), t) = matrix(`der(inv(B)) inv(A) + inv(B) der(inv(A))`) ;
The equal function applied to the resultant matrices of (a) and (b), i.e.
> equal(`der(inv(AB))`, `der(inv(B)) inv(A) + inv(B) der(inv(A))`) ;
returns the
Boolean
value
, which verifies that both matrices are equal.
* * *
N.B.
If two
square
non-singular
matrices, [
A
(
)
] and [
B
(
)
], are differentiable in some common interval, the derivative of the transpose of their product is equal to the product of the derivative of the transpose of the post-multiplier and the transpose of the pre-multiplier plus the product of the transpose of the post-multiplier and the derivative of the transpose of the pre-multiplier
For example, consider the same
(
×
)
matrices [
A
(
)
] and [
B
(
)
] as before.
(a) The derivative of the transpose of the product of both matrices is the following
(
×
)
matrix:
> `der(transp(AB))` := map(diff, transpose(evalm(A(t) &* B(t))), t) :
> Diff(Transp('A(t)' * 'B(t)'), t) = matrix(`der(transp(AB))`) ;
(b) The product of the derivative of the transpose of the post-multiplier and the transpose of the pre-multiplier plus the product of the transpose of the post-multiplier and the derivative of the transpose of the pre-multiplier is the following
(
×
)
matrix:
> `der(transp(B)) transp(A) + transp(B) der(transp(A))` := evalm(map(diff, transpose(B(t)), t) &* transpose(A(t)) + transpose(B(t)) &* map(diff, transpose(A(t)), t)) :
> Diff(Transp('B(t)'), t) * Transp('A(t)') + Transp('B(t)') * Diff(Transp('A(t)'), t) = matrix(`der(transp(B)) transp(A) + transp(B) der(transp(A))`) ;
The equal function applied to the resultant matrices of (a) and (b), i.e.
> equal(`der(transp(AB))`, `der(transp(B)) transp(A) + transp(B) der(transp(A))`) ;
returns the
Boolean
value
, which verifies that both matrices are equal.
* * *
Proceed to Unit (28) for " Limits of matrices comprising functions ".
-------------------------------------------------------------------