Post Reply 
complex log
02-07-2024, 11:03 AM (This post was last modified: 02-07-2024 12:35 PM by Albert Chan.)
Post: #3
RE: complex log
I was confused how giorgiomcmlx produce plots in How to calculate 1-x·x in floating-point
Then, I figure this out ... we are measuring different things!

Previous post compared ratio of relative errors, measure against exact (x^2-1)

Plots does absolute errors against correctly-rounded (x^2-1)
(negated, but error have same plot, |exact-approx| = |(-exact)-(-approx)|)

We can't get any better than correctly rounded!

We don't need double-double (~106 bits), just fma(x,x,-1) for the reference.
Code:
function ratio_relerr(n, lo, hi)
    local e1, e2, x, y = 0, 0
    for i = 1,n do
        repeat x = lo + (hi-lo)*random() until x~=1
        y = fma(x,x,-1)
        e1 = e1 + abs((y-(x+1)*(x-1))/y)
        x = x-1
        e2 = e2 + abs((y-(2*x + x*x))/y)
    end
    return e1/e2
end

lua> ratio_relerr(1e6, .5, 1)
1.3800592174099267
lua> ratio_relerr(1e6, 1, 1.732)
2.9941118786964216
lua> ratio_relerr(1e6, .5, 1.732)
2.3113799166880664

lua> ratio_relerr(1e6, 0.9, 1.1)
18.32637500303419
lua> ratio_relerr(1e6, 0.99, 1.01)
192.75860912929932
lua> ratio_relerr(1e6, 0.999, 1.001)
2008.010676441317

This now matched the plot when x ≈ 1
[Image: omxsq__erraccum__www.png?w=712]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
complex log - Albert Chan - 02-07-2024, 12:47 AM
RE: complex log - Albert Chan - 02-07-2024, 12:49 AM
RE: complex log - Albert Chan - 02-07-2024, 11:24 PM
RE: complex log - Albert Chan - 02-07-2024 11:03 AM
RE: complex log - Albert Chan - 02-08-2024, 09:04 PM
RE: complex log - Albert Chan - 02-10-2024, 09:55 PM
RE: complex log - Albert Chan - 02-11-2024, 06:32 PM



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