0
$\begingroup$

Caveat: I've already searched for this topic here in MSE but also on other sites, but I have not still found anything that can answer my doubt.


I'm checking my own implementation of a code. The context is not important. The correct value is $x=e^{-200}$, and I computed $\hat{x}$ with my routine.

  • I computed the absolute error $|x- \hat{x}|=1.2\cdot10^{-14}$. This means that in $\hat{x}$ I have 14 correct digits of $x$.

  • If I compute now the relative error I have $\frac{|x-\hat{x}|}{|x|} = 8.67 \cdot 10^{72} $. I know it is related to the number of significant digits, and in this case the denominator $x=e^{-200}$ is not zero (even in is really small).

I'm really puzzled because I can't understand what is going on: I mean, the result of the relative error is saying me that the approximation is poor? But the first $14$ digits are equal.

$\endgroup$

1 Answer 1

2
$\begingroup$

Your $x$ has 86 zeros after the decimal period. So having determimed the first 14 zeros you are still 72 zeros away from the real thing.

More technically, your error is $10^{72}$ bigger than the actual $x$, which is what your quotient is showing.

$\endgroup$
8
  • $\begingroup$ Okay, so the relative error takes into account ALL the significant digits of the number. Right? Since $e^{-200}$ has 87 zeros before the beginning of the significant digits, and my $\hat{x}$ is exact only on the first $14$ (which are all zeros), the relative error of $10^72$ is saying me the information about what you call the "real thing". $\endgroup$
    – andereBen
    Commented Aug 1, 2020 at 8:47
  • $\begingroup$ Yes. For instance $10^{-15}$ is within your tolerance, and it is $10^{72}$ times bigger than $x$. $\endgroup$ Commented Aug 1, 2020 at 14:29
  • $\begingroup$ Sorry, but what do you mean with "within your tolerance"? @MartinArgerami $\endgroup$
    – andereBen
    Commented Aug 1, 2020 at 14:37
  • $\begingroup$ Do you mean that even if $\hat{x}$ is accurate up to $15$ digits, it is $10^{72}$ times bigger? @MartinArgerami $\endgroup$
    – andereBen
    Commented Aug 1, 2020 at 14:40
  • $\begingroup$ Yes. Like I said, $10^{-15}$ is accurate up to 14 digits, and $10^{72}$, times bigger than $x$. $\endgroup$ Commented Aug 1, 2020 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .