Introduction To Computational Mathematic
Introduction To Computational Mathematic
Mathematical Foundations
Ma
f
Introduction
thematics
lim → 0, (1.4)
Xin-She Yang x→x0 g
c World Scientific
or
(20 08)
f = o(g). (1.5)
3
INTRODUCTION TO COMPUTATIONAL MATHEMATICS
© World Scientific Publishing Co. Pte. Ltd.
[Link]
4 Introduction to Computational Mathematics
Ma
Introduction
thematics
Xin-She Yang and the sum is also a vector. The addition of vectors has commutability
(u + v = v + u) and associativity [(u + v) + w = u + (v + w)]. This
c World Scientific
is
(20 08)
because each of the components is obtained by simple addition which
means it has the same properties.
u w
a v b v
v
u u
The zero vector 0 is a special case where all its components are zeros.
The multiplication of a vector u with a scalar or constant α ∈ ℜ is carried
out by the multiplication of each component,
αu = (αu1 , αu2 , ..., αun ). (1.7)
Thus, we have
−u = (−u1 , −u2 , ..., −un ). (1.8)
The dot product or inner product of two vectors x and y is defined as
n
X
x · y = x1 y1 + x2 y2 + ... + xn yn = xi yi , (1.9)
i=1
which is a real number. The length or norm of a vector x is the root of the
dot product of the vector itself,
v
u n
√ uX
|x| = kxk = x · x = t x2i . (1.10)
i=1
Ma
Introduction
Xin-She Yang
c World Scientific
The angle θ between two vectors u and v can be calculated using their
dot product
(20 08)
u · v = ||u|| ||v|| cos(θ), 0 ≤ θ ≤ π, (1.13)
which leads to
u·v
cos(θ) = . (1.14)
kuk kvk
If the dot product of these two vectors is zero or cos(θ) = 0 (i.e., θ = π/2),
then we say that these two vectors are orthogonal.
Since cos(θ) ≤ 1, then we get the useful Cauchy-Schwartz inequality:
ku · vk ≤ kuk kvk. (1.15)
The dot product of two vectors is a scalar or a number. On the other
hand, the cross product or outer product of two vectors is a new vector
i j k
u = x × y = x1 x2 x3
y1 y2 y3
x2 x3 x x x x
= i+ 3 1 j+ 1 2 k
y2 y3 y3 y1 y1 y2
Ma
Introduction
thematics
Xin-She Yang
Example 1.2: For two 3-D vectors u = (4, 5, −6) and v = (2, −2, 1/2),
c World Scientific
their dot product is
(20 08)
u · v = 4 × 2 + 5 × (−2) + (−6) × 1/2 = −5.
Ma
thematics
Ma
Introduction
thematics
Xin-She Yang Three important operators commonly used in vector analysis, especially
in the formulation of mathematical models, are the gradient operator (grad
c World Scientific
(20 08)
or ∇), the divergence operator (div or ∇·) and the curl operator (curl or
∇×).
Ma
Introduction
Xin-She Yang
the Laplacian operator
c World Scientific
Ma
Introduction
The sum of two matrices A and B is only possible if they have the same
thematics
Xin-She Yang
size m × n, and their sum, which is also m × n, is obtained by adding their
c World Scientific
corresponding entries
(20 08)
C = A + B, cij = aij + bij , (1.42)
and
R R
Z a11 dt a12 dt
Adt = . (1.46)
R R
a21 dt a22 dt
A diagonal matrix A is a square matrix whose every entry off the main
diagonal is zero (aij = 0 if i 6= j). Its diagonal elements or entries may or
may not have zeros. In general, it can be written as
d1 0 ... 0
0 d2 ... 0
D= .. . (1.47)
.
omputational 0 0 ... dn
oC
t
Ma
Introduction
Xin-She Yang
c World Scientific 10 0
(20 08)
I = 0 1 0 (1.48)
00 1
AI = IA = A. (1.49)
A zero or null matrix 0 is a matrix with all of its elements being zero.
There are three important matrices: lower (upper) triangular matrix,
tridiagonal matrix, and augmented matrix, and they are important in the
solution of linear equations. A tridiagonal matrix often arises naturally
from the finite difference and finite volume discretization of partial differ-
ential equations, and it can in general be written as
b1 c1 0 0 ... 0 0
a2 b2 c2 0 ... 0 0
Q = 0 a3 b3 c3 ... 0 0 .
(1.50)
.
.. ..
.
0 0 0 0 ... an bn
An augmented matrix is formed by two matrices with the same number
of rows. For example, the follow system of linear equations
Au = b. (1.53)
Ma
Introduction
Xin-She Yang
a31 a32 a33 b3
c World Scientific
(20 08)
The augmented form is widely used in Gauss-Jordan elimination and linear
programming.
A lower (upper) triangular matrix is a square matrix with all the ele-
ments above (below) the diagonal entries being zeros. In general, a lower
triangular matrix can be written as
l11 0 ... 0
l12 l22 ... 0
L= .. , (1.55)
.
ln1 ln2 ... lnn
while the upper triangular matrix can be written as
u11 u12 ... u1n
0 u22 ... u2n
U = .. . (1.56)
.
0 0 ... unn
Any n × n square matrix A = [aij ] can be decomposed or factorized as a
product of an L and a U , that is
A = LU , (1.57)
2
though some decomposition is not unique because we have n +n unknowns:
n(n + 1)/2 coefficients lij and n(n + 1)/2 coefficients uij , but we can only
provide n2 equations from the coefficients aij . Thus, there are n free pa-
rameters. The uniqueness of decomposition is often achieved by imposing
either lii = 1 or uii = 1 where i = 1, 2, ..., n.
Other LU variants include the LDU and LUP decompositions. An LDU
decomposition can be written as
A = LDU , (1.58)
where L and U are lower and upper matrices with all the diagonal entries
being unity, and D is a diagonal matrix. On the other hand, the LUP
decomposition can be expressed as
A = LU P , or A = P LU , (1.59)
where P is a permutation matrix which is a square matrix and has exactly
omputatione
ona entry 1 in each column and each row with 0’s elsewhere. However, most
oC l
numerical libraries and software use the following LUP decomposition
t
Ma
Introduction
thematics
Xin-She Yang
c World Scientific
P A = LU . (1.60)
(20 08)
which makes it easier to decompose some matrices. However, the require-
ment for LU decompositions is relatively strict. An invertible matrix A
Ma
Introduction
thematics
Xin-She Yang 2 0 0 000 015
c World Scientific
A = D + L + U = 0 −4 0 + 4 0 0 + 0 0 5 .
(20 08) 0 0 −5 520 000
Ma
Introduction
Xin-She Yang
det(A) 6= 0. From the basic definitions, it is straightforward to prove that
c World Scientific
and
(AB)−1 = B −1 A−1 . (1.70)
The inverse of a lower (upper) triangular matrix is also a lower (upper)
triangular matrix. The inverse of a diagonal matrix
d1 0 ... 0
0 d2 ... 0
D= .. , (1.71)
.
0 0 ... dn
can simply be written as
1/d1 0 ... 0
0 1/d2 ... 0
D −1
= .. , (1.72)
.
0 0 ... 1/dn
where di 6= 0. If any of these elements di is zero, then the diagonal matrix
is not invertible as it becomes singular. For a 2 × 2 matrix, its inverse is
simply
ab 1 d −b
A= , A−1 = . (1.73)
cd ad − bc −c a
Ma
Introduction
thematics
and
3
X
D12 = A1j Bj2 = 4 × 3 + 5 × (−2) + 0 × 2 = 2.
j=1
Ma
Introduction
thematics
of
Xin-She Yang a general square matrix is O(n3 ). That is why most modern algorithms
try to avoid the direct inverse of a large matrix. Solution of a large matrix
c World Scientific
(20 08)
system is instead carried out either by partial inverse via decomposition
or by iteration (or a combination of these two methods). If the matrix
Ma
Introduction
thematics
Ma
eA eB = eA+B
Introduction
Xin-She Yang
d tA
c World Scientific
e = AetA = etA A, (1.83)
dt
(eA )−1 = e−A , det(eA ) = etrA .
(20 08)
(1.84)
The matrices we have discussed so far are real matrices because all their
elements are real. In general, the entries or elements of a matrix can be
complex numbers, and the matrix becomes a complex matrix. For a matrix
A, its complex conjugate A∗ is obtained by taking the complex conjugate
of each of its elements. The Hermitian conjugate A† is obtained by taking
the transpose of its complex conjugate matrix. That is to say, for
a11 a12 ...
A = a21 a21 ... , (1.85)
... ... ...
we have
a∗11 a∗12 ...
A∗ = a∗21 a∗22 ... , (1.86)
... ... ...
and
a∗11 a∗21 ...
A† = (A∗ )T = (AT )∗ = a∗12 a22 ... . (1.87)
... ... ...
A square matrix A is called orthogonal if and only if A−1 = AT . If a
square matrix A satisfies A∗ = A, it is called an Hermitian matrix. It is
an anti-Hermitian matrix if A∗ = −A. If the Hermitian matrix of a square
matrix A is equal to the inverse of the matrix (or A† = A−1 ), it is called
a unitary matrix.
Ma
Introduction
Xin-She Yang
c World Scientific 2 − 3iπ e−iπ
(20 08)
A† = 1 − 9i 2i = (A∗ )T .
0 −i sin θ
Ma
Introduction
thematics
Xin-She Yang
c World Scientific
det |A − λI| = 0, (1.91)
(20 08)
and Qi are the intrinsic components along directions of the eigenvectors in
this case.
Ma
(A − λI)u = 0. (1.93)
Introduction
thematics
Xin-She Yang
where I is a unitary matrix with the same size as A. Any non-trivial
c World Scientific
or
a11 − λ a12 ... a1n
a21 a22 − λ ... a2n
.. .. = 0, (1.95)
. .
an1 an2 ... ann
which again can be written as a polynomial
λn + αn−1 λn−1 + ... + α0 = (λ − λ1 )...(λ − λn ) = 0, (1.96)
where λi are the eigenvalues which could be complex numbers. In general,
the determinant is zero, which leads to a polynomial of order n in λ. For
each eigenvalue λ, there is a corresponding eigenvector u whose direction
can be uniquely determined. However, the length of the eigenvector is not
unique because any non-zero multiple of u will also satisfy equation (1.92),
and thus can be considered as an eigenvector. For this reason, it is usually
necessary to apply additional conditions by setting the length as unity, and
subsequently the eigenvector becomes a unit eigenvector.
Generally speaking, a real n × n matrix A has n eigenvalues λi (i =
1, 2, ..., n), however, these eigenvalues are not necessarily distinct. If the
real matrix is symmetric, that is to say AT = A, then the matrix has n
distinct eigenvectors, and all the eigenvalues are real numbers.
The eigenvalues λi are related to the trace and determinant of the matrix
n
X n
X
tr(A) = aii = λ1 + λ2 + ... + λn = λi , (1.97)
i=1 i=1
and
n
Y
det(A) = |A| = λi . (1.98)
i=1
4−λ 9
Ma
Introduction
= 0.
thematics
Xin-She Yang 2 −3 − λ
c World Scientific
We have
(20 08)
(4 − λ)(−3 − λ) − 18 = (λ − 6)(λ + 5) = 0.
Ma
Introduction
thematics
eigenvalues
Xin-She Yang of αA are αλi where α 6= 0 ∈ ℜ. This property becomes handy
when rescaling the matrices in some iteration formulae so that the rescaled
c World Scientific
(20 08)
scheme becomes more stable. This is also the major reason why the pivoting
and removing/rescaling of exceptionally large elements works.
Ma
Introduction
Xin-She Yang
c World Scientific
As the eigenvalues of
12
(20 08) A= ,
21
omputational
oC
t
Ma
Introduction
thematics
Xin-She Yang
c World Scientific
(20 08)