Numerical Methods for Engineers · Problem type

Gauss–Seidel sweeps

Use this for “Do Gauss–Seidel sweeps on 4x + y = 9 and x + 3y = 5 from (0, 0) until the change is under 0.0001.”

Diagram

−1012300.511.5y₀ = 0(x₁, y₁) = (2.25, 0.9167)line 1line 2
Across
to
line
1:
x₁
=
b₁ − a₁₂y₀
a₁₁
=
2.25.
Then
to
line
2
with
the
new
x:
y₁
=
b₂ − a₂₁x₁
a₂₂
=
0.9167.
The faded sweeps close in on the crossing (2, 1).
This is an example. Type your own values to start a new problem.
a₁₁
x
+
a₁₂
y
=
b₁
a₂₁
x
+
a₂₂
y
=
b₂
y₀
Starting guess for y
example
x₁
x after one sweep
worked out (not typed)
y₁
y after one sweep
worked out (not typed)
ε
Tolerance
example
x
x where both equations hold
worked out (not typed)
y
y where both equations hold
worked out (not typed)

Formulas

x₁
=
b₁
−
a₁₂
×
y₀
a₁₁
2.25
=
9 − 1 × 0
4
y₁
=
b₂
−
a₂₁
×
x₁
a₂₂
0.9167
=
5 − 1 × 2.25
3
x
=
b₁
×
a₂₂
−
a₁₂
×
b₂
a₁₁
×
a₂₂
−
a₁₂
×
a₂₁
,
swept
until
no
change
reaches
ε
2
=
9 × 3 − 1 × 5
4 × 3 − 1 × 1
,
swept
until
no
change
reaches
0.0001
y
=
b₂
−
a₂₁
×
x
a₂₂
1
=
5 − 1 × 2
3

Assumptions

•
The system is a₁₁x + a₁₂y = b₁ and a₂₁x + a₂₂y = b₂.
•
A sweep solves equation 1 for x from the old y, then equation 2 for y from the new x.
•
It surely converges when each diagonal entry outweighs the other entry in its row.
•
The sweeps repeat from (x₁, y₁) until no value changes by as much as the tolerance ε.

Step-by-step

WE KNOW
a₁₁ = 4, a₁₂ = 1, b₁ = 9, a₂₁ = 1, a₂₂ = 3, b₂ = 5, y₀ = 0, ε = 0.0001
FIND
x after one sweep (x₁), y after one sweep (y₁), x where both equations hold (x), y where both equations hold (y)
Step 1 · Find x after one sweep (x₁)
Use x₁ = (b₁ − a₁₂ × y₀) ÷ a₁₁
Equation
1
solved
for
x
,
with
y
at
its
old
value
y₀
:
move
a₁₂
y₀
across
and
divide
by
a₁₁
.
x₁
=
9 − 1 × 0
4
x₁
=
2.25
Step 2 · Find y after one sweep (y₁)
Use y₁ = (b₂ − a₂₁ × x₁) ÷ a₂₂
Equation
2
solved
for
y
,
using
the
new
x₁
at
once
(Jacobi
would
still
use
x₀):
this
is
what
makes
it
Gauss–Seidel.
y₁
=
5 − 1 × 2.25
3
y₁
=
2.75
3
y₁
=
0.9167
Step 3 · Find x where both equations hold (x)
Use x = (b₁ × a₂₂ − a₁₂ × b₂) ÷ (a₁₁ × a₂₂ − a₁₂ × a₂₁), swept until no change reaches ε
Sweep again and again: the values close in on the point where both equations hold (the check works it exactly by Cramer’s rule).
x
=
the
value
the
sweeps
close
in
on
Pass
1:
x₁
=
9 − 1 × 0
4
=
2.25;
y₁
=
5 − 1 × 2.25
3
=
0.916667;
change
0.916667
Pass
2:
x₂
=
9 − 1 × 0.916667
4
=
2.02083;
y₂
=
5 − 1 × 2.02083
3
=
0.993057;
change
0.22917
Pass
3:
x₃
=
9 − 1 × 0.993057
4
=
2.00174;
y₃
=
5 − 1 × 2.00174
3
=
0.99942;
change
0.01909
Pass
4:
x₄
=
9 − 1 × 0.99942
4
=
2.00014;
y₄
=
5 − 1 × 2.00014
3
=
0.999953;
change
0.0016
Pass
5:
x₅
=
9 − 1 × 0.999953
4
=
2.00001;
y₅
=
5 − 1 × 2.00001
3
=
0.999997;
change
0.00013
Pass
6:
x₆
=
9 − 1 × 0.999997
4
=
2;
y₆
=
5 − 1 × 2
3
=
1;
change
1 ×
10
-5
Stop:
the
change
1 ×
10
-5
is
under
0.0001.
x
=
2
Step 4 · Find y where both equations hold (y)
Use y = (b₂ − a₂₁ × x) ÷ a₂₂
Equation
2
solved
for
y
at
that
x
.
y
=
5 − 1 × 2
3
y
=
3
3
y
=
1
Check
Put the numbers back in. Both sides should match.
2.25
=
9 − 1 × 0
4
✓
0.9167
=
5 − 1 × 2.25
3
✓
2
=
9 × 3 − 1 × 5
4 × 3 − 1 × 1
✓
1
=
5 − 1 × 2
3
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.

Related lessons

© 2026 SME. All rights reserved.