Pergunta

I'd like to understand how absolute and relative errors work in order to write some code.

Suppose, we have x1*=4.54 x2*=3.00 and x3*=15.0, accuracy: 3 digits.
How do we define: a. the absolute error of x1*-x2*+x3* and
b. the absolute relative error of x1*x2*/x3* c. the accuracy in a and b.

Trying to make sense: a. |e1|<=0.5*10^(-3)

|e2|<=0.5*10^(-3)

|e3|<=0.5*10^(-3)

or |e1|<=0.5*10^(-2)

|e2|<=0.5*10^(-2)

|e3|<=0.5*10^(-1)

and then |e|<=|e1|+|e2|+|e3|=(15+4+3)*0.5*10^(-3) b. |r|<=|r1|+|r2|+|r3|=|e1/x1*|+|e2/x2*|+|e3/x3*|

Foi útil?

Solução

You're on the right track. Of course you can't find the actual error because you don't know the actual values. Thus you want to constrain the error. First note that we're talking about rounding error (as you've done), thus the maximum that each variable can be off by is 0.5 of its precision, i.e.

|e1| <= 0.005

|e2| <= 0.005

|e3| <= 0.05

For the absolute error of x1-x2+x3, the worst case is that all of the errors add together linearly, I.e.:

|e123| <= 0.005+0.005+0.05 = 0.06.

Because it's absolute error, you don't have to rescale by what the actual values of x1... are.

For the relative error of (x1x2)/x3, it's a little more complicated--you have to actually propogate (multiply) out the error. But, if you assume that the error is much smaller than the value, i.e. |e1| << x1 (which is a good approximation for this case), then you get the equation that you used in 'b':

|r| = |r123 / (x1x2/x3) | ~< |e1/x1| + |e2/x2| + |e3/x3|

Because this is relative error, you do have to rescale the errors by the actual values.

So, overall, you just about had it right --- just a little trouble with the absolute error.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top