Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Algorithms

This document summarizes several numerical methods for solving systems of linear equations, including: 1) Forward and backward substitution to solve LUx=b for triangular matrices L and U. 2) Gaussian elimination without pivoting to transform Ax=b into Ux=y. 3) LU factorization without pivoting to obtain the factorization A=LU. 4) Gaussian elimination with partial pivoting and LU factorization with partial pivoting, which include row swapping to improve numerical stability. Exercises are provided to implement the partial pivoting LU factorization.

Uploaded by

Jouhar Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Algorithms

This document summarizes several numerical methods for solving systems of linear equations, including: 1) Forward and backward substitution to solve LUx=b for triangular matrices L and U. 2) Gaussian elimination without pivoting to transform Ax=b into Ux=y. 3) LU factorization without pivoting to obtain the factorization A=LU. 4) Gaussian elimination with partial pivoting and LU factorization with partial pivoting, which include row swapping to improve numerical stability. Exercises are provided to implement the partial pivoting LU factorization.

Uploaded by

Jouhar Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2023

Algorithms
Krithika Narayanaswamy

The following are implied unless stated otherwise.

• A is a n × n matrix
• The system being solved is Ax = b
• L and U refer to Lower triangular and Upper triangular matrices respectively.

• Any index range refer to all numbers in that range. For instance, k + 1 : n refers to the range of numbers
k + 1, k + 2, . . . n. Note that this interpretation also applies to such ranges that appear in the row/column indices
of matrices.

1 Solutions to linear algebraic systems of equations


1.1 Forward Substitution
This solves for y in Ly = b. The diagonals of L matrix take the value 1, i.e., ljj = 1.

y1 = b1 (Assign first unknown trivially)


for j = 1 : n do
sum = 0
for k = 1 : j − 1 do
sum = sum − ljk yk
end
yj = sum
end

1.2 Backward Substitution


This solves for x in U x = y.

xn = yn /unn (Assign last unknown trivially)


for j = n − 1 : 1 do
sum = 0
for k = j + 1 : n do
sum = sum − ujk xk
end
xj = sum/ujj
end

Updated on 2023/08/22 at 12:30:10


ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2023

1.3 Gaussian Elimination without pivoting


This transforms Ax = b into U x = y. Equivalently, this transforms an augmented system (A|b) into (U |y). Note that
row operations are performed on both A and b to get the final simpler system U x = y.

U = A, L = I
for k = 1 : n − 1 do
for j = k + 1 : n do
ljk = ujk /ukk (Multiplication factor)
ujk = 0 (Element underneath pivot)
uj,k+1:n = uj,k+1:n − ljk · uk,k+1:n (Row operations)
bj = bj − ljk bk (Row operations on rhs vector)
end
end

1.4 LU factorization without pivoting


This obtains the factorization A = LU . Row operations are performed on A to obtain the U matrix, and the
multiplication factors used in the row operations are wisely assembled to give the L matrix.

U = A, L = I
for k = 1 : n − 1 do
for j = k + 1 : n do
ljk = ujk /ukk (Multiplication factor)
ujk = 0 (Element underneath pivot)
uj,k+1:n = uj,k+1:n − ljk · uk,k+1:n (Row operations)
end
end

Remarks:
1. Row operations are being performed only on columns k + 1 : n on the j th row. This is because

• the first k − 1 column entries on this row will be zero, and


• the k th entry is 0 upon evaluation. This is assigned explicitly so in the previous step.
2. This approach saves on computational time by avoiding operating and evaluating zero values. This is carried
over for the subsequent algorithms coming up as well.

Updated on 2023/08/22 at 12:30:10


ME 5107: Numerical methods in Thermal Engineering Jul–Nov 2023

1.5 Gaussian Elimination with partial pivoting


This transforms Ax = b into U x = y. Equivalently, this transforms an augmented system (A|b) into (U |y). Note that
row operations as well as row swaps have been done on both A and b to get the final simpler system U x = y.

U =A
for k = 1 : n − 1 do
Select q : |uq,k | = max |up,k |
p≥k
uk,k:n ↔ uq,k:n (Row swap)
for j = k + 1 : n do
mult = ujk /ukk (Multiplication factor)
ujk = 0 (Element underneath pivot)
uj,k+1:n = uj,k+1:n − mult · uk,k+1:n (Row operations)
bj = bj − mult · bk (Row operations on rhs vector)
end
end

1.6 LU factorization with partial pivoting


This algorithm results in the factorization P A = LU . Row operations and row swaps are performed on A to obtain
the U matrix, and the multiplication factors used in the row operations are wisely assembled (after suitable swapping)
to give the L matrix. The permutations are stored in P , which is essentially an Identity matrix with its rows swapped
appropriately. Matrices P , L, and U are needed for subsequently solving the original system Ax = b.

U = A, L = I, P = I
for k = 1 : n − 1 do
Select q : |uq,k | = max |up,k |
p≥k
uk,k:n ↔ uq,k:n (Row swap in U matrix)
lk,1:k−1 ↔ lq,1:k−1 (Row swap in L matrix)
pk,1:n ↔ pq,1:n (Row swap in permutation matrix)
for j = k + 1 : n do
ljk = ujk /ukk (Multiplication factor)
ujk = 0 (Element underneath pivot)
uj,k+1:n = uj,k+1:n − ljk · uk,k+1:n (Row operations)
end
end

Exercise:
1. Using the above algorithm, given matrix A as,

 
2 1 1
A = 4 3 3
8 7 9
obtain the L, U , and P matrices.

2. Verify that P A = LU .

Updated on 2023/08/22 at 12:30:10

You might also like