1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Which function is more accurate?

  1. Jan 28, 2010 #1
    1. The problem statement, all variables and given/known data
    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)?

    2. Relevant equations
    None really.

    3. 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-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.
  2. jcsd
  3. Jan 28, 2010 #2
    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook