Georgi Guninski on Tue, 28 Sep 2021 10:46:20 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
How to correctly check equality of non-integer numbers?
|
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: How to correctly check equality of non-integer numbers?
- From: Georgi Guninski <gguninski@gmail.com>
- Date: Tue, 28 Sep 2021 11:46:05 +0300
- Delivery-date: Tue, 28 Sep 2021 10:46:20 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=yJuWzxffHwWY8Brh639VkxJUzU8xpAEh80Sfya5OmU4=; b=FPqy1kYXTJFUgbZDgrqrT/WzKRdYZ/AU+95l9UKqyUeON4VVPMaZrAVmu4rok3ItrL reZ1TSHLYZuSGX9ENUc+9q5rbzrjc8f0wu42QbZmbX2QRraJ40Ug5hX3g1Gopc8+84gG lmM0ShEgthfad2DmhfFUycOVrz9zo+Xt93TJiL1lzkPEDH94e/e7SErWulS2K+Y1IipI 0tYDcAK4eVxTq/189aR0dDodHdyJBoLxKUiA1lbnMgYsxlSpww6Qc0i3s4F6xzlUle8E 576a4aD4/VGIp028bW3aOz/WHn/5lihHC/wQWC4afYXfpUiVsps2/KszVzd+z9UZ0IUX 2IuA==
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