News for hackers. Stuff that matters.
Re:Show HN: A Mathematical Integration rust crate by wiz21c on Tuesday November 19, 2024 @02:50PM (#42187378)
In the rectangle method, there is "let x = a + i * h + (h / F1::from(2)...)"

I didn't check, but I wonder if it is not better to do x = a + (i+0.5)*h... My reasoning is that if "i" is very big, then i * h can be much bigger than h/2 and thus h/2 may be eaten by numerical precision when added to i*h... And then you have to convince the optimizer to do it the way you want. But well, it's late...

Re:Show HN: A Mathematical Integration rust crate by zokier on Tuesday November 19, 2024 @05:37PM (#42188835)
herbie recommends `fma(h, (i + 0.5), a)`, but also doesn't report any accuracy problems with the original either
Re:Show HN: A Mathematical Integration rust crate by wiz21c on Wednesday November 20, 2024 @03:40AM (#42191905)
yeah, fused mul-add is certainly better. Dunno how one epxresses that in rust though :-) Ahhh seems like there at least f64::mul_add() in stdlib :-)