Professional Documents
Culture Documents
COMPUTATIONAL METHODS IN
ENGINEERING
Part 3 – Linear Algebraic Equation
Notice that we have changed our notation for the coefficients from a’s and b’s
to e’s, f’s, g’s, and r’s. This was done to avoid storing large numbers of useless
zeros in the square matrix of a’s.
This space-saving modification is advantageous because the resulting
algorithm requires less computer memory
Where do Tridiagonal Systems Come From in Engineering? (Beams)
d 2 y wLx wx 2
EI 2 = −
dx 2 2
Where do Tridiagonal Systems Come From in Engineering? (Beams)
d 2 y wLx wx 2
EI 2 = −
dx 2 2
d 2 y yi −1 − 2 yi + yi +1
=
dx 2
x 2
yi −1 − 2 yi + yi +1 wLxi wxi2
EI = −
x 2
2 2
x 2 wLxi wxi2
yi −1 − 2 yi + yi +1 = −
EI 2 2
Where do Tridiagonal Systems Come From? (Heat Transfer)
d 2T
2
+ h (Ta − T ) = 0
dx
The Thomas LU Algorithm
(LU Decomposition Version)
+ O ( n2 )
2n 3
8n – 7
3
Cholesky Decomposition
Recall that a symmetric matrix is one where aij = aji for all i and j.
In other words, [A] = [A]T
0 0
b1 − a12 x2 + a13 x3
x1 =
a11
b1
x1 =
a11
Gauss-Seidel
Gauss-Seidel
New x1 is substituted to calculate x2 and x3. The procedure is repeated until
the convergence criterion is satisfied:
xij − xij −1
a ,i = j
100% s
xi
Ei +1 = g’( ) Ei
g
1
x
Gauss-seidel as a Fixed Point Iteration
b1 − a12 x2
x1 =
a11
b2 − a21 x1
x2 =
a22
x1 = g1 ( x1 , x2 )
x2 = g 2 ( x1 , x2 )
Convergence Criteria
g1 g 2 g1 g 2
+ 1 + 1
x1 x1 x2 x2
g 2 a21 g 2
= =0
x1 a22 x2
a21 a12
1 1
a22 a11
Diagonal Dominance
a21 a12
1 1
a22 a11
a22 a21
a11 a12
x new
i = 0.5 x new
i + 0.5 x old
i
Over relaxation ( 1).
= 1.5 :
x new
i = 1.5 x new
i + 0.5 x
old
i
LAPACK MATLAB COMMANDS
Linear algebra
functions in
MATLAB® provide
fast, numerically
robust matrix
calculations.
Capabilities
include a variety of
matrix
factorizations,
linear equation
solving,
computation of
eigenvalues or
singular values,
and more.
LAPACK MATLAB COMMANDS
LAPACK MATLAB COMMANDS
LAPACK MATLAB COMMANDS
LAPACK MATLAB COMMANDS
MATRIX ALGEBRA COMMANDS
MATLAB Functions
x=A\b returns the solution x of Ax = b, obtained by Gauss elimination. If the
equations are overdetermined (A has more rows than columns), the leastsquares
solution is computed.
[L,U] = lu(A) Doolittle’s decomposition A = LU. On return, U is an upper triangular
matrix and L contains a row-wise permutation of the lower triangular matrix.
[M,U,P] = lu(A) returns the same U as above, but now M is a lower triangular matrix
and P is the permutation matrix so that M = P*L. Note that here P*A = M*U.
L = chol(A) Choleski’s decomposition A = LLT .
B = inv(A) returns B as the inverse of A (the method used is not specified).
n = norm(A)returns the largest singular value of matrix A (singular value
decomposition of matrices is not covered in this text).
n = norm(A,inf) returns the infinity norm of matrix A (largest sum of elements in a row
of A).
c = cond(A) returns the condition number of the matrix A (probably based on the
largest singular value of A)
GAUSS ELIMINATION
During back
substitution, b is
overwritten by the
solution vector x, so
that b contains the
solution upon exit
LU DECOMPOSITION CODE
In this version of
LU decomposition
the original A is
destroyed and
replaced by its
decomposed form
[L\U].
LU DECOMPOSITION CODE
This function carries
out the solution
phase (forward and
back substitutions).
It is assumed that
the original
coefficient matrix
has been
decomposed, so
that the input is A =
[L\U].
The contents of b
are replaced by y
during forward
substitution.
Similarly, back
substitution
overwrites y with the
solution x.
CHOLESKY DECOMPOSITION
At the conclusion of
decomposition, L is
extracted with the
MATLAB command
tril(A).
If a negative L2 j j is
encountered during
decomposition, an error
message is printed and
the program is
terminated.
CHOLESKY DECOMPOSITION
After the coefficient matrix A has been decomposed, the solution of Ax = b can be obtained by
the usual forward and back substitution operations. The following function (given without
derivation) carries out the solution phase.
GAUSS SIEDEL
The equations Ax = b are in
scalar notation
GAUSS SIEDEL
It automatically
computes ωopt from
former equation
using k = 10 and p =
1.
The user must
provide the function
func that computes
the improved x from
the iterative formulas
Case Studies: Linear Algebraic Equations
Civil/Environmental Engineering: The matrix inverse is used to
determine the complex cause-effect interactions between forces in
the members of a truss.
Mechanical/Aerospace Engineering: Linear equations are employed
to determine the steady-state configuration of a mass-spring system.
ANALYSIS OF A STATICALLY DETERMINATE TRUSS
Analysis of a Statically Determinate Truss
Analysis of a Statically Determinate Truss
Force Balance in matrix form:
0.866 0 −0.5 0 0 0 F1 0
0.5 0 0.866 0 0 0 F2 −1000
−0.866 −1 0 −1 0 0 F3 0
H =
−0.5 0 0 0 −1 0 2 0
0 1 0.5 0 0 0 V2 0
0 0 −0.866 0 0 −1 V3 0
Solution:
3kx1 − 2kx2 = m1 g
−2kx1 + 3kx2 − kx3 = m2 g
−kx2 + kx2 = m3 g
or in matrix form:
K X = W
where {X} = vector of unknowns, {W} = vector of weights, and [K] is called the
stiffness matrix
3k −2k
K = −2k 3k −k
−k −k
SOLUTION
Substitute parameter values:
30 −20 x1 19.62
−20 30 −10 x = 29.43
2
−10 −10 x3 24.525