Which error is a type of algorithm error?
A truncation error is the difference between an actual and a truncated, or cut-off, value. A truncated quantity is represented by a numeral with a fixed number of allowed digits, with any excess digits chopped off -- hence, the expression truncated.
Truncation error explained with Taylor series
In mathematical and computing applications, the true or analytical derivative or value of a function may be different from the value obtained by numerical approximation. The truncation error is the difference between these two values. It refers to the discrepancy that arises from executing a finite number of steps to approximate an infinite process -- a process known as discretization -- usually for ease of calculation.
Consider an infinite exponential function, ex. It may be expressed as the sum of the infinite Taylor series polynomial:
ex = 1 + (x / 1!) + (x2 / 2!) + (x3 / 3!) + ⋯ + (xn / n!) + ⋯ ∞
ex = 1 + x + (x2 / 2) + (x3 / 6) + ⋯ + (xn / n!) + ⋯ ∞
Thus, ex has an infinitely long series that can be expressed in a truncated (approximated) format:
ex = p2x +∑∞ (xn / n!)
n = 3
Here, p2x = 1 + (x / 1!) + (x2 / 2!)
In this case, the infinite Taylor series ex is approximated by a quadratic polynomial where n = 3. This approximation gives an approximate or inaccurate answer, resulting in a truncation error.
The Taylor series is useful to represent a continuously differentiable function as a polynomial function of infinite order. Adding each of these values generates the exact answer. However, if the calculation is stopped after any finite value of n, the final value will only be an approximation of the value of ex. The difference between the exact answer and the approximate answer is the truncation error.
Reducing a truncation error
A truncation error is always present as long as a finite number of steps is used to approximate an infinite mathematical calculation process. However, it is possible to make this error as small as possible by making n as large as possible, that is, by doing repeated iterations and including as many numbers of terms in the approximation as possible. However, this may result in additional time or cost, so many numerical applications accept approximations of the exact analytical answer and the resultant truncation error.
Truncation error examples
Consider the infinite series 1/2 + 1/4 + 1/8 + 1/16 + 1/32 and so on adds up to exactly 1. But this final value is only derived when all the values in the series are added together. If this infinite series is truncated to a finite series containing only the first four terms, the series now becomes 1/2 + 1/4 + 1/8 + 1/16. Adding these four terms does not produce 1. Rather, the value will be 15/16, or 0.94. In this case, the truncation error = 1 - 15/16 = 1/16 = 0.06.
Consider the speed of light in a vacuum. The official value is 299,792,458 meters per second (m/s). In scientific (power-of-10) notation, it is expressed as 2.99792458 x 108 m/s. But truncating it to only two decimal places yields 2.99 x 108 m/s.
Since the truncation error is the difference between the actual value and the truncated value, in this case, it comes to the following:
2.99792458 x 108 - 2.99 x 108 = 0.00792458 x 108 m/s
Truncation error in practice
Truncation errors commonly appear in these practical applications:
1. Discretizing equations
Discretization is the conversion of a continuous function (differentiation) to a discrete approximation for numerical evaluation.
A derivative is expressed as the following:
f'(xi) = lim (f(xi+1) - f(xi)) / h
h → 0
This equation can be approximated by removing the limit and expressing it as the following:
f'(xi) ~ (f(xi+1) - f(xi)) / h
This is a type of forward difference approximation where the derivative at xi is approximated by using the value at xi and forwarding one step at xi+1. The Taylor series approximation is a type of discretized equation.
2. Finite-difference approximations
Three types of finite-difference approximations are possible: forward difference, backward difference and central difference.
In forward difference, the argument x is increased by a small amount, and each of a set of finite differences is calculated by subtracting the present value of a function f(x) from a new value. Thus, the value of the function f(x) at xi and forward one step at f(xi+1) is used to approximate the derivative at xi.
Forward difference is expressed as ∆i = f(x + i) - f(xi).
In backward difference, the argument x is changed by a small negative amount, and each of a set of finite differences is calculated by subtracting a previous value of the function f(x) from the present value. Thus, it uses the value of the function f(x) at xi and backward one step at f(xi-1) to approximate the value of the derivative at xi.
Backward difference is expressed as ∇i = f(i) - f(x - i).
Central difference uses the value of f(x) one step backward at f(xi-1) and one step forward f(xi+1) to approximate the derivative at xi. The finite difference is calculated by subtracting the value of a function when x is decreased by a given amount from its value and also increased by the same amount.
Central difference is expressed as δ = f(x + ½h) - f(x - ½h).
Although the central difference method also creates a truncation error, the magnitude of this error is smaller than the forward or backward difference methods. That's why central difference is a more accurate approximation method than forward or backward difference.
Truncation error and rounding error
In mathematics and computing, a truncation error is not the only source of error. When numerically solving initial-value problems using difference formats, a rounding error can also occur. This refers to the difference between a rounded-off numerical value and its actual value.
If a numerical problem consists of multiple steps and values are rounded off at each step, the rounding error in each may be small. However, as the number of steps increases, the sum of the rounding error accumulates with each step, and the final error may be quite large, resulting in unstable numerical results.
Truncation errors and rounding errors may be the same, or they may be two different types of errors in numerical and computing calculations. The sum of the truncation error and roundoff error is known as the total numerical error. Reducing the step size can reduce the truncation error and thus the total error. However, doing so can also increase the rounding error. That's why it's best to reduce the step size just enough so that the truncation error is reduced to an acceptable level without increasing the rounding error by a large amount.
See also: mathematical symbols.
This was last updated in August 2022
Continue Reading About truncation error
Related TermsautocorrectAutocorrect is a word processing feature that identifies misspelled words, and uses algorithms to identify the words most likely ... See complete definitionnormal distributionA normal distribution is a type of continuous probability distribution in which most data points cluster toward the middle of the... See complete definitiontruth tableA truth table is a breakdown of all the possible truth values returned by a logical expression. See complete definition
Word of the Day
Security information and event management (SIEM) is an approach to security management that combines security information management (SIM) and security event management (SEM) functions into one security management system.
What are errors in algorithm?
Definitions of algorithm error. error resulting from the choice of the wrong algorithm or method for achieving the intended result. type of: computer error, error. (computer science) the occurrence of an incorrect result produced by a computer.
What type of error can be found in algorithms?
When developing programs there are three types of error that can occur: syntax errors. logic errors. runtime errors.
What are the 3 error types?
Type I error: "rejecting the null hypothesis when it is true". Type II error: "failing to reject the null hypothesis when it is false". Type III error: "correctly rejecting the null hypothesis for the wrong reason".
What are the 3 types of errors in Python?
There are mainly three kinds of distinguishable errors in Python: syntax errors, exceptions and logical errors.