How to correctly check equality of non-integer numbers?
Georgi Guninski <[email protected]>
| Newsgroups | gmane.comp.mathematics.pari.devel |
|---|---|
| Message-ID | <CAGUWgD99SfBjiDVuFcyAQhHXudn7LK6WLvoNDK+VmSLa3wVf-w@mail.gmail.com> |
Given two non-integer numbers a1,a2 how to check they are "logically" equal? Direct comparison `a1==a2` not always works, e.g. this example: ? \p 100 ? A0=20+30*I;k=5;a1=lfun(1,A0,k);a2=derivnum(x=A0,zeta(x),k);[a1==a2,abs(a1-a2)==0] %8 = [0, 0] ? a1-a2 %9 = 2.2210727900800077785 E-114 + 8.030998757511428266 E-114*I Observe that we might have numerical instability of two expressions that are theoretically equal. I expect the result should be something like: ? abs(a1-a2) < 10^-(default(realprecision)-4) %15 = 1