5 ms·
The precondition on the link you shared has -1 <= x && x <= 1, so 99 is way outside of that range. But even so, testing for x=1, which is supposed to be inside
by yossi_peti 6mo ago
The precondition on the link you shared has -1 <= x && x <= 1, so 99 is way outside of that range. But even so, testing for x=1, which is supposed to be inside that range, 0.5 doesn't seem tolerably close to 0.4142.
- LiamPowell 6mo agoI have a suspicion that the accuracy number is the mean of accuracies over all valid floats in the range (or something approximating that), which is going to be weighted towards zero where the accuracy is higher, and perhaps where sqrt near 1 has some artefacts.
- pavpanchekha 6mo agoIt is, there's a page in the documentation about how errors are defined. Let me also add: Herbie generally gives the most accurate option it found first, and then the other stuff might be useful for speed (0.5x is way faster than two square roots and a divide!) but it's not as accurate
- Rexxar 6mo agoThe input should be the range and the distribution of probability on this range. Intuitively we have a tendency to assume an uniform probability for range [-1, 1] which is not the case if we check every doubles.
- fluorinerocket 6mo agoYou're right but still, big error. I get its averaging over the range, and the floats are not uniformly distributed. Maybe the thing to optimize the expression for is the minimize the maximum error, and not the average error. I think that's what I would care about