\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := x \cdot \left(y - z\right)\\
t_1 := \frac{t_0}{y}\\
t_2 := x \cdot \frac{y - z}{y}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -2.082978945168603 \cdot 10^{+190}:\\
\;\;\;\;t_0 \cdot \frac{1}{y}\\
\mathbf{elif}\;t_1 \leq 947192973.4213506:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 1.1655371408352642 \cdot 10^{+279}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- y z))) (t_1 (/ t_0 y)) (t_2 (* x (/ (- y z) y))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -2.082978945168603e+190)
(* t_0 (/ 1.0 y))
(if (<= t_1 947192973.4213506)
t_2
(if (<= t_1 1.1655371408352642e+279)
(- x (/ (* x z) y))
(* x (- 1.0 (/ z y)))))))))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 * (y - z);
double t_1 = t_0 / y;
double t_2 = x * ((y - z) / y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -2.082978945168603e+190) {
tmp = t_0 * (1.0 / y);
} else if (t_1 <= 947192973.4213506) {
tmp = t_2;
} else if (t_1 <= 1.1655371408352642e+279) {
tmp = x - ((x * z) / y);
} else {
tmp = x * (1.0 - (z / y));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.5 |
|---|---|
| Target | 2.4 |
| Herbie | 0.9 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0 or -2.0829789451686031e190 < (/.f64 (*.f64 x (-.f64 y z)) y) < 947192973.421350598Initial program 10.5
Applied *-un-lft-identity_binary6410.5
Applied times-frac_binary641.0
Simplified1.0
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2.0829789451686031e190Initial program 0.2
Applied *-un-lft-identity_binary640.2
Applied times-frac_binary6413.3
Simplified13.3
Applied div-inv_binary6413.3
Applied associate-*r*_binary640.3
Simplified0.3
if 947192973.421350598 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.16553714083526419e279Initial program 0.2
Taylor expanded in y around 0 0.2
if 1.16553714083526419e279 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 24.1
Applied *-un-lft-identity_binary6424.1
Applied times-frac_binary641.2
Simplified1.2
Taylor expanded in y around 0 1.2
Final simplification0.9
herbie shell --seed 2022088
(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))