Professional Documents
Culture Documents
Linear Equations Lec. 4.1: Linear Algebra in MATLAB: Dr. Niket Kaisare Department of Chemical Engineering IIT-Madras
Linear Equations Lec. 4.1: Linear Algebra in MATLAB: Dr. Niket Kaisare Department of Chemical Engineering IIT-Madras
EQUATIONS
Lec. 4.1: Linear Algebra in MATLAB
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras
• A vector…
⎡ 2⎤ 3
• Is an ordered set of scalars x=⎢ ⎥
⎣ 3⎦ 2
• Has “dimension” (# of elements)
2x + 4y = 4 2x + 4y = 2
x + 2y = 1
(3, -1) x + 2y = 1 x + 2y = 1
x-y=4
x + 2y =1
x = 3; y = −1
2 x + 3.999 y = 2.001
x + 2y =1
x = 1; y = 0
2 x + 3.999 y = 2
⎡1 2 ⎤
A=⎢ ⎥ Eigenvalues λ1 = −2 ×10− 4 ; λ2 = 4.99;
⎣2 3.999⎦
Useful MATLAB functions
command Purpose command Purpose
expm Matrix exponent inv Inverse of a matrix
logm Matrix logarithm rank Rank of a matrix
sqrtm Matrix square root cond Condition number
^ Matrix Power norm Norm of a vector/matrix
• With + 2,2 as pivot element, repeat the above steps for 8- and below
• … And so on until we obtain upper triangular matrix
Back-Substitution
> -
• !- = ? -,-
> % @? %,- AB
• !% = ? %,%
Assignment Problem
1 2 2 1 1
2 2 4 2 0
G=
1 3 2 5 2
2 6 5 8 4
End of Lecture 4.2
LINEAR EQUATIONS
Lec. 4.3: LU Decomposition; Partial Pivoting
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras
• In this lecture
• LU Decomposition
• Partial Pivoting
LU Decomposition
•+ = IJ, where
J is matrix obtained after Gauss Elimination, and
1 0 ⋯ 0
I = :%," 1 ⋯ 0
:-," :-,% ⋱ ⋮
Gauss Elimination + Partial Pivoting
• Jacobi:
,N − ∑9QN +N,9 !9 ;
!N;O" =
+N,N
• Gauss-Siedel:
;O"
,N − ∑N@"
9R" +N,9 !9 + ∑SNO" +N,9 !9 ;
!N;O" =
+N,N
Gauss Siedel
http://nptel.ac.in/courses/103106074/8
Gauss Siedel
1 2 2 1 1
2 2 4 2 0
G=
1 3 2 5 2
2 6 5 8 4
Tri-Diagonal Matrix
W" = 100
W" − 2 + : W% + W- = ^ : = 0.04
W% − 2 + : W- + W_ = ^
⋮ ⋮ ^ = −1.0
W"" = 25
Tri-Diagonal Matrix