Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(1-x)/x - 1/x =1/x - 1 - 1/x = -1

Evaluating the expression naively near zero you're going to get wild numerical errors, but if you do the symbolic manipulation you're going to notice that it's just equal to -1.

Edit: e.g. consider this interaction I just had with the python interpreter

    >>> x=1e-15
    >>> (1-x)/x - 1/x
    -1.0
    >>> x=1e-16
    >>> (1-x)/x - 1/x
    0.0
you get completely the wrong answer when x = 1e-16


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: