Hello, > Did you enable FMA? I'd expect 1 - x*x to be accurate with FMA, so the > relative error > should be much better. If there is no FMA, 2*(1-fabs(x)) - (1-fabs(x))^2 > should be > more accurate when abs(x)>0.5 and still much faster.
No, but I will check how to enable it if FMA is available. I did a minor test with your formula and the precision improved a lot. Here is an example for floats with input : = 9.99999880790710449218750000000000000000000000000000e-01 cosh: before: = 2.04800000000000000000000000000000000000000000000000e+03 cosh: after : = 2.04800024414062500000000000000000000000000000000000e+03 cosh: mpfr : = 2.04800006103515897848424084406334262726138617589463e+03 error before: = 6.10351589784842408440633426272613861758946325324235e-05 error after : = 1.83105466021515759155936657372738613824105367467577e-04 But now I am puzzled about how did you come up with that formula :-). I am able to proof equality, but how did you know it was going to be more precise? On Thu, Oct 18, 2018 at 7:41 PM Wilco Dijkstra <wilco.dijks...@arm.com> wrote: > > Hi, > > > Well, I compared the results before and after the simplifications with a > > 512-bit > > precise mpfr value. Unfortunately, I found that sometimes the error is very > > noticeable :-( . > > Did you enable FMA? I'd expect 1 - x*x to be accurate with FMA, so the > relative error > should be much better. If there is no FMA, 2*(1-fabs(x)) - (1-fabs(x))^2 > should be > more accurate when abs(x)>0.5 and still much faster. > > Wilco > >