Chapter 3 System of Equations
Chapter 3 System of Equations
or Ax=b
where A =[ aij] is a nxn matrix,
x and b are nx1 matrices or n-dimension vectors;
they are written in column form.
1 0 ... 0
0 1 ... 0
I = ... ... ... ...
0 0 ... 1
where the diagonal elements = 1,
and the off-diagonal elements = 0.
Note: A I = A.
d1 0 ... 0
◊ Diagonal matrix:
0 d2 ... 0
... ... ... ...
0 0 ... dn
u11 u12 ... u1n
◊ Upper-triangular matrix U: U=
0 u22 ... u2n
... ... ... ...
0 0 ... unn
◊ Determinant of A:
n=2: det[A] = |A| = a11 a22 - a12 a21
n
n≥3: det[A] = |A| = (−1)
1+ j a1j |M1j|
j =1
8 9 3 8 9 2
+ 3 1 5 8 - 4 1 5 3 = -36
3 6 0 3 6 9
-1 -1
◊ The inverse, A , of A is defined as A A = I.
Example:
1 − 1 3 1 −1 −1
= − 6 / 5 7 / 5 4 / 5
-1
A = 2 1 2 A
− 2 − 2 1 − 2 / 5 4 / 5 3 / 5
-1 -1
A A = I (you can verify it by multiplying A with A)
Inversion of 2x2 matrices can be done easily as follows:
−1
−1 a b 1 d − b
= =
ad − bc − c a
A
c d
-1
For n>2, it is easier to compute A numerically.
-1
◊ The matrix A is non-singular if A exists.
-1
◊ If A is not singular, Ax = b x = A b
◊ If A is singular, Ax=b x may have multitude or no solution.
◊ Eigenvalues of an nxn matrix are the roots, , of the nth order
polynomial
det (A - I) = 0.
* If A is symmetric, all 's are real.
which is equivalent to 2 − 7 + 10 = 0 .
The solution is: = 2 & = 5
det(A − I n ) = 0
will give all eigenvalues of A.
This equation is called the characteristic equation or
characteristic polynomial of A. It is a polynomial
function in of degree n.
The square matrix A of order n will not have more than n
eigenvalues.
◊ Scalar product of vectors b1 and b2:
n
b1 b2 = b1j b2j or simply b1 b2 = b1j b2j.
j =1
* Examples:
a b e f a e b f
c d g =
h c g d h
1 2 5 6 6 8
3 4 + 7 8 = 10 12 ,
1 2 5 6 − 4 − 4
3 4 − 8 7 = − 5 − 3
* A + B = B + A (commutative property)
n
◊ Multiplication: P = AB pij = aik bkj
k =1
a b ag + bj ah + bk ai + bl
c d g h i
j k l = cg + dj ch + dk ci + dl
e f eg + fj eh + fk ei + fl
1 2 27 30 33
3 4 7 8 9
=
e.g.
10 11 12 61 68 75
5 6 95 106 117
n
|| A || = Max | aij | = max. row sum
1 i n j =1
n n 1/2
|| A ||e = ( aij2 ) = Euclidean or Frobenius norm
i =1 j =1
maximum is 16
|| A ||1 = 16 (column norm)
n T
row sums: | aij | = (17, 10, 16)
j =1
maximum element is 17
|| A || = 17 (row norm)
Euclidean norm || A ||e
1/2
= (25+25+49+16+4+16+49+16+25)
1/2
= 225 = 15.
Sp ectral norm || A ||2: (let A* be conjugate transpose of A)
90 − 5 − 54
A*A = − 5 45 7
− 54 7 90
1 0 0 1.0000 --1*
0 1 0 2.0000 --2*
0 0 1 3.0000 --3*
* The solution vector is
T T
x = (x1, x2, x3) = (1.0000, 2.0000, 3.0000) .
Comments:
* Gauss elimination involves n3/3 multiplication/division.
* Gauss-Jordan method involves n3/2 multiplication/division.
=> Gauss-Jordan method involves 50% more work.
* Gauss-Jordan method is used mainly to find inverse matrix.
◊ Counting:
• First, we need to find the coefficients such as 1/3 and 2/3…
o For each coefficient, it involves 1 division
o The 1st column involves (n-1) divisions
o The 2nd column involves (n-2) divisions.
o …
o Totally, it requires (n-1)+(n-2)+…+3+2+1 = n(n-1)/2
divisions in order to obtain all the coefficients.
3 1 -1 x1 2
◊ Back to 1 4 1 x2 = 12 using Gaussian
2 1 2 x3 10
elimination.
3 1 -1 --- 1'
† (row 2) - (row 1) 1/3 row 2' 0 3.6667 1.3333 --- 2'
(row 3) - (row 1) 2/3 row 3' 0 0.3333 2.6667 --- 3'
1 0 0 3 1 -1
A = 1/3 1 0 0 3.6667 1.3333 = L U
2/3 0.0909 1 0 0 2.5455
U = upper triangular matrix (with diagonal elements ≠ 1)
The non-zero coefficients are from Gaussian elimination.
L = lower triangular matrix (with diagonal elements = 1)
The rest of non-zero coefficients are from the coefficients
used in the Gaussian elimination to get U.
3 0 0 1 1/3 -1/3
A = 1 11/3 0 0 1 4/11 = L1 U1
2 1/3 28/11 0 0 1
3 0 0
where L1 = L 0 11/3 0
0 0 28/11
1/3 0 0
U1 = U 0 3/11 0
0 0 11/28
◊ If we interchanged rows during the reduction step, the resulting
LU=A' is a permutation of A (i.e. by exchanging rows, A' can be
made back into A).
◊ Once LU decomposition is obtained, we can find,
det(A);
& the solution for Ax = b as follows:
Ax = b
A'x = b' where A' = LU or LU x = b'
(due to pivoting=> row exchange so that
the elements of b must be exchanged if A≠A').
Let Ux = y.
Then LUx = b'
Ly = b',
3 1 -1 1 0 0 3 1 -1
Note 1 4 1 = 1/3 1 0 0 3.6667 1.3333
2 1 2 2/3 0.0909 1 0 0 2.5455
1 0 0 y1 2
L y = 1/3 1 0 y2 = 12
2/3 0.0909 1 y3 10
y1 2
y2 = 11.333
y3 7.6364
Since Ux=y
3 1 -1 x1 2
0 3.6667 1.3333 x2 = 11.333
0 0 2.5455 x3 7.6364
x1 1
x2 = 2
x3 3
1 j −1
uij = (aij − likukj ) , i≤j, j=2, 3, ..., n
lii k =1
◊ Note:
0 2 1 --- 1
* Consider A = 1 0 0 --- 2
3 0 1 --- 3
* Interchange row 1 with row 3 to avoid dividing by 0.
3 0 1
A′ = 1 0 0
0 2 1
* We can then proceed to compute L & U of A′.
3 0 1/3
Finally, LU = 0 2 1/2 ,
1 0 -1/3
* Suppose b = [5, -1, -2]T is the RHS of Ax = b.
Then since the original row 1 and row 3 are switched,
b → b' = [-2, 5, -1]T.
Thus, we need to solve LU x = b' as
3 0 0 1 0 1/3 x1 -2
0 2 0 0 1 1/2 x2 = b' = 5
1 0 -1/3 0 0 1 x3 -1
The solution can be easily found as x = [-1, 2, 1]T.
3 0 1 0 1 0
* Pivoting: R2 R 1 1 − 1 2 1 0 0
1 0 2 0 0 1
3 0 1 0 1 0
* Gaussian elimination 0 − 1 1.667 1 − 0.333 0
0 0 1.667 0 − 0.333 1
-6 10 -3 2
1 0 0 0 10 7.0 8.0 7.00 10 7 8 7
0.8 1 0 0 0 0.4 3.6 3.40 8 6 10 9
LU: 0.7 0.25 1 0 0 0 2.5 4.25 = 7 5 9 10 =A′
0.7 0.25 -0.2 1 0 0 0 0.10 7 5 6 5
Eigenvalues: = 0.01015, 0.84311, 3.85806, 30.28869.
Notes organized by Prof. Renwei Mei, University of Florida 29
3.02 -1.05 2.53 -1.61
◊ Consider A = 4.33 0.56 -1.78 , b = 7.23
-0.83 -0.54 1.47 -3.38
Exact solution: x = (1, 2, -1)T
◊ In general, for A x = b x = A-1 b
Expect: small change in some elements of A or b
small change in x.
◊ Now, change a11 from 3.02 to 3.00 ≤ 1% change in a11.
|| x - x* ||2
Hence || x ||2 = 2.068 or 207% ! WHY?
2 2
1 1
0 0
1.01x + 0.99y = 1.98
-1 -1 0.99x + 1.01y = 2.02
-2 -2
-2 -1 0 x 1 2 3 4 -2 -1 0 x 1 2 3 4
107 75 86 75 25 -41 10 -6
-41 68 -17 10
◊ For A = 8 6 10 9 , A-1 = 10 -17 5 -3
7 5 9 10 -6 10 -3 2
use maximum column sum ||A||1 = 33, ||A-1||1 =136
cond(A) = 33*136 = 4216 (quite big!)
Using spectral norm, cond(A) =2984.1 similar magnitude.
* Error in x: e = x - x-
* Residual of eqn. r = b - A x- = b - A (x - e) = A e
due to round-off error.
-1 -1 -1
e=A r || e || = || A r || ≤ || A || || r ||
* Also note: r = A e || r || = || A e || ≤ || A || || e ||
|| r ||
|| e || ≥ || A ||
|| r || -1
Hence || A || ≤ || e || ≤ || A || || r || (1)
* We are interested in how large the relative error of the solution is:
|| e ||
|| x || = ?
* Ax=b || b || ≤ || A || || x ||
-1 -1
* x=A b || x || ≤ || A || || b ||
|| b || -1
|| A || ≤ || x || ≤ || A || || b || (2)
* Combining (1-2)
1 || r || || e || -1 || r ||
-1 ≤ ≤ ||A || || A ||
|| A || || A || || b || || x || || b ||
1 || r || || e || || r ||
or Cond(A) || b || ≤ || x || ≤ Cond(A) || b ||
6 -2 1 x1 11
Consider 1 2 -5 x2 = -1
-2 7 2 x3 5
It is important to have the diagonal elements as large as possible.
6 -2 1 x1 11
-2 7 2 x2 = 5
1 2 -5 x3 -1
3.6.2 Jacobi method
Divide the ith row by aii, express xi as a linear function of other
x's for i=1, 2, 3.
11 2 1
x1 = 6 + 6 x2 - 6 x3 = 1.8333 + 0.3333 x2 - 0.1667 x3
5 2 2
x2 = 7 + 7 x1 - 7 x3 = 0.7143 + 0.2857 x1 - 0.2857 x3
1 1 2
x3 = 5 + 5 x1 + 5 x2 = 0.2 + 0.2 x1 + 0.4 x2
x2n +1 = 0.7143 n
+ 0.2857 x1 - 0.2857 x3
n
x3n +1 = 0.2 n n
+ 0.2 x1 + 0.4 x2
Initial guess: x(0) = (0, 0, 0)T x(1) = (1.833, 0.714, 0.2)T
x\ 0 1 2 ... 7
x1 0 1.833 2.038 2.085 2.00 ... 2.000
n x2n 0
3
0.714 1.181 1.053
4
1.00 ... 1.000
3 4
x3 0 0.2 0.852 1.080 1.03 ... 1.000
3 1
8
a a a b1
0 − 12 − 13 − 14 a
a11 a11 a11
11
− a21 0
a
− 23 −
a24 b2
a a22 a22 a
with C = 22 ; d = 22
a a a b
− 31 − 32 0 − 34 3
a33 a33 a33 a 33
a41 a a b4
− − 42 − 43 0
a44 a44 a44 a 44
n x1 x2 x3
0 0 0 0
1 1.8333 1.23807 1.06189
2 2.06896 1.00202 1.014602
3 1.99817 0.99531 0.997756
4 1.99874 1.00028 0.99986
5 2.00005 1.00005 1.000031
6 1.99994 0.99997 0.999978
n+1 1 i-1 n n n
Jacobi: xi = a ( bi - aij xj - aij xj )
ii j=1 j=i+1
⎯ 1 i-1 n+1 n n
or let xn+1
i
= aii (b i - aij xj - aij xj )
j=1 j=i+1
n+1 n ⎯ n
xi = xi + ( xn+1
i
- xi )
y x
j+
1j y
j-1
i- i i+ x
1 1
2u ui +1, j − 2ui, j + ui −1, j
|
2 (x=xi, y=yj)
= 2
+ O((x)2) (2)
x (x)
An example of 3
surface intersection is
shown on the right.
n x1 x2 x3 Sum |e(i)|
0 2 2 2
1 3.76 2.1 -1.675 5.535
2 3.5729355 1.6528388 -1.41131 0.897916
3 3.6502092 1.7621168 -1.4875564 0.262798
4 3.6271619 1.7231574 -1.4642729 0.08529
5 3.6346066 1.7349801 -1.4718606 0.026855
6 3.6322621 1.7311631 -1.469487 0.008535
7 3.6330071 1.732364 -1.4702437 0.002703
8 3.6327712 1.7319822 -1.4700044 0.000857
9 3.632846 1.732103 -1.4700803 0.000272
10 3.6328223 1.7320647 -1.4700562 8.61E-05
11 3.6328298 1.7320769 -1.4700639 2.73E-05
12 3.6328274 1.732073 -1.4700614 8.65E-06
13 3.6328282 1.7320742 -1.4700622 2.74E-06
14 3.6328279 1.7320738 -1.4700620 8.69E-07
15 3.6328280 1.7320740 -1.4700620 2.76E-07
2 3
instead of 15x 3 m .