\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{x}{y}, x, y\right)\\
\mathbf{if}\;z \cdot z \leq 1.0679394866726301 \cdot 10^{+297}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z \cdot z}{y} - t_0\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot 0.5\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (/ x y) x y)))
(if (<= (* z z) 1.0679394866726301e+297)
(* -0.5 (- (/ (* z z) y) t_0))
(* t_0 0.5))))double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
double code(double x, double y, double z) {
double t_0 = fma((x / y), x, y);
double tmp;
if ((z * z) <= 1.0679394866726301e+297) {
tmp = -0.5 * (((z * z) / y) - t_0);
} else {
tmp = t_0 * 0.5;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 28.1 |
|---|---|
| Target | 0.2 |
| Herbie | 3.8 |
if (*.f64 z z) < 1.0679394866726301e297Initial program 23.9
Simplified6.8
Applied div-sub_binary646.8
Applied associate--l-_binary646.8
Simplified0.7
if 1.0679394866726301e297 < (*.f64 z z) Initial program 62.0
Simplified59.2
Taylor expanded in z around 0 37.5
Simplified29.5
Final simplification3.8
herbie shell --seed 2021215
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))