2
$\begingroup$

The relative error is defined by the simple formula:

$$\text{Rel. Error} = \frac{|v_\text{approx}-v_\text{analytical}|}{v_\text{analytical}}$$

but what if the theoretical value $v_\text{analytical}$ should be $0$? then our relative error is undefined.... this is also quite a common occurs. If our analytical function is $x^2$ then at its $x=0$ we have a problem.

I'm trying to program this on a computer. How do I make sure that I don't have any problems with this formula?

$\endgroup$
1
  • 1
    $\begingroup$ I'd say that in such cases the relative error is not a good error measurement technique. $\endgroup$
    – lisyarus
    Nov 3, 2017 at 13:56

3 Answers 3

1
$\begingroup$

You could argue that in that particular case, the relative error is not a good measure.

Note that usually the relative error is defined a the ratio of the absolute error and the absolute true value, i.e. $$ \mathrm{Rel. Error} = \frac{ |v_{\mathrm{approx}} - v_{\mathrm{analytical}}| }{ |v_\mathrm{analytical}| }. $$

An alternative would be to use just the absolute error or to define the relative error as follows:

$$ \mathrm{Rel. Error} = \frac{ |v_{\mathrm{approx}} - v_{\mathrm{analytical}}| }{ 1+|v_\mathrm{analytical}| }. $$

$\endgroup$
0
$\begingroup$

Relative error is generally only used for quantities that can only be non-negative.

$\endgroup$
0
$\begingroup$

Unfortunately, there is no good answer.

There is of course no relative error to a zero quantity and you need to use an absolute error. Then two embarrasing questions:

  • what absolute error can you choose ?

  • when do you switch from relative to absolute ?

These are application-dependent and can't be "hard-coded" in a program.

$\endgroup$

You must log in to answer this question.

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