10.1: Absolute and Relative Errors
- Page ID
- 63928
Consider an algorithm that tries to find the value of \(x^{\star}\). If the algorithm actually returns the value $x$, then there will be some error. The absolute error is \[|x - x^{\star}|\]
and the relative error is \[\left|\frac{x-x^{\star}}{x^{\star}}\right|.\]
Often, the percent error is helpful as well, which is just the relative error times 100.
Example
Consider an algorithm that returns \(x=0.0153\) and the actual answer is \(x^{\star}=0.0150\). Find both the absolute and relative errors.
The absolute error is \(|0.0153-0.015|= 0.0003\) and the relative error is \[\left|\frac{0.0153-0.015}{0.015}\right|=0.02\] or 2\%.
We can do this is julia as follows. Here is the absolute error:
and the relative error is
which is the same results as above.
Exercise
Find the relative, absolute and percent error if \(x^{\star} = 130.32\) and \(x=130\).