1
$\begingroup$

How should I compute the maximum absolute and relative error of the following IEEE-754 floating-point expression?

a.y + (x - a.x) * ((b.y - a.y) / (b.x - a.x))

Also, we assume, that

  • the optimizer leaves the expression in the specified form
  • the default rounding mode (round to nearest even)
$\endgroup$
2
  • 3
    $\begingroup$ Hint: the absolute error on a sum/difference is the sum of the absolute errors and the relative error on a product/quotient is the sum of the relative errors. $\endgroup$
    – user16034
    Commented May 29, 2018 at 12:27
  • $\begingroup$ Depending on the values, the absolute and relative error could be very high. Particularly when a.y is close to b.y or b.x is close to a.x, your error could be awful. $\endgroup$
    – HackerBoss
    Commented Dec 15, 2020 at 19:18

2 Answers 2

0
$\begingroup$

IEEE 754 gives you the maximum relative error of each operation. You have three differences with a maximum relative error each. Multiplication and division adds the maximum relative error of each operand, plus the maximum relative error of the multiplication and division.

Then you have a final addition. If the right hand side is very close to the negative of the left hand side of the "+" then the relative error is unlimited. You'd need to analyse how close to -a.y the right hand side can be.

For absolute error, you convert the relative error of the right hand side into an absolute error.

$\endgroup$
0
$\begingroup$

Let the absolute errors on all variables be equal to $\delta$.

The absolute errors on the differences are $2\delta$ and the relative errors on the second term is

$$\frac{2\delta}{x-a_x}+\frac{2\delta}{b_y-a_y}+\frac{2\delta}{b_x-a_x}$$

So the final absolute error,

$$\delta\left(1+2\frac{(x-a_x)(b_y-a_y)}{b_x-a_x}\left(\frac1{x-a_x}+\frac1{b_y-a_y}+\frac1{b_x-a_x}\right)\right)$$

or

$$\delta\left(1+2\left(\frac{b_y-a_y}{b_x-a_x}+\frac{x-a_x}{b_x-a_x}+\frac{b_y-a_y}{b_x-a_x}\frac{x-a_x}{b_x-a_x}\right)\right)$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.