Which function is more accurate?

  • Thread starter Thread starter blalien
  • Start date Start date
  • Tags Tags
    Function
Click For Summary
SUMMARY

The discussion centers on the accuracy of two mathematical functions: x^2 - y^2 and (x - y)(x + y) when evaluated with a precision of 5 digits in base 10. The analysis reveals that for specific values, such as x = 1.0000 and y = 0.00001, the function x^2 - y^2 yields a more accurate result (1) compared to (x - y)(x + y) which results in 0.99999. This discrepancy arises from the inherent floating-point errors and accumulated rounding errors associated with multiplication versus subtraction and addition.

PREREQUISITES
  • Understanding of floating-point arithmetic
  • Knowledge of numerical precision and rounding errors
  • Familiarity with basic algebraic identities
  • Experience with mathematical functions in programming
NEXT STEPS
  • Research floating-point error analysis in programming languages
  • Explore numerical stability in mathematical computations
  • Learn about the IEEE 754 standard for floating-point arithmetic
  • Investigate the impact of precision on mathematical functions in software applications
USEFUL FOR

Mathematicians, computer scientists, software developers, and anyone interested in understanding the implications of numerical precision and accuracy in computational mathematics.

blalien
Messages
31
Reaction score
0

Homework Statement


You have a number system in base 10 with a precision of 5 digits. Which function is more accurate: x^2-y^2 or (x-y)(x+y)?

Homework Equations


None really.

The Attempt at a Solution


My intuition would tell me that (x-y)(x+y) is more accurate, since multiplication is less accurate than addition or subtraction (unless the two numbers are very close). But look at x = 1.0000, y = 0.00001:

Actual value: 0.999999999

x^2 = 1, y^2 = 1e-10 ~ 0
x^2-y^2=1

x-y = 0.99999
x+y = 1.00001 ~ 1
(x-y)(x+y) = 0.99999

So x^2-y^2 is more accurate, at least in this situation. I have no idea why, though.
 
Physics news on Phys.org
blalien said:
So x^2-y^2 is more accurate, at least in this situation. I have no idea why, though.
Which class is this for? If it's a programming class/computer architecture class/etc. the answer probably has to do with floating point errors and accumulated rounding errors.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
3K