0% found this document useful (0 votes)
30 views13 pages

6.2 Pivoting Strategies

The document discusses linear systems of equations with a focus on Gaussian elimination and the importance of pivoting to minimize round-off errors. It explains the process of forward elimination and backward substitution, emphasizing the need for selecting appropriate pivot elements to avoid inaccuracies. Additionally, it introduces partial pivoting as a strategy to improve the reliability of the Gaussian elimination method in solving linear systems.

Uploaded by

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

6.2 Pivoting Strategies

The document discusses linear systems of equations with a focus on Gaussian elimination and the importance of pivoting to minimize round-off errors. It explains the process of forward elimination and backward substitution, emphasizing the need for selecting appropriate pivot elements to avoid inaccuracies. Additionally, it introduces partial pivoting as a strategy to improve the reliability of the Gaussian elimination method in solving linear systems.

Uploaded by

vqqh5fnvfh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Sec:6.

Linear systems of
Equations
(Pivoting)
Sec:6.1 Linear systems of Equations

From section 1.2, recall that the division by a small number or multiplication by a large
number can magnify the round-off error. Here an example from section 1.2:

determine the five-digit values of , and .


Sec:6.1 Linear systems of Equations

Gaussian elimination (Direct Method)


STEP (1) Forward elimination
Linear system Upper triangular system

𝒂 𝒋𝒊
𝑹𝒋 − 𝑹𝒊 → 𝑹𝒋 , 𝒊+ 𝟏 ≤ 𝒋 ≤ 𝒏
𝒂 𝒊𝒊

Elementary row
operations

STEP (2)backward substitution


Use last equation to find 𝑎𝑛 ,𝑛 +1
→ 𝑥𝑛=
𝑎𝑛 , 𝑛
Use equation to find
𝑛

In general 𝑥 = 𝑎 𝑖 , 𝑛 +1 − ∑ 𝑎𝑖 , 𝑗 𝑥 𝑗
𝑗 =𝑖+ 1
𝑖 , 𝑖 =𝑛 − 1 , 𝑛 − 2 , … , 2 , 1.
𝑎𝑖 , 𝑖
Sec:6.2 Linear systems of Equations (Pivoting)
Remark

Based on the previous discussion, we conclude that the Gaussian elimination method
may become unreliable when the nonzero pivot element is relatively too small.

In the next example, even for small systems, we will see that round-off error can dominate the
calculations when the pivot element is relatively too small.

Solution: The augmented matrix of the linear system using four-digit rounding is:
5.291
𝐸2− −2
𝐸1 → 𝐸2
|
0.3 ∗ 10
( 0 .3 ∗1 0− 2
5.291 |
59.14 5 9.17
− 6.130 46.78 ) (
0 .3 ∗1 0− 2
0
59.14 5 9.17
− 104300 − 104400 )
Sec:6.2 Linear systems of Equations (Pivoting)

By backward substitution, we get

Note: In the previous example, the pivot element is very small compared to 5.291. Thus,
the evaluation of the multiplier enlarged the round-off error and ruined the
approximation.

Note: In order to avoid large round-off error, we need to ensure that the pivot element is
not relatively too small.
Sec:6.2 Linear systems of Equations (Pivoting)
Example

Difficulties can arise when the pivot


element is small relative to
the entries below it.

[ ] 𝑏= 1
[]
− 20
𝐴= 10 1
1 1 0

Partial Pivoting
Before forward elimination starts, it is
advantageous to determine the coefficient
Suppose has the largest absolute value in the with the largest absolute value in the
column below the pivot element. Then we column below the pivot element. The rows
perform the row swapping: can then be swapped so that the largest
element is the pivot element.
Sec:6.2 Linear systems of Equations (Pivoting)
Example

Difficulties can arise when the pivot


element is small relative to
the entries

[ ] []
𝑏= 1
− 20
𝐴= 10 1
1 1 0

partial pivoting is to select an element in the


Partial Pivoting same column that is below the diagonal and has
the largest absolute value; specifically, we
Before forward elimination starts, it is determine
advantageous to determine the coefficient with
the largest absolute value in the column the smallest such that
( 𝒌) ( 𝒌)
below the pivot element. The rows can then ∣ 𝒂 𝒑𝒌 ∣=𝐦𝐚𝐱 ∣ 𝒂𝒑𝒌 ∣
be switched so that the largest element is the 𝒌≤ 𝒊 ≤ 𝒏
pivot element.
and perform
Partial pivoting is performed by selecting an
element with a larger magnitude as the pivot
and interchanging the k-th and p-th rows.
Sec:6.2 Linear systems of Equations (Partial Pivoting)

R1R3 R2-(1/2)R1R2

R3-(1/4)R1R3
R4-(6/8)R1R4

R2R4

R3R4 Row
Operations

Row
Operations
Sec:6.2 Linear systems of Equations

Solution: The augmented matrix of the linear system using four-digit rounding is:

𝑅2 𝑅1
( | ) ( 5.291
|
6.130 4 6.78
)
−2
0 .3 ∗1 0 59.14 5 9.17 ↔
−2
5.291 − 6.130 46.78 0 .3 ∗ 1 0 59.14 59.17

−2
0.3 ∗ 10
𝐸2− 𝐸1 → 𝐸2
( 5.291
0 .3 ∗ 1 0− 2 |
6.130 4 6.78
59.14 59.17 ) 5.291
( 5.291
0 |
− 6.130 4 6.78
59.14 59.14 )
Sec:6.2 Linear systems of Equations

Remark

Although the Gaussian elimination with partial pivoting is a valid method for solving
many linear systems, it can be unreliable for solving some types of linear systems. For
instance, when the coefficient matrix is badly scaled; that is some of its elements are too
large compared to the other elements, the Gaussian elimination with partial pivoting may
fail. In such a case, other pivoting strategies shall be used.

Pivoting Strategies

Partial Pivoting

Scaled Partial Pivoting

Complete Pivoting
Sec:6.2 Linear systems of Equations
(Pivoting
Sec:6.2 Linear systems of Equations
)
function x = gauss_elimination_pivoting(A, b)
% Get the size of the matrix A
[n, m] = size(A);

Example % Check if A is a square matrix


if n ~= m
error('Matrix A must be square');
Use the Gaussian Elimination to end
solve the following linear % Augment the matrix A with the vector b
systems Ab = [A, b];

% Perform Gaussian elimination with partial pivoting

[ ] []
𝑏= 1
for i = 1:n-1
− 20
𝐴= 10 1
% Find the maximum element in the current column
1 1 0 [~, maxIndex] = max(abs(Ab(i:n, i)));
maxIndex = maxIndex + i - 1;

% Swap rows if necessary


if maxIndex ~= i
Solution Ab([i, maxIndex], :) = Ab([maxIndex, i], :);
end

% Forward elimination
for j = i+1:n
factor = Ab(j, i) / Ab(i, i);
Ab(j, i:n+1) = Ab(j, i:n+1) - factor * Ab(i, i:n+1);
end
end

% Back substitution
x = zeros(n, 1);
x(n) = Ab(n, n+1) / Ab(n, n);
for i = n-1:-1:1
x(i) = (Ab(i, n+1) - Ab(i, i+1:n) * x(i+1:n)) / Ab(i, i);
end
end
Sec:6.2 Linear systems of Equations (Pivoting
)
function x = gauss_elimination_pivoting(A, b)
% Get the size of the matrix A
Find the row interchanges that are required [n, m] = size(A);
to solve the following linear systems using
% Check if A is a square matrix
Partial Pivoting if n ~= m
error('Matrix A must be square');
end

% Augment the matrix A with the vector b


Ab = [A, b];

% Perform Gaussian elimination with partial pivoting


for i = 1:n-1
% Find the maximum element in the current column
[~, maxIndex] = max(abs(Ab(i:n, i)));
maxIndex = maxIndex + i - 1;

% Swap rows if necessary


if maxIndex ~= i
Ab([i, maxIndex], :) = Ab([maxIndex, i], :);
end

% Forward elimination
for j = i+1:n
factor = Ab(j, i) / Ab(i, i);
Ab(j, i:n+1) = Ab(j, i:n+1) - factor * Ab(i, i:n+1);
end
end

% Back substitution
x = zeros(n, 1);
x(n) = Ab(n, n+1) / Ab(n, n);
for i = n-1:-1:1
x(i) = (Ab(i, n+1) - Ab(i, i+1:n) * x(i+1:n)) / Ab(i, i);
end
end

You might also like