Skip to main content
Mathematics LibreTexts

10.1: Absolute and Relative Errors

  • Page ID
    63928
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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:

    xstar = 0.0150;
    x = 0.0153
    abs(x-xstar)
    0.0002999999999999999

     

    and the relative error is 

    xstar = 0.0150;
    x = 0.0153
    abs((x-xstar)/xstar)
    0.019999999999999997

    which is the same results as above.  

    Exercise

    Find the relative, absolute and percent error if \(x^{\star} = 130.32\) and \(x=130\). 

    # fill in code here.
     

     


    This page titled 10.1: Absolute and Relative Errors is shared under a not declared license and was authored, remixed, and/or curated by Peter Staab.

    • Was this article helpful?