x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t_1 \leq -2.181314069237898 \cdot 10^{-307}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{-1}{1 - z}\\
x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, t \cdot t_2\right) + \mathsf{fma}\left(t_2, t, t \cdot \frac{1}{1 - z}\right)\right)
\end{array}\\
\mathbf{elif}\;t_1 \leq 1.1559562824622024 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + t\right)\\
\mathbf{elif}\;t_1 \leq 6.454915979042131 \cdot 10^{+273}:\\
\;\;\;\;t_1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z} - t \cdot x\\
\end{array}
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
(if (<= t_1 -2.181314069237898e-307)
(let* ((t_2 (/ -1.0 (- 1.0 z))))
(*
x
(+ (fma y (/ 1.0 z) (* t t_2)) (fma t_2 t (* t (/ 1.0 (- 1.0 z)))))))
(if (<= t_1 1.1559562824622024e-159)
(* (/ x z) (+ y t))
(if (<= t_1 6.454915979042131e+273)
(* t_1 x)
(- (/ (* y x) z) (* t x)))))))double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_1 <= -2.181314069237898e-307) {
double t_2_1 = -1.0 / (1.0 - z);
tmp = x * (fma(y, (1.0 / z), (t * t_2_1)) + fma(t_2_1, t, (t * (1.0 / (1.0 - z)))));
} else if (t_1 <= 1.1559562824622024e-159) {
tmp = (x / z) * (y + t);
} else if (t_1 <= 6.454915979042131e+273) {
tmp = t_1 * x;
} else {
tmp = ((y * x) / z) - (t * x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 4.5 |
|---|---|
| Target | 4.2 |
| Herbie | 2.1 |
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -2.18131406923789798e-307Initial program 3.6
Applied div-inv_binary643.7
Applied div-inv_binary643.7
Applied prod-diff_binary643.7
if -2.18131406923789798e-307 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.15595628246220237e-159Initial program 9.5
Applied sub-neg_binary649.5
Taylor expanded in z around inf 2.3
Simplified2.2
if 1.15595628246220237e-159 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 6.45491597904213068e273Initial program 0.2
Applied sub-neg_binary640.2
Taylor expanded in x around 0 0.2
if 6.45491597904213068e273 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) Initial program 38.9
Taylor expanded in z around 0 1.3
Final simplification2.1
herbie shell --seed 2022081
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
:precision binary64
:herbie-target
(if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))
(* x (- (/ y z) (/ t (- 1.0 z)))))