\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\begin{array}{l}
\mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -2.0587203320363797 \cdot 10^{+298}:\\
\;\;\;\;x + -0.3333333333333333 \cdot \frac{y - \frac{t}{y}}{z}\\
\mathbf{elif}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -5.274546549140728 \cdot 10^{-10}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-0.3333333333333333 \cdot \left(y + t \cdot \frac{-1}{y}\right)}{z}\\
\end{array}(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
:precision binary64
(if (<=
(+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
-2.0587203320363797e+298)
(+ x (* -0.3333333333333333 (/ (- y (/ t y)) z)))
(if (<=
(+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
-5.274546549140728e-10)
(+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
(+ x (/ (* -0.3333333333333333 (+ y (* t (/ -1.0 y)))) z)))))double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
double tmp;
if (((x - (y / (z * 3.0))) + (t / (y * (z * 3.0)))) <= -2.0587203320363797e+298) {
tmp = x + (-0.3333333333333333 * ((y - (t / y)) / z));
} else if (((x - (y / (z * 3.0))) + (t / (y * (z * 3.0)))) <= -5.274546549140728e-10) {
tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
} else {
tmp = x + ((-0.3333333333333333 * (y + (t * (-1.0 / y)))) / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 3.6 |
|---|---|
| Target | 1.7 |
| Herbie | 2.3 |
if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -2.05872033203637967e298Initial program 37.8
Simplified2.5
Taylor expanded around 0 3.0
if -2.05872033203637967e298 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -5.27454654914072818e-10Initial program 0.4
if -5.27454654914072818e-10 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) Initial program 3.1
Simplified3.5
Taylor expanded around inf 3.5
Simplified3.6
rmApplied associate-*r/_binary64_184343.5
Simplified3.5
rmApplied div-inv_binary64_184893.5
Applied cancel-sign-sub-inv_binary64_184583.5
Final simplification2.3
herbie shell --seed 2021098
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))