exercism / exercism/julia

Write dig-deeper page for darts and talk about hypot

Open
#660 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
73
Forks
82
Avg merge
2h 17m
Merged PRs (30d)
5

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 = y*y*d1
r2 = fma(x, x, y2)*d2

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

So a final max theoretical error is something like: (eps/2)*(x*x + y*y*(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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.