0% found this document useful (0 votes)
13 views3 pages

Numerical Methods for Thermal Engineering

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 5) LU factorization with partial pivoting, which include row swapping to improve numerical stability. Exercises are provided to implement the LU factorization with partial pivoting algorithm.

Uploaded by

Jouhar Sheikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Numerical Methods for Thermal Engineering

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 5) LU factorization with partial pivoting, which include row swapping to improve numerical stability. Exercises are provided to implement the LU factorization with partial pivoting algorithm.

Uploaded by

Jouhar Sheikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

Common questions

Powered by AI

In Gaussian elimination and LU factorization, performing row operations only on certain sections of the matrix, specifically on columns k+1 to n, after certain pivot operations reduces unnecessary computations. The first k-1 columns of a row become zero due to previous operations, eliminating the need to operate on them, thus saving computational resources. This approach focuses calculations on non-zero elements, avoiding futile operations on zero entries and enhancing the overall efficiency of the algorithm, particularly in larger matrices .

To verify that P, L, and U satisfy PA = LU after LU factorization with partial pivoting, one must perform matrix multiplication operations in sequence. First, calculate the product of L and U to obtain LU. Then, multiply the permutation matrix P by the original matrix A to obtain PA. If both resulting matrices LU and PA are equivalent, the factorization is verified to be accurate. This verification confirms that the transformations and row swaps done during factorization have faithfully reconstructed the modified system that equates the original matrix transformed into its LU components .

LU factorization with partial pivoting results in the decomposition PA = LU where P is a permutation matrix that keeps track of row swaps. This approach enhances numerical stability and reliability by mitigating potential issues caused by small pivot elements, which can lead to large rounding errors. Unlike LU factorization without pivoting, which may struggle with ill-conditioned matrices, the incorporation of a permutation matrix helps provide a more accurate and stable solution by properly organizing the matrix elements before factorization .

Multiplication factors, calculated as the ratio of the current element to the pivot element, are utilized in Gaussian elimination to perform row operations that eliminate elements below the pivot in the column. By multiplying these factors with respective row entries of the pivot row and subtracting from the current row, rows are effectively transformed to create zeros below the pivot element. This process systematically transforms matrix A into an upper triangular matrix U, streamlining further calculations for solving Ux = y in the latter stages of linear equation solving .

Setting the diagonal elements of the L matrix to 1 during forward substitution simplifies calculations as it eliminates the need to divide by these diagonal values when solving for each y in Ly = b. By assigning ljj to be 1, each unknown y can be determined directly using the previous results without additional computations for diagonal scaling. This assumption provides consistency and simplification in deriving solutions, specifically facilitating quick evaluation steps in forward substitutions within triangular matrix systems .

In LU factorization with partial pivoting, the permutation matrix P is constructed by initially setting it as an identity matrix and then performing row swaps corresponding to those in the U matrix. This matrix keeps track of the row interchanges needed to maintain numerical stability and ensures that operations on A maintain consistency across the system. The permutation matrix enables the transformation PA = LU, where L and U are computed after necessary row adjustments via P. This decomposition aids efficiently solving the original system Ax = b by permitting stable linear solutions via transformations adhered by P .

Gaussian elimination without pivoting transforms the system Ax = b into Ux = y by performing row operations on both A and b to simplify the system. In contrast, Gaussian elimination with partial pivoting includes row swapping to ensure numerical stability by maximizing the absolute value of the pivot element. This is crucial to handle matrices that may lead to large numerical errors or instability during computations. The pivoting process reduces rounding errors and enhances the precision of the solution, making it particularly important for ill-conditioned matrices .

Partial pivoting in LU factorization enhances stability by selecting the maximum value of potential pivot elements, reducing the risk of performing division by small numbers that could lead to substantial numerical errors. This method contrasts with simple Gaussian elimination, which might not account for the magnitude of pivot elements, risking increased errors in operations. By adjusting rows through pivoting first, the method ensures that the numerical algorithms are more robust to variations in input data and can handle a wider range of matrices more efficiently, reducing potential for catastrophic error accumulation .

Forward substitution is used to solve for y in the equation Ly = b, where L is a lower triangular matrix with ones on its diagonal. It involves assigning the first unknown trivially and computing subsequent y values using previous y values, iterating from j = 1 to n. Backward substitution then takes the solution y and solves for x in Ux = y, where U is an upper triangular matrix. It starts by assigning the last unknown trivially and works backwards using computed x values, iterating from j = n-1 to 1. These steps collectively transform the original system of equations into a form that is straightforward to solve .

Gaussian elimination without pivoting can be ineffective in scenarios involving ill-conditioned matrices where small deviations in data can cause large errors in solutions due to insufficient handling of pivot elements. It may fail to accurately solve if a pivot element is zero or very close to zero, leading to division by small values and amplifying errors. Partial pivoting addresses these issues by rearranging the rows to use the largest possible pivot element in each step, minimizing errors and ensuring that the operations remain stable and consistent throughout the process, effectively reducing numerical instability .

You might also like