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)
  • 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$ – Yves Daoust May 29 '18 at 12:27
  • $\begingroup$ Why exactly is this question coming back? $\endgroup$ – gnasher729 Apr 25 '19 at 8:11
  • $\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 Dec 15 '20 at 19:18

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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