You are on page 1of 138

Numerical Linear Algebra

Ramaz Botchorishvili

Kutaisi International University

November 2, 2022

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 1 / 34


Numerical Linear Algebra

Ramaz Botchorishvili

Kutaisi International University

November 2, 2022

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 2 / 34


Well posed problem, ill conditioned problem, condition
Number

▶ Recap of Previous Lecture


▶ Round-of errors
▶ How to avoid cancellation and recursion errors
▶ Computational template for numerical linear algebra
▶ Thomas algorithm
▶ Q&A

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 3 / 34


Recap of Previous Lecture

▶ Perturbations in right hand side and coefficients


▶ Error sources
▶ Number systems
▶ Floating point

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 4 / 34


Round-off errors, 1
Rounding and Chopping

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away
▶ Rounding down: d−m−1 < β/2

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away
▶ Rounding down: d−m−1 < β/2
▶ Rounding up: d−m−1 ≥ β/2
Example 7.1
π = 3.1415926

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away
▶ Rounding down: d−m−1 < β/2
▶ Rounding up: d−m−1 ≥ β/2
Example 7.1
π = 3.1415926
▶ Two-digit arithmetic fl(π) = 0.31 · 10−2

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away
▶ Rounding down: d−m−1 < β/2
▶ Rounding up: d−m−1 ≥ β/2
Example 7.1
π = 3.1415926
▶ Two-digit arithmetic fl(π) = 0.31 · 10−2
▶ Three-digit arithmetic fl(π) = 0.314 · 10−2

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34


Round-off errors, 1
Rounding and Chopping
▶ Not all real numbers are machine representable
▶ Finite number of real numbers are only representable in computers
▶ Consider 0.d−1 ...d−m d−m−1
▶ Chopping:
in m-digit arithmetics d−m−1 and all other further digits are thrown
away
▶ Rounding:
in m-digit arithmetics d−m is rounded up or down, d−m−1 and all other
further digits are thrown away
▶ Rounding down: d−m−1 < β/2
▶ Rounding up: d−m−1 ≥ β/2
Example 7.1
π = 3.1415926
▶ Two-digit arithmetic fl(π) = 0.31 · 10−2
▶ Three-digit arithmetic fl(π) = 0.314 · 10−2
▶ Four-digit arithmetic fl(π) = 0.3142 · 10−2
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 5 / 34
Round-off errors, 2
Machine precision, significant numbers
Definition 7.2
Machine precision µ is smallest positive number such that

fl(1 + µ) > 1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 6 / 34


Round-off errors, 2
Machine precision, significant numbers
Definition 7.2
Machine precision µ is smallest positive number such that

fl(1 + µ) > 1

Definition 7.3
Suppose x is real number and x̃ is its approximation. x̃ approximates x to s
significant digits if s is largest nonnegative integer for which relative error
satisfies the inequality:
|x − x̃ |
< 5 · 10−s
|x |

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 6 / 34


Round-off errors, 2
Machine precision, significant numbers
Definition 7.2
Machine precision µ is smallest positive number such that

fl(1 + µ) > 1

Definition 7.3
Suppose x is real number and x̃ is its approximation. x̃ approximates x to s
significant digits if s is largest nonnegative integer for which relative error
satisfies the inequality:
|x − x̃ |
< 5 · 10−s
|x |
Example 7.4
▶ x = 1.31, x̃ = 1.3, |x − x̃ | = 0.01, |x|x−x̃| | = 0.007635
▶ 7.635 · 10−3 < 5 · 10−2 , agree up to two significant digits
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 6 / 34
Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e
▶ fl(x )rounded up = (0.d−1 ...d−m + β −m )β e

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e
▶ fl(x )rounded up = (0.d−1 ...d−m + β −m )β e
▶ x ∈ (fl(x )rounded down , fl(x )rounded up )

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e
▶ fl(x )rounded up = (0.d−1 ...d−m + β −m )β e
▶ x ∈ (fl(x )rounded down , fl(x )rounded up )
▶ |x − fl(x )rounded down | ≤ 0.5|fl(x )rounded down − fl(x )rounded up | = β e−m

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e
▶ fl(x )rounded up = (0.d−1 ...d−m + β −m )β e
▶ x ∈ (fl(x )rounded down , fl(x )rounded up )
▶ |x − fl(x )rounded down | ≤ 0.5|fl(x )rounded down − fl(x )rounded up | = β e−m
▶ |x − fl(x )rounded up | ≤ 0.5|fl(x )rounded down − fl(x )rounded up | = β e−m

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34


Round-off errors, 3
▶ Round-off Error in Representation of a Real Number
Theorem 7.5
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ=
β 1−m for chopping
▶ Proof for round-off case
Proof.
▶ ▶ Consider x = (0.d−1 ...d−m d−m−1 ..)β e , d−1 ̸= 0, 0 ≤ d−i < β
▶ fl(x )rounded down = (0.d−1 ...d−m )β e
▶ fl(x )rounded up = (0.d−1 ...d−m + β −m )β e
▶ x ∈ (fl(x )rounded down , fl(x )rounded up )
▶ |x − fl(x )rounded down | ≤ 0.5|fl(x )rounded down − fl(x )rounded up | = β e−m
▶ |x − fl(x )rounded up | ≤ 0.5|fl(x )rounded down − fl(x )rounded up | = β e−m
|x −fl(x )| 0.5β −m 0.5β −m
▶ |x | ≤ 0.d−1 ...d−m d−m−1 .. ≤ β −1 = 0.5β 1−m
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 7 / 34
Round-off errors, 4

▶ Round-off Error in Representation of a Real Number

Corollary 7.6
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ= ⇒ fl(x ) = x (1 + δ), |δ| ≤ µ
β 1−m for chopping

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 8 / 34


Round-off errors, 4

▶ Round-off Error in Representation of a Real Number

Corollary 7.6
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ= ⇒ fl(x ) = x (1 + δ), |δ| ≤ µ
β 1−m for chopping

Proof.
x −fl(x )
▶ ▶ We set: δ ≡ x

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 8 / 34


Round-off errors, 4

▶ Round-off Error in Representation of a Real Number

Corollary 7.6
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ= ⇒ fl(x ) = x (1 + δ), |δ| ≤ µ
β 1−m for chopping

Proof.
x −fl(x )
▶ ▶ We set: δ ≡ x
▶ ⇒ |δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 8 / 34


Round-off errors, 4

▶ Round-off Error in Representation of a Real Number

Corollary 7.6
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ= ⇒ fl(x ) = x (1 + δ), |δ| ≤ µ
β 1−m for chopping

Proof.
x −fl(x )
▶ ▶ We set: δ ≡ x
▶ ⇒ |δ| ≤ µ
▶ ⇒ fl(x ) − x = x δ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 8 / 34


Round-off errors, 4

▶ Round-off Error in Representation of a Real Number

Corollary 7.6
(
|x −fl(x )| 0.5β 1−m for rounding
|x | ≤µ= ⇒ fl(x ) = x (1 + δ), |δ| ≤ µ
β 1−m for chopping

Proof.
x −fl(x )
▶ ▶ We set: δ ≡ x
▶ ⇒ |δ| ≤ µ
▶ ⇒ fl(x ) − x = x δ
▶ ⇒ fl(x ) = x (1 + δ)

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 8 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102
▶ fl(x1 + x2 ) = 0.10 · 102

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102
▶ fl(x1 + x2 ) = 0.10 · 102
▶ (x1 + x2 ) − fl(x1 + x2 ) = −0.0001 · 102 = 0.1 · 10−1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102
▶ fl(x1 + x2 ) = 0.10 · 102
▶ (x1 + x2 ) − fl(x1 + x2 ) = −0.0001 · 102 = 0.1 · 10−1
(x1 +x2 )−fl(x1 +x2 )
▶ δ= x1 +x2 ≈ −0.999 · 10−3

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102
▶ fl(x1 + x2 ) = 0.10 · 102
▶ (x1 + x2 ) − fl(x1 + x2 ) = −0.0001 · 102 = 0.1 · 10−1
(x1 +x2 )−fl(x1 +x2 )
▶ δ= x1 +x2 ≈ −0.999 · 10−3
▶ δ =≈ 0.999000 · 10−3 < 0.5 · 10−2

▶ Other arithmetic operations: ×, :, −

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 5
▶ Round-off in floating point addition

Example 7.7
▶ ▶ Floating point system β = 10, m = 2, emin = −3, emax = 3
▶ x1 = 0.99 · 101 , x2 = 0.11 · 100
▶ x1 + x2 = 9.9 + 0.11 = 10.01 = 0.1001 · 102
▶ fl(x1 + x2 ) = 0.10 · 102
▶ (x1 + x2 ) − fl(x1 + x2 ) = −0.0001 · 102 = 0.1 · 10−1
(x1 +x2 )−fl(x1 +x2 )
▶ δ= x1 +x2 ≈ −0.999 · 10−3
▶ δ =≈ 0.999000 · 10−3 < 0.5 · 10−2

▶ Other arithmetic operations: ×, :, −


▶ See other examples in the textbook p.34

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 9 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ For computers without guard digits
fl(x1 + x2 ) = x1 (1 + δ1 ) + x2 (1 + δ2 ), |δ1 | ≤ µ, |δ2 | ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ For computers without guard digits
fl(x1 + x2 ) = x1 (1 + δ1 ) + x2 (1 + δ2 ), |δ1 | ≤ µ, |δ2 | ≤ µ
▶ IEEE standard:
Theorem 7.8
Laws of floating point arithmetic:
▶ fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ For computers without guard digits
fl(x1 + x2 ) = x1 (1 + δ1 ) + x2 (1 + δ2 ), |δ1 | ≤ µ, |δ2 | ≤ µ
▶ IEEE standard:
Theorem 7.8
Laws of floating point arithmetic:
▶ fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ fl(x1 × x2 ) = (x1 × x2 )(1 + δ), |δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ For computers without guard digits
fl(x1 + x2 ) = x1 (1 + δ1 ) + x2 (1 + δ2 ), |δ1 | ≤ µ, |δ2 | ≤ µ
▶ IEEE standard:
Theorem 7.8
Laws of floating point arithmetic:
▶ fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ fl(x1 × x2 ) = (x1 × x2 )(1 + δ), |δ| ≤ µ
▶ fl(x1 /x2 ) = (x1 /x2 )(1 + δ), |δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34


Round-off errors, 6
▶ Guard digits are extra digits in arithmetic register
▶ Can be used for reducing round-off errors
▶ In multi-step calculations intermediate results are not rounded
▶ For computers with guard digits fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ For computers without guard digits
fl(x1 + x2 ) = x1 (1 + δ1 ) + x2 (1 + δ2 ), |δ1 | ≤ µ, |δ2 | ≤ µ
▶ IEEE standard:
Theorem 7.8
Laws of floating point arithmetic:
▶ fl(x1 + x2 ) = (x1 + x2 )(1 + δ), |δ| ≤ µ
▶ fl(x1 × x2 ) = (x1 × x2 )(1 + δ), |δ| ≤ µ
▶ fl(x1 /x2 ) = (x1 /x2 )(1 + δ), |δ| ≤ µ

▶ What if n operands are involved in computation?


Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 10 / 34
Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

▶ |δi | ≤ µ, 2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

▶ |δi | ≤ µ, 2 ≤ i ≤ n

Proof.
▶ s = x1 + x2 + ... + xn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

▶ |δi | ≤ µ, 2 ≤ i ≤ n

Proof.
▶ s = x1 + x2 + ... + xn
▶ s2 = fl(x1 + x2 ) = (x1 + x2 )(1 + δ2 ), |δ2 | ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

▶ |δi | ≤ µ, 2 ≤ i ≤ n

Proof.
▶ s = x1 + x2 + ... + xn
▶ s2 = fl(x1 + x2 ) = (x1 + x2 )(1 + δ2 ), |δ2 | ≤ µ
▶ si = fl(si−1 + xi ) = (si−1 + xi )(1 + δi ), |δi | ≤ µ, 2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 11 / 34


Round-off errors, 7
Theorem 7.9
Round-off error in floating point addition
▶ xi ∈ R, 2 ≤ i ≤ n

fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈


(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

▶ |δi | ≤ µ, 2 ≤ i ≤ n

Proof.
▶ s = x1 + x2 + ... + xn
▶ s2 = fl(x1 + x2 ) = (x1 + x2 )(1 + δ2 ), |δ2 | ≤ µ
▶ si = fl(si−1 + xi ) = (si−1 + xi )(1 + δi ), |δi | ≤ µ, 2 ≤ i ≤ n
▶ s3 = fl(s2 + x3 ) = (s2 + x3 )(1 + δ3 ) =
((xBotchorishvili
Ramaz 1 + x2 )(1(KIU)
+ δ2 ) + x3 )(1 + δLectures
3 ) = in(x1 + x2 )(1 + δ2 )(1 + δ3Fall
NLA ) +Term
x3 (1
2022+11
δ3/)34
Round-off errors, 8
Round-off error in floating point addition, cont.
Proof. cont.
▶ s3 = (x1 + x2 )(1 + δ2 + δ3 ) + x3 (1 + δ3 ) + O(µ2 )

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 12 / 34


Round-off errors, 8
Round-off error in floating point addition, cont.
Proof. cont.
▶ s3 = (x1 + x2 )(1 + δ2 + δ3 ) + x3 (1 + δ3 ) + O(µ2 )
▶ s3 − (x1 + x2 + x3 ) = (x1 + x2 )(δ2 + δ3 ) + x3 δ3 + O(µ2 ) ≈
(x1 + x2 )(δ2 + δ3 ) + x3 δ3 = (x1 + x2 )δ2 + (x1 + x2 + x3 )δ3

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 12 / 34


Round-off errors, 8
Round-off error in floating point addition, cont.
Proof. cont.
▶ s3 = (x1 + x2 )(1 + δ2 + δ3 ) + x3 (1 + δ3 ) + O(µ2 )
▶ s3 − (x1 + x2 + x3 ) = (x1 + x2 )(δ2 + δ3 ) + x3 δ3 + O(µ2 ) ≈
(x1 + x2 )(δ2 + δ3 ) + x3 δ3 = (x1 + x2 )δ2 + (x1 + x2 + x3 )δ3
▶ si − (x1 + x2 + ... + xi ) ≈
(x1 + x2 )δ2 + (x1 + x2 + x3 )δ3 + ... + (x1 + x2 + ... + xi )δi

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 12 / 34


Round-off errors, 8
Round-off error in floating point addition, cont.
Proof. cont.
▶ s3 = (x1 + x2 )(1 + δ2 + δ3 ) + x3 (1 + δ3 ) + O(µ2 )
▶ s3 − (x1 + x2 + x3 ) = (x1 + x2 )(δ2 + δ3 ) + x3 δ3 + O(µ2 ) ≈
(x1 + x2 )(δ2 + δ3 ) + x3 δ3 = (x1 + x2 )δ2 + (x1 + x2 + x3 )δ3
▶ si − (x1 + x2 + ... + xi ) ≈
▶ (x1 + x2 )δ2 + (x1 + x2 + x3 )δ3 + ... + (x1 + x2 + ... + xi )δi

si+1 − (x1 + x2 + ... + xi+1 ) = fl(si + xi+1 ) − (x1 + x2 + ... + xi+1 ) =


(si + xi+1 )(1 + δi+1 ) − (x1 + x2 + ... + xi+1 ) =
(si − (x1 + x2 + ... + xi )) + si δi+1 + xi+1 δi+1 =
≈ (x1 + x2 )(δ2 + δ3 + ... + δi ) + ... + xi δi + si δi+1 + xi+1 δi+1 =
(x1 + x2 )(δ2 + δ3 + ... + δi ) + ... + xi δi +
(x1 + x2 + ... + xi )δi+1 + O(µ2 ) + +xi+1 δi+1 =
≈ (x1 + x2 )(δ2 + δ3 + ... + δi ) + ... + xi δi +
(x1 + x2 + ... + xi + xi+1 )δi+1
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 12 / 34
Round-off errors, 9
Laws of floating point arithmetic

fl(x ⊙ y ) = (x ⊙ y )(1 + δ)
⊙ = +, −, ∗, /
|δ| ≤ µ

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 13 / 34


Round-off errors, 9
Laws of floating point arithmetic

fl(x ⊙ y ) = (x ⊙ y )(1 + δ)
⊙ = +, −, ∗, /
|δ| ≤ µ

Example 7.10
Biswa Nath Datta, 2010

fl(x (y + z)) = [xfl(y + z)](1 + δ1 =)


= x (y + z)(1 + δ1 )(1 + δ2 ) =
= x (y + z)(1 + δ1 + δ2 + δ1 δ2 ) =
≈ x (y + z)(1 + δ1 + δ2 )
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 13 / 34
Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|
4. fl(A + B) = (A + B) + E , |E | ≤ µ|A + B|

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|
4. fl(A + B) = (A + B) + E , |E | ≤ µ|A + B|
5. fl(AB) = AB + E , |E | ≤ nµ|A| |B| + O(µ2 )

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|
4. fl(A + B) = (A + B) + E , |E | ≤ µ|A + B|
5. fl(AB) = AB + E , |E | ≤ nµ|A| |B| + O(µ2 )

Floating point errors and matrix operations


Biswa Nath Datta, 2010
1. ∥fl(AB) − AB∥1 ≤ nµ∥A∥1 ∥B∥1 + O(µ2 ), A, B ∈ Rn×n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|
4. fl(A + B) = (A + B) + E , |E | ≤ µ|A + B|
5. fl(AB) = AB + E , |E | ≤ nµ|A| |B| + O(µ2 )

Floating point errors and matrix operations


Biswa Nath Datta, 2010
1. ∥fl(AB) − AB∥1 ≤ nµ∥A∥1 ∥B∥1 + O(µ2 ), A, B ∈ Rn×n
2. ∥fl(Ab) − Ab∥1 ≤ nµ∥A∥1 ∥b∥1 , A ∈ Rn×n , b ∈ Rn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Round-off errors, 10
Theorem 7.11
Wilkinson, 1965
1. |M| = (|mij |)
2. A, B ∈ Rn×n
3. fl(cA) = cA + E , |E | ≤ µ|cA|
4. fl(A + B) = (A + B) + E , |E | ≤ µ|A + B|
5. fl(AB) = AB + E , |E | ≤ nµ|A| |B| + O(µ2 )

Floating point errors and matrix operations


Biswa Nath Datta, 2010
1. ∥fl(AB) − AB∥1 ≤ nµ∥A∥1 ∥B∥1 + O(µ2 ), A, B ∈ Rn×n
2. ∥fl(Ab) − Ab∥1 ≤ nµ∥A∥1 ∥b∥1 , A ∈ Rn×n , b ∈ Rn
3. ∥fl(QB) − QB∥F ≤ nµ∥A∥F , A, Q ∈ Rn×n , Q T Q = I

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 14 / 34


Avoid round-off errors due to recursion and cancellation, 1
Theorem 7.12
Round-off error in floating point addition: xi ∈ R, 2 ≤ i ≤ n
fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈
(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

|δi | ≤ µ, 2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 15 / 34


Avoid round-off errors due to recursion and cancellation, 1
Theorem 7.12
Round-off error in floating point addition: xi ∈ R, 2 ≤ i ≤ n
fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈
(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

|δi | ≤ µ, 2 ≤ i ≤ n
Example 7.13
Pn 1 P1 1
S1 = i=1 i , S2 = i=n i

Figure: which sum is more accurate, S1 or S2 ?


Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 15 / 34
Avoid round-off errors due to recursion and cancellation, 2

Theorem 7.14
Round-off error in floating point addition: xi ∈ R, 2 ≤ i ≤ n
fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈
(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

|δi | ≤ µ, 2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 16 / 34


Avoid round-off errors due to recursion and cancellation, 2

Theorem 7.14
Round-off error in floating point addition: xi ∈ R, 2 ≤ i ≤ n
fl(x1 + x2 + ... + xn ) − (x1 + x2 + ... + xn ) ≈
(x1 + x2 )(δ2 + δ3 + ... + δn ) + x3 (δ3 + δ4 + ... + δn )+... + xn δn

|δi | ≤ µ, 2 ≤ i ≤ n

Example 7.15
▶ S1 = ni=1 1i , S2 = 1i=n 1i
P P

▶ Recommendation:
summation from smallest to largest terms is more accurate

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 16 / 34


Avoid round-off errors due to recursion and cancellation, 3
Example 7.16
1−cos(x )
▶ Cancellation error, compute function for small x : f (x ) = x2

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 17 / 34


Avoid round-off errors due to recursion and cancellation, 3
Example 7.16
1−cos(x )
▶ Cancellation error, compute function for small x : f (x ) = x2

Figure: Cancellation errors: left=wrong approach, right=correct approach

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 17 / 34


Avoid round-off errors due to recursion and cancellation, 3
Example 7.16
1−cos(x )
▶ Cancellation error, compute function for small x : f (x ) = x2

Figure: Cancellation errors: left=wrong approach, right=correct approach

▶ Remedy: rewrite formula equivalently for avoiding cancellation


sin2 (x ) sin2 (x )
1 − cos(x ) = 1+cos(x ) , f (x ) = (1+cos(x ))x 2

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 17 / 34


Avoid round-off errors due to recursion and cancellation, 4
Example 7.17

Figure: Same expressions written differently give different results

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 18 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25
3. Catastrophic cancellation: two numbers of approximately same size
substracted

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25
3. Catastrophic cancellation: two numbers of approximately same size
substracted
4. Notice: substraction reveals errors of previous computations

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25
3. Catastrophic cancellation: two numbers of approximately same size
substracted
4. Notice: substraction reveals errors of previous computations
Round-off errors due to recursion

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25
3. Catastrophic cancellation: two numbers of approximately same size
substracted
4. Notice: substraction reveals errors of previous computations
Round-off errors due to recursion
▶ p.43, Biswa Nath Datta, 2010,
En = 1 − nEn−1 , n = 2, 3.., En = o1 x n e x −1 dx
R

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34


Avoid round-off errors due to recursion and cancellation, 5
Example 7.18
Biswa Nath Datta, 2010
1. Exact input data:
1.1 x = 0.54617, y = 0.54601
1.2 d = x − y = 0.00016
2. 4-digit arithmetic with rounding
2.1 x̃ = 0.5462, ỹ = 0.5460
2.2 d̃ = x̃ − ỹ = 0.0002
2.3 Large relative error |d− d̃|
|d| = 0.25
3. Catastrophic cancellation: two numbers of approximately same size
substracted
4. Notice: substraction reveals errors of previous computations
Round-off errors due to recursion
▶ p.43, Biswa Nath Datta, 2010,
En = 1 − nEn−1 , n = 2, 3.., En = o1 x n e x −1 dx
R

▶ Recommendation: rearrange recursion


Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 19 / 34
Computational template of Linear Algebra, 1

1. Transform the problem to ”easier to solve” form, e.g. matrices of the


problem into matrices with special structure

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 20 / 34


Computational template of Linear Algebra, 1

1. Transform the problem to ”easier to solve” form, e.g. matrices of the


problem into matrices with special structure
Example 7.19
   
a11 a12 ... a1n a11 a12 ... a1n
a
 21 a22 ... a2n   0 a ... a2n 
22
 −→ 
  
 .. .. ... ..   .. .. ... .. 
 

an1 an2 ... ann 0 0 ... ann

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 20 / 34


Computational template of Linear Algebra, 1

1. Transform the problem to ”easier to solve” form, e.g. matrices of the


problem into matrices with special structure
Example 7.19
   
a11 a12 ... a1n a11 a12 ... a1n
a
 21 a22 ... a2n   0 a ... a2n 
22
 −→ 
  
 .. .. ... ..   .. .. ... .. 
 

an1 an2 ... ann 0 0 ... ann

2. Exploit special structure of associated matrices and solve transformed


problem

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 20 / 34


Computational template of Linear Algebra, 1

1. Transform the problem to ”easier to solve” form, e.g. matrices of the


problem into matrices with special structure
Example 7.19
   
a11 a12 ... a1n a11 a12 ... a1n
a
 21 a22 ... a2n   0 a ... a2n 
22
 −→ 
  
 .. .. ... ..   .. .. ... .. 
 

an1 an2 ... ann 0 0 ... ann

2. Exploit special structure of associated matrices and solve transformed


problem
3. From the solution of transformed problem recover solution of the
original problem

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 20 / 34


Computational template of Linear Algebra, 2
Definition 7.20
LU Decomposition, LU Factorisation

A = LU
A, L, U-square matrices, L-lower triangular, U - upper triangular

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 21 / 34


Computational template of Linear Algebra, 2
Definition 7.20
LU Decomposition, LU Factorisation

A = LU
A, L, U-square matrices, L-lower triangular, U - upper triangular

Example 7.21
    
a11 a12 ... a1n l11 0 ... 0 u11 u12 ... u1n
a
 21 a22 ... a2n  l21 l22 ... 0   0 u22 ... u2n 
   
=

 .. .. ... ..   .. .. ... ..   .. .. ... .. 
  

an1 an2 ... ann ln1 ln2 ... lnn 0 0 ... unn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 21 / 34


Computational template of Linear Algebra, 2
Definition 7.20
LU Decomposition, LU Factorisation

A = LU
A, L, U-square matrices, L-lower triangular, U - upper triangular

Example 7.21
    
a11 a12 ... a1n l11 0 ... 0 u11 u12 ... u1n
a
 21 a22 ... a2n  l21 l22 ... 0   0 u22 ... u2n 
   
=

 .. .. ... ..   .. .. ... ..   .. .. ... .. 
  

an1 an2 ... ann ln1 ln2 ... lnn 0 0 ... unn

Example 7.22
LU factoriozation for solving linear systems

Ax = b ⇒ A = LU, LUx = b⇒⇒L(Ux ) = b, Ly = b ⇒ Ux = y


Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 21 / 34
Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops
▶ Thomas algorithm O(n) flops

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops
▶ Thomas algorithm O(n) flops
▶ Fastest Computer today in development = hexapoint(1018 ) operations
per second

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops
▶ Thomas algorithm O(n) flops
▶ Fastest Computer today in development = hexapoint(1018 ) operations
per second
▶ How fast can you solve linear system with 103 , 106 , 109 unknowns?

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops
▶ Thomas algorithm O(n) flops
▶ Fastest Computer today in development = hexapoint(1018 ) operations
per second
▶ How fast can you solve linear system with 103 , 106 , 109 unknowns?
Example 7.23
 
a11 a12 . . . . 0
a21 a22 a23 . . . . 
 
 . . . . . . . 
 
 
 . . aii−1 aii aii+1 . . 
 
 . . . . . . . 
 
 . . . . . . . 
 
0 . . . . ann−1 ann

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34


Thomas algorithm, 1
▶ LU Decompositionm of square tridiagonal matrices
▶ Efficient for solving linear systems for tridiagonal matrices:
▶ Cramer’s rule O(n!) flops
▶ Gaussian elimination O(n3 ) flops
▶ Thomas algorithm O(n) flops
▶ Fastest Computer today in development = hexapoint(1018 ) operations
per second
▶ How fast can you solve linear system with 103 , 106 , 109 unknowns?
Example 7.23
 
a11 a12 . . . . 0
a21 a22 a23 . . . . 
 
 . . . . . . . 
 
 
 . . aii−1 aii aii+1 . . 
 
 . . . . . . . 
 
 . . . . . . . 
 
0 . . . . ann−1 ann

▶ Better storage scheme: store three ”diagonals” ONLY


Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 22 / 34
Thomas algorithm, 2
▶ Tgridiagonal system

Example 7.24
    
a1 c1 . . . . 0 x1 f1
b2 a2 c2 . . . .  x2  f2 
    
. . . . . . . .   . 
    
   

. . bi ai ci . .  xi  =  fi 
   

. . . . . . .  .   .
   

. . . . . . .  .   . 
    
0 . . . . b n an xn fn

▶ Storage scheme: vectors a, b, c, f and x

Theorem 7.25
If LU decomposition of a tridiagonal matrix exists then matrices L and U
are bi-diagonal

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 23 / 34


Thomas algorithm, 3
▶ LU factorization of tgridiagonal
 system
a1 c1 . . . . 0
b2 a2 c2 . . . .
 
. . . . . . .
 
 
. . bi ai ci . .
 =
. . . . . . .
 
. . . . . . .
 
0 . . . . bn an
  
1 . . . . . 0 α1 c1 . . . . 0
β2 1 . . . . .   . α2 c2 . . . . 
  
. . . . . . .  . . . . . . . 
  

 
. . βi 1 . . .   .   . . αi ci . . 
 
. . . . . . .  . . . . . . . 
  
. . . . . . . . . . . . . . 
  
 
0 . . . . βn 1 0 . . . . . αn
▶ Storage scheme: vectors a, b, c and α, β
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 24 / 34
Thomas algorithm, 4
LU Decomposition
  
1 . . . . . 0 α1 c1 . . . . 0
β2 1 . . . . .   . α2 c2 . . . . 
  
. . . . . . .  . . . . . . . 
  

 
. . βi 1 . . .  . . . α ci . . 
i =

 
. . . . . . .  . . . . . . . 
  
. . . . . . .  . . . . . . . 
  
0 . . . . βn 1 0 . . . . . αn


α 1 = a1
  
a1 c1 . . . . 0 α1 β2 = b2 ⇒ β2 = b2 /α1





b2 a2 c2 . . . .
  
β2 c1 + α2 = a2 ⇒ α2 = a2 − β2 c1



. . . . . . .
  

  ..

⇒
. . b i ai ci . .

. . . . . . . 
αi−1 βi = bi ⇒ βi = bi /αi−1
  
βi ci−1 + αi = ai ⇒

. . . . . . .
  




0 . . . . b n an αi = ai − βi ci−1




2≤i ≤n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 25 / 34
Thomas algorithm, 5
LU
 Decomposition, solving
 linear system  
1 . . . . . 0 α1 c1 . . . . 0 x1
β2 1 . . . . .   . α2 c2 . . . .  x2 
   
. . . . . . .  . . . . . . .  . 
   
  

. . βi 1 . . .   . . . αi ci . .   xi  =
   

. . . . . . .  . . . . . . .  . 
 
  
. . . . . . .  . . . . . . .  . 
   
0 . . . . βn 1 0 . . . . . αn xn
 
f1 
 f2 
  


Ax = b

. LUx = f
  


 
 fi  ⇒ L(Ux ) = f
  
. 
  

 Ux = y
.
  

Ly = f

fn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 26 / 34


Thomas algorithm, 6

solving linear system, forward substituition



     y1 = f1

1 . . . . . 0 y1 f1 

β2 y1 + y2 = f2


β2 1 . . . . .  y2  f2 
     



. . . . . . .  .   .  y2 = f2 − β2 y1
     

    

  yi  =  fi  ⇒ ...
. . βi 1 . . .    

. . . . . . .   .  .
    
 

 βi yi−1 + yi = fi
. . . . . . .  .   . 
     

yi = fi − βi yi−1



0 . . . . βn 1 yn fn 

2 ≤ i ≤ n

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 27 / 34


Thomas algorithm, 7

Solving linear system, backward substituition


    
α1 c1 . . . . 0 x1 y1 
 . α2 c2 .

. . .  x2  y2 
    


αn xn = yn

 . . . . . . .  .   .  xn = yn /αn
     

    

 .
 . . α i ci . .   xi  =  yi  ⇒ αi xi + ci yi+1 = fi
    
 . 
 . . . . . .  .   . 
    


 xi = (fi − ci yi+1 )/αi
 . . . . . . .  .   . 
     

i = n − 1, n − 2, ..., 1

0 . . . . . αn xn yn

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 28 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

xn = yn /αn , xi = (fi − ci yi+1 )/αi i = n − 1, n − 2, ..., 1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

xn = yn /αn , xi = (fi − ci yi+1 )/αi i = n − 1, n − 2, ..., 1

Solving linear system, number of arithmetic operations


1. LU Decomposition 3(n − 1) operations

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

xn = yn /αn , xi = (fi − ci yi+1 )/αi i = n − 1, n − 2, ..., 1

Solving linear system, number of arithmetic operations


1. LU Decomposition 3(n − 1) operations
2. Forward substitution 2(n − 1) operations

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

xn = yn /αn , xi = (fi − ci yi+1 )/αi i = n − 1, n − 2, ..., 1

Solving linear system, number of arithmetic operations


1. LU Decomposition 3(n − 1) operations
2. Forward substitution 2(n − 1) operations
3. Backward substitution 3(n − 1) + 1 operations

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34


Thomas algorithm, 8
1. LU Decomposition

α1 = a1 , βi = bi /αi−1 , αi = ai − βi ci−1 , i = 2, 3, ..., n

2. Forward substitution

y1 = f1 , yi = fi − βi yi−1 , i = 2, 3, ..., n

3. Backward substitution

xn = yn /αn , xi = (fi − ci yi+1 )/αi i = n − 1, n − 2, ..., 1

Solving linear system, number of arithmetic operations


1. LU Decomposition 3(n − 1) operations
2. Forward substitution 2(n − 1) operations
3. Backward substitution 3(n − 1) + 1 operations
4. Total 8(n − 1) ≈ O(n) operations
Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 29 / 34
Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?


▶ A: If solving the same system with many different right hand sides is
needed

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?


▶ A: If solving the same system with many different right hand sides is
needed

Example 7.26
▶ ▶ Finding inverse of a matrix

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?


▶ A: If solving the same system with many different right hand sides is
needed

Example 7.26
▶ ▶ Finding inverse of a matrix
▶ AB = I or BA = I ⇒ B = A−1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?


▶ A: If solving the same system with many different right hand sides is
needed

Example 7.26
▶ ▶ Finding inverse of a matrix
▶ AB = I or BA = I ⇒ B = A−1
       
1 0 ... 0 1 0 0
0 1 ... 0 0 1 0
▶ I=  I =   I =   ...I =   ⇒ I = (I1 I2 ... In )
 ... 0 1   2   n  
0 0 ... 1 0 0 1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 10

▶ Q: When is LU Decomposition very useful?


▶ A: If solving the same system with many different right hand sides is
needed

Example 7.26
▶ ▶ Finding inverse of a matrix
▶ AB = I or BA = I ⇒ B = A−1
       
1 0 ... 0 1 0 0
0 1 ... 0 0 1 0
▶ I=  I =   I =   ...I =   ⇒ I = (I1 I2 ... In )
 ... 0 1   2   n  
0 0 ... 1 0 0 1
▶ AB = I ⇒ Abi = Ii , i = 1, 2, ..n ⇒ B = (b1 b2 ...bn ) = A−1

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 30 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?
▶ A: No:

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?
▶ A: No:
▶ if matrix is degenerate

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?
▶ A: No:
▶ if matrix is degenerate
▶ if stability conditions are not satisfied

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?
▶ A: No:
▶ if matrix is degenerate
▶ if stability conditions are not satisfied

|a1 | > |c1 | > 0,


|ai | ≥ |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 11
▶ Q: Is Thomas algorithm always good to apply?
▶ A: No:
▶ if matrix is degenerate
▶ if stability conditions are not satisfied

|a1 | > |c1 | > 0,


|ai | ≥ |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

Example 7.27

Figure: Stability condition satisfied

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 31 / 34


Thomas algorithm, 12
Example 7.28

Figure: Stability condition is not satisfied

Example 7.29

Figure: Stability condition is not satisfied

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 32 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

|a1 | > |c1 | > 0,


|ai | > |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

|a1 | > |c1 | > 0,


|ai | > |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

▶ Assume perturbations in RHS Ax = f , Ax̃ = f˜

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

|a1 | > |c1 | > 0,


|ai | > |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

▶ Assume perturbations in RHS Ax = f , Ax̃ = f˜


▶ A(x − x̃ ) = f − f˜

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

|a1 | > |c1 | > 0,


|ai | > |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

▶ Assume perturbations in RHS Ax = f , Ax̃ = f˜


▶ A(x − x̃ ) = f − f˜
▶ bi (xi−1 − x̃i−1 ) + ai (xi − x̃i ) + ci (xi+1 − x̃i+1 ) = fi − f˜i

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Thomas algorithm, 13
Stability
▶ strictly diagonally dominant by rows

|a1 | > |c1 | > 0,


|ai | > |bi | + |ci |, i = 2, 3, ..., n − 1,
|an | > |cn | > 0.

▶ Assume perturbations in RHS Ax = f , Ax̃ = f˜


▶ A(x − x̃ ) = f − f˜
▶ bi (xi−1 − x̃i−1 ) + ai (xi − x̃i ) + ci (xi+1 − x̃i+1 ) = fi − f˜i

▶ ∥x − x̃ ∥∞ ≤ |a |−|b1 |−|c | ∥f − f˜∥∞
i i i

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 33 / 34


Q&A

Ramaz Botchorishvili (KIU) Lectures in NLA Fall Term 2022 34 / 34

You might also like