CE206 - System of Linear Equations
CE206 - System of Linear Equations
Gauss Elimination
Forward elimination
Starting with the first row, add or subtract multiples of that row to b li l f h eliminate the first coefficient from the second row and beyond. Continue this process with the second row to remove the second coefficient from the third row and beyond. Stop when an upper triangular matrix remains.
Back substitution
Starting with the last row, solve for the unknown, then substitute that value into the th next hi h t row. t highest Because of the upper-triangular nature of the matrix, each row will contain only one more unknown.
Partial Pivoting
Problems with nave Gauss elimination: a coefficient along the diagonal is 0 or close to 0 Solution: determine the coefficient with the largest absolute value in the column below the pivot element. Switch the rows so that the largest element is the pivot element. Class Exercise: Implement partial pivoting in your GaussNaive m function GaussNaive.m file Also modify the code in a way so that you can display the matrix after each operation. t i ft h ti
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
Tridiagonal systems
A tridiagonal system is a banded system with a bandwidth of 3:
f1 e2 g1 f2 e3 g2 f3 x r x 1 r1 2 2 x 3 r3 = gn1 x n1 rn1 f n x n rn
g3
en1
f n1 en
Tridiagonal systems can be solved using the same method as Gauss elimination, but with much less effort.
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
Tridiagonal solver
function x = T idi ( f f ti Tridiag(e,f,g,r) ) % input: % e = subdiagonal vector % f = diagonal vector % g = superdiagonal vector % r = right hand side vector % output: % x = solution vector n=length(f); % forward elimination for k = 2:n factor = e(k)/f(k-1); f(k) = f(k) - factor*g(k-1); r(k) = r(k) - factor*r(k-1); end % back substitution x(n) = r(n)/f(n); for k = n-1:-1:1 x(k) = (r(k)-g(k)*x(k+1))/f(k); / end
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
LU Factorization
The main advantage is once [ ] is decomposed, the same [ ] g [A] p [L] and [U] can be used for multiple {b} vectors.
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
F1 H2
2 30
90 60
F3
3
Node 1:
F2 V2 V3
Node 2:
Node 3:
F2 + F1 cos 30 + H 2 = 0 F1 sin 30 + V2 = 0
CE 206: Engg. Computation sessional
F2 + F3 cos 60 = 0 F3 sin 60 + V3 = 0
Dr. Tanvir Ahmed
1000lb
F1 H2
2 30
90 60 60
F3
3
1000lb
F2 V2 V3
F1 = 866
Frictionfactor=0.375
45
Frictionfactor=0.25
[Use your free body diagram concept from analytic mechanics and apply Newtons second law] Newton s
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
Stiffness matrix
A f =
a
i=1 j=1 n 1in j=1 1/2
i=1 n n
2 ij
Relative error of the norm of the computed solution will be very sensitive to the relative error in norm of coeff. of [A] If the coefficients of [A] are known to t digit precision, the solution [X] may be valid to only t - log10(Cond[A]) digits. Example:
1 1 / 2 1 / 3 A = 1 / 2 1 / 3 1 / 4 1 / 3 1 / 4 1 / 5