\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := x - \frac{x \cdot z}{y}\\
t_1 := \frac{x \cdot \left(y - z\right)}{y}\\
t_2 := x \cdot \frac{y - z}{y}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -3.9680877061023717 \cdot 10^{-53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{elif}\;t_1 \leq 9.966738429679642 \cdot 10^{+297}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (/ (* x z) y)))
(t_1 (/ (* x (- y z)) y))
(t_2 (* x (/ (- y z) y))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -3.9680877061023717e-53)
t_0
(if (<= t_1 0.0)
(/ x (/ y (- y z)))
(if (<= t_1 9.966738429679642e+297) t_0 t_2))))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double t_0 = x - ((x * z) / y);
double t_1 = (x * (y - z)) / y;
double t_2 = x * ((y - z) / y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -3.9680877061023717e-53) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = x / (y / (y - z));
} else if (t_1 <= 9.966738429679642e+297) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.7 |
|---|---|
| Target | 2.9 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0 or 9.9667384296796421e297 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 62.3
Applied egg-rr0.6
Applied egg-rr0.4
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.96808770610237167e-53 or -0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 9.9667384296796421e297Initial program 0.3
Taylor expanded in y around 0 0.2
if -3.96808770610237167e-53 < (/.f64 (*.f64 x (-.f64 y z)) y) < -0.0Initial program 14.8
Applied egg-rr0.1
Applied egg-rr0.1
Final simplification0.2
herbie shell --seed 2022125
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))