Post Reply 
Free42 possible accuracy flaw
03-23-2022, 09:11 PM
Post: #16
RE: Free42 possible accuracy flaw
Continued on from previous post, lets add mul, and ipow

Code:
def mul(z1, z2):
    x1, y1 = z1.real, z1.imag
    x2, y2 = z2.real, z2.imag
    x3 = x1*x2
    return normalize(x3, fsum([fma(x1,x2,-x3), x1*y2, x2*y1]))

def ipow(x,n):  # assumed integer n > 0
    if n <= 1: return x
    y = ipow(sqr(x), n//2)
    return y if n%2==0 else mul(x,y)

Lets do (1+1/1e8) ^ 1e8

To represent decimal base more accurately:

exact(1+1/1e8) - float(1+1/1e8) ≈ 6.07747097092215e-017

>>> from gmpy2 import *
>>> ipow((1+1/1e8) + 6.07747097092215e-017j, 1e8)
(2.7182818148676362+1.4094245018370637e-17j)

Add parts together, convert to decimal base, we matched true result 24 digits.
Or, considering 2 doubles have about 30 digits precision, we lost 6.

2.718281814867636217652976740666852
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Free42 possible accuracy flaw - Werner - 03-23-2022, 07:30 AM
RE: Free42 possible accuracy flaw - Werner - 03-23-2022, 08:49 AM
RE: Free42 possible accuracy flaw - Albert Chan - 03-23-2022 09:11 PM
RE: Free42 possible accuracy flaw - Werner - 03-25-2022, 07:03 AM
RE: Free42 possible accuracy flaw - Werner - 03-30-2022, 08:04 AM
RE: Free42 possible accuracy flaw - Werner - 03-25-2022, 08:53 AM



User(s) browsing this thread: 3 Guest(s)