x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{y}{z} \cdot x\\
t_2 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -1.768045311118471 \cdot 10^{+144}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{y}{z} \leq -1.0602978721814878 \cdot 10^{-215}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq 4.435953205233472 \cdot 10^{-95}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{y}{z} \leq 2.6259892455976272 \cdot 10^{+203}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ y z) x)) (t_2 (/ y (/ z x))))
(if (<= (/ y z) -1.768045311118471e+144)
t_2
(if (<= (/ y z) -1.0602978721814878e-215)
t_1
(if (<= (/ y z) 4.435953205233472e-95)
t_2
(if (<= (/ y z) 2.6259892455976272e+203) t_1 (* y (/ x z))))))))double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
double t_1 = (y / z) * x;
double t_2 = y / (z / x);
double tmp;
if ((y / z) <= -1.768045311118471e+144) {
tmp = t_2;
} else if ((y / z) <= -1.0602978721814878e-215) {
tmp = t_1;
} else if ((y / z) <= 4.435953205233472e-95) {
tmp = t_2;
} else if ((y / z) <= 2.6259892455976272e+203) {
tmp = t_1;
} else {
tmp = y * (x / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 14.7 |
|---|---|
| Target | 1.5 |
| Herbie | 1.1 |
if (/.f64 y z) < -1.768045311118471e144 or -1.0602978721814878e-215 < (/.f64 y z) < 4.43595320523347225e-95Initial program 19.3
Simplified10.7
Taylor expanded in x around 0 1.8
Applied associate-/l*_binary642.1
if -1.768045311118471e144 < (/.f64 y z) < -1.0602978721814878e-215 or 4.43595320523347225e-95 < (/.f64 y z) < 2.62598924559762723e203Initial program 7.4
Simplified0.3
if 2.62598924559762723e203 < (/.f64 y z) Initial program 42.6
Simplified27.3
Taylor expanded in x around 0 0.8
Applied *-un-lft-identity_binary640.8
Applied times-frac_binary640.8
Simplified0.8
Final simplification1.1
herbie shell --seed 2022125
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))