Skip to content

Write dig-deeper page for darts and talk about hypot #660

Open
@cmcaine

Description

There's a cool paper here that details how Julia got a new algorithm for hypot that's much better than the old one and quite a lot better than the version that's in libm.

https://arxiv.org/pdf/1904.09481.pdf

Also worth talking about how you can work with radius^2. And some explanation of why doing these kinds of calculations with floats is generally safer than using ints to try and counteract the common fear of floats and complacency about integers.

It would be neat to explain a bit about precision, but I am bad at numerical analysis. I think if you use a fused multiply add to find the radius squared then you get two sources of error like this:

y2 = yyd1
r2 = fma(x, x, y2)*d2

where -eps/2 <= d1, d2 <= eps/2

So a final max theoretical error is something like: (eps/2)(xx + yy(eps/2)) . Which seems pretty small.

Mostly just for me, but the paper includes some corrections that I would like to understand. I think it's plausible that a number closer to the magnitude of the input variables can retain more precision than the sum of the squares of those input variables, so maybe the hypot function produces a value with higher theoretical precision?

Anyway, I can certainly recreate their experiments and find the experimental error for a variety of inputs.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions