- Source: Truncation error
In numerical analysis and scientific computing, truncation error is an error caused by approximating a mathematical process.
Examples
= Infinite series
=A summation series for
e
x
{\displaystyle e^{x}}
is given by an infinite series such as
e
x
=
1
+
x
+
x
2
2
!
+
x
3
3
!
+
x
4
4
!
+
⋯
{\displaystyle e^{x}=1+x+{\frac {x^{2}}{2!}}+{\frac {x^{3}}{3!}}+{\frac {x^{4}}{4!}}+\cdots }
In reality, we can only use a finite number of these terms as it would take an infinite amount of computational time to make use of all of them. So let's suppose we use only three terms of the series, then
e
x
≈
1
+
x
+
x
2
2
!
{\displaystyle e^{x}\approx 1+x+{\frac {x^{2}}{2!}}}
In this case, the truncation error is
x
3
3
!
+
x
4
4
!
+
⋯
{\displaystyle {\frac {x^{3}}{3!}}+{\frac {x^{4}}{4!}}+\cdots }
Example A:
Given the following infinite series, find the truncation error for x = 0.75 if only the first three terms of the series are used.
S
=
1
+
x
+
x
2
+
x
3
+
⋯
,
|
x
|
<
1.
{\displaystyle S=1+x+x^{2}+x^{3}+\cdots ,\qquad \left|x\right|<1.}
Solution
Using only first three terms of the series gives
S
3
=
(
1
+
x
+
x
2
)
x
=
0.75
=
1
+
0.75
+
(
0.75
)
2
=
2.3125
{\displaystyle {\begin{aligned}S_{3}&=\left(1+x+x^{2}\right)_{x=0.75}\\&=1+0.75+\left(0.75\right)^{2}\\&=2.3125\end{aligned}}}
The sum of an infinite geometrical series
S
=
a
+
a
r
+
a
r
2
+
a
r
3
+
⋯
,
r
<
1
{\displaystyle S=a+ar+ar^{2}+ar^{3}+\cdots ,\ r<1}
is given by
S
=
a
1
−
r
{\displaystyle S={\frac {a}{1-r}}}
For our series, a = 1 and r = 0.75, to give
S
=
1
1
−
0.75
=
4
{\displaystyle S={\frac {1}{1-0.75}}=4}
The truncation error hence is
T
E
=
4
−
2.3125
=
1.6875
{\displaystyle \mathrm {TE} =4-2.3125=1.6875}
= Differentiation
=The definition of the exact first derivative of the function is given by
f
′
(
x
)
=
lim
h
→
0
f
(
x
+
h
)
−
f
(
x
)
h
{\displaystyle f'(x)=\lim _{h\to 0}{\frac {f(x+h)-f(x)}{h}}}
However, if we are calculating the derivative numerically,
h
{\displaystyle h}
has to be finite. The error caused by choosing
h
{\displaystyle h}
to be finite is a truncation error in the mathematical process of differentiation.
Example A:
Find the truncation in calculating the first derivative of
f
(
x
)
=
5
x
3
{\displaystyle f(x)=5x^{3}}
at
x
=
7
{\displaystyle x=7}
using a step size of
h
=
0.25
{\displaystyle h=0.25}
Solution:
The first derivative of
f
(
x
)
=
5
x
3
{\displaystyle f(x)=5x^{3}}
is
f
′
(
x
)
=
15
x
2
,
{\displaystyle f'(x)=15x^{2},}
and at
x
=
7
{\displaystyle x=7}
,
f
′
(
7
)
=
735.
{\displaystyle f'(7)=735.}
The approximate value is given by
f
′
(
7
)
=
f
(
7
+
0.25
)
−
f
(
7
)
0.25
=
761.5625
{\displaystyle f'(7)={\frac {f(7+0.25)-f(7)}{0.25}}=761.5625}
The truncation error hence is
T
E
=
735
−
761.5625
=
−
26.5625
{\displaystyle \mathrm {TE} =735-761.5625=-26.5625}
= Integration
=The definition of the exact integral of a function
f
(
x
)
{\displaystyle f(x)}
from
a
{\displaystyle a}
to
b
{\displaystyle b}
is given as follows.
Let
f
:
[
a
,
b
]
→
R
{\displaystyle f:[a,b]\to \mathbb {R} }
be a function defined on a closed interval
[
a
,
b
]
{\displaystyle [a,b]}
of the real numbers,
R
{\displaystyle \mathbb {R} }
, and
P
=
{
[
x
0
,
x
1
]
,
[
x
1
,
x
2
]
,
…
,
[
x
n
−
1
,
x
n
]
}
,
{\displaystyle P=\left\{[x_{0},x_{1}],[x_{1},x_{2}],\dots ,[x_{n-1},x_{n}]\right\},}
be a partition of I, where
a
=
x
0
<
x
1
<
x
2
<
⋯
<
x
n
=
b
.
{\displaystyle a=x_{0}
∫
a
b
f
(
x
)
d
x
=
∑
i
=
1
n
f
(
x
i
∗
)
Δ
x
i
{\displaystyle \int _{a}^{b}f(x)\,dx=\sum _{i=1}^{n}f(x_{i}^{*})\,\Delta x_{i}}
where
Δ
x
i
=
x
i
−
x
i
−
1
{\displaystyle \Delta x_{i}=x_{i}-x_{i-1}}
and
x
i
∗
∈
[
x
i
−
1
,
x
i
]
{\displaystyle x_{i}^{*}\in [x_{i-1},x_{i}]}
.
This implies that we are finding the area under the curve using infinite rectangles. However, if we are calculating the integral numerically, we can only use a finite number of rectangles. The error caused by choosing a finite number of rectangles as opposed to an infinite number of them is a truncation error in the mathematical process of integration.
Example A.
For the integral
∫
3
9
x
2
d
x
{\displaystyle \int _{3}^{9}x^{2}{dx}}
find the truncation error if a two-segment left-hand Riemann sum is used with equal width of segments.
Solution
We have the exact value as
∫
3
9
x
2
d
x
=
[
x
3
3
]
3
9
=
[
9
3
−
3
3
3
]
=
234
{\displaystyle {\begin{aligned}\int _{3}^{9}{x^{2}{dx}}&=\left[{\frac {x^{3}}{3}}\right]_{3}^{9}\\&=\left[{\frac {9^{3}-3^{3}}{3}}\right]\\&=234\end{aligned}}}
Using two rectangles of equal width to approximate the area (see Figure 2) under the curve, the approximate value of the integral
∫
3
9
x
2
d
x
≈
(
x
2
)
|
x
=
3
(
6
−
3
)
+
(
x
2
)
|
x
=
6
(
9
−
6
)
=
(
3
2
)
3
+
(
6
2
)
3
=
27
+
108
=
135
{\displaystyle {\begin{aligned}\int _{3}^{9}x^{2}\,dx&\approx \left.\left(x^{2}\right)\right|_{x=3}(6-3)+\left.\left(x^{2}\right)\right|_{x=6}(9-6)\\&=(3^{2})3+(6^{2})3\\&=27+108\\&=135\end{aligned}}}
Truncation Error
=
Exact Value
−
Approximate Value
=
234
−
135
=
99.
{\displaystyle {\begin{aligned}{\text{Truncation Error}}&={\text{Exact Value}}-{\text{Approximate Value}}\\&=234-135\\&=99.\end{aligned}}}
Occasionally, by mistake, round-off error (the consequence of using finite precision floating point numbers on computers), is also called truncation error, especially if the number is rounded by chopping. That is not the correct use of "truncation error"; however calling it truncating a number may be acceptable.
= Addition
=Truncation error can cause
(
A
+
B
)
+
C
≠
A
+
(
B
+
C
)
{\displaystyle (A+B)+C\neq A+(B+C)}
within a computer when
A
=
−
10
25
,
B
=
10
25
,
C
=
1
{\displaystyle A=-10^{25},B=10^{25},C=1}
because
(
A
+
B
)
+
C
=
(
0
)
+
C
=
1
{\displaystyle (A+B)+C=(0)+C=1}
(like it should), while
A
+
(
B
+
C
)
=
A
+
(
B
)
=
0
{\displaystyle A+(B+C)=A+(B)=0}
. Here,
A
+
(
B
+
C
)
{\displaystyle A+(B+C)}
has a truncation error equal to 1. This truncation error occurs because computers do not store the least significant digits of an extremely large integer.
See also
Quantization error
References
Atkinson, Kendall E. (1989), An Introduction to Numerical Analysis (2nd ed.), New York: John Wiley & Sons, p. 20, ISBN 978-0-471-50023-0
Stoer, Josef; Bulirsch, Roland (2002), Introduction to Numerical Analysis (3rd ed.), Berlin, New York: Springer-Verlag, p. 1, ISBN 978-0-387-95452-3.