x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -2.5913527548956093 \cdot 10^{-145}:\\
\;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\
\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 0:\\
\;\;\;\;\frac{y}{z} \cdot x + \frac{x}{z} \cdot \left(t + \frac{t}{z}\right)\\
\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.9748042716300287 \cdot 10^{+255}:\\
\;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\
\end{array}(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
:precision binary64
(if (<= (- (/ y z) (/ t (- 1.0 z))) -2.5913527548956093e-145)
(* (- (/ y z) (/ t (- 1.0 z))) x)
(if (<= (- (/ y z) (/ t (- 1.0 z))) 0.0)
(+ (* (/ y z) x) (* (/ x z) (+ t (/ t z))))
(if (<= (- (/ y z) (/ t (- 1.0 z))) 1.9748042716300287e+255)
(* (- (/ y z) (/ t (- 1.0 z))) x)
(/ (* x (- (* y (- 1.0 z)) (* z t))) (* z (- 1.0 z)))))))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 tmp;
if (((y / z) - (t / (1.0 - z))) <= -2.5913527548956093e-145) {
tmp = ((y / z) - (t / (1.0 - z))) * x;
} else if (((y / z) - (t / (1.0 - z))) <= 0.0) {
tmp = ((y / z) * x) + ((x / z) * (t + (t / z)));
} else if (((y / z) - (t / (1.0 - z))) <= 1.9748042716300287e+255) {
tmp = ((y / z) - (t / (1.0 - z))) * x;
} else {
tmp = (x * ((y * (1.0 - z)) - (z * t))) / (z * (1.0 - z));
}
return tmp;
}












Bits error versus x












Bits error versus y












Bits error versus z












Bits error versus t
Results
| Original | 4.4 |
|---|---|
| Target | 4.2 |
| Herbie | 2.8 |
| Alternative 1 | |
|---|---|
| Error | 4.3 |
| Cost | 2312 |
| Alternative 2 | |
|---|---|
| Error | 4.4 |
| Cost | 704 |
| Alternative 3 | |
|---|---|
| Error | 5.1 |
| Cost | 776 |
| Alternative 4 | |
|---|---|
| Error | 13.3 |
| Cost | 776 |
| Alternative 5 | |
|---|---|
| Error | 13.6 |
| Cost | 776 |
| Alternative 6 | |
|---|---|
| Error | 27.7 |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 55.4 |
| Cost | 64 |
| Alternative 8 | |
|---|---|
| Error | 61.7 |
| Cost | 64 |

if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -2.59135275489560931e-145 or 0.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.9748042716300287e255Initial program 2.2
Simplified2.2
if -2.59135275489560931e-145 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 0.0Initial program 8.1
rmApplied add-cube-cbrt_binary64_134128.3
Taylor expanded around inf 3.4
Simplified7.0
Simplified7.0
if 1.9748042716300287e255 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) Initial program 32.0
rmApplied frac-sub_binary64_1338634.5
Applied associate-*r/_binary64_133192.9
Simplified2.9
Final simplification2.8
herbie shell --seed 2021044
(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)))))