Which function is more accurate?

  • Thread starter Thread starter blalien
  • Start date Start date
  • Tags Tags
    Function
AI Thread Summary
In a discussion on the accuracy of the functions x^2 - y^2 versus (x - y)(x + y) within a base 10 system with five-digit precision, it was determined that x^2 - y^2 is more accurate in a specific example where x = 1.0000 and y = 0.00001. The actual value of 0.999999999 was compared against the results of both functions, revealing that x^2 - y^2 yielded a value of 1, while (x - y)(x + y) resulted in 0.99999. The conclusion suggests that multiplication may introduce more rounding errors than addition or subtraction, particularly when the numbers involved are not very close. This discrepancy highlights the importance of understanding floating point errors and accumulated rounding errors in computational contexts. Overall, the discussion emphasizes that the accuracy of mathematical expressions can vary significantly based on their structure and the values used.
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.
 
Thread 'Have I solved this structural engineering equation correctly?'
Hi all, I have a structural engineering book from 1979. I am trying to follow it as best as I can. I have come to a formula that calculates the rotations in radians at the rigid joint that requires an iterative procedure. This equation comes in the form of: $$ x_i = \frac {Q_ih_i + Q_{i+1}h_{i+1}}{4K} + \frac {C}{K}x_{i-1} + \frac {C}{K}x_{i+1} $$ Where: ## Q ## is the horizontal storey shear ## h ## is the storey height ## K = (6G_i + C_i + C_{i+1}) ## ## G = \frac {I_g}{h} ## ## C...
Back
Top