# truncation error

## What is a truncation 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, e^{x}. It may be expressed as the sum of the infinite Taylor series polynomial:

e^{x} = 1 + (x / 1!) + (x^{2 }/ 2!) + (x^{3 }/ 3!) + ⋯ + (x^{n }/ n!) + ⋯ ∞

e^{x} = 1 + x + (x^{2 }/ 2) + (x^{3 }/ 6) + ⋯ + (x^{n }/ n!) + ⋯ ∞

Thus, e^{x} has an infinitely long series that can be expressed in a truncated (approximated) format:

e^{x }= p_{2}x +∑^{∞ }(x^{n }/ n!)^{}

n = 3

Here, p_{2}x = 1 + (x / 1!) + (x^{2 }/ 2!)

In this case, the infinite Taylor series e^{x} 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 *e ^{x}*.

^{ }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

### Example 1

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.

### Example 2

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 10^{8} m/s. But truncating it to only two decimal places yields 2.99 x 10^{8} 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 10^{8} - 2.99 x 10^{8} = 0.00792458 x 10^{8 }m/s

## Truncation error in practice

Truncation errors commonly appear in these practical applications:

- discretizing equations
- finite-difference approximations

### 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'(x_{i}) = lim (f(x_{i+1}) - f(x_{i})) / h

h → 0

This equation can be approximated by removing the limit and expressing it as the following:

f'(x_{i}) ~ (f(x_{i+1}) - f(x_{i})) / h

This is a type of forward difference approximation where the derivative at x_{i} is approximated by using the value at x_{i} and forwarding one step at x_{i+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 x_{i} and forward one step at f(x_{i+1}) is used to approximate the derivative at x_{i.}

Forward difference is expressed as ∆_{i} = f(x + i) - f(x_{i}).

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 x_{i} and backward one step at f(x_{i-1}) to approximate the value of the derivative at x_{i.}

Backward difference is expressed as ∇_{i} = f(i) - f(x - i).

Central difference uses the value of f(x) one step backward at f(x_{i-1}) and one step forward f(x_{i+1}) to approximate the derivative at x_{i}. 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.*