\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\begin{array}{l}
\mathbf{if}\;x \leq -4.833721844680349 \cdot 10^{+87}:\\
\;\;\;\;1 - 8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -1.6932163406705725 \cdot 10^{-159}:\\
\;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)} \cdot \left(\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)} \cdot \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\right)}\\
\mathbf{elif}\;x \leq 7.088159935425954 \cdot 10^{-155}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.4090580343274923 \cdot 10^{+70}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + 4 \cdot \left(y \cdot y\right)}{x \cdot x + \left(y \cdot y\right) \cdot -4}}\\
\mathbf{elif}\;x \leq 2.8060004685656228 \cdot 10^{+85}:\\
\;\;\;\;-1 + 0.5 \cdot \frac{{x}^{2}}{{y}^{2}}\\
\mathbf{elif}\;x \leq 5.71734574737866 \cdot 10^{+172} \lor \neg \left(x \leq 5.841742874771862 \cdot 10^{+172}\right):\\
\;\;\;\;1 - 8 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(if (<= x -4.833721844680349e+87)
(- 1.0 (* 8.0 (* (/ y x) (/ y x))))
(if (<= x -1.6932163406705725e-159)
(cbrt
(*
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(*
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0)))))))
(if (<= x 7.088159935425954e-155)
-1.0
(if (<= x 1.4090580343274923e+70)
(/ 1.0 (/ (+ (* x x) (* 4.0 (* y y))) (+ (* x x) (* (* y y) -4.0))))
(if (<= x 2.8060004685656228e+85)
(+ -1.0 (* 0.5 (/ (pow x 2.0) (pow y 2.0))))
(if (or (<= x 5.71734574737866e+172)
(not (<= x 5.841742874771862e+172)))
(- 1.0 (* 8.0 (* (/ y x) (/ y x))))
-1.0)))))))double code(double x, double y) {
return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
double code(double x, double y) {
double tmp;
if (x <= -4.833721844680349e+87) {
tmp = 1.0 - (8.0 * ((y / x) * (y / x)));
} else if (x <= -1.6932163406705725e-159) {
tmp = cbrt((((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)))) * ((((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)))) * (((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0))))));
} else if (x <= 7.088159935425954e-155) {
tmp = -1.0;
} else if (x <= 1.4090580343274923e+70) {
tmp = 1.0 / (((x * x) + (4.0 * (y * y))) / ((x * x) + ((y * y) * -4.0)));
} else if (x <= 2.8060004685656228e+85) {
tmp = -1.0 + (0.5 * (pow(x, 2.0) / pow(y, 2.0)));
} else if ((x <= 5.71734574737866e+172) || !(x <= 5.841742874771862e+172)) {
tmp = 1.0 - (8.0 * ((y / x) * (y / x)));
} else {
tmp = -1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 32.4 |
|---|---|
| Target | 32.1 |
| Herbie | 12.8 |
if x < -4.8337218446803486e87 or 2.8060004685656228e85 < x < 5.71734574737866021e172 or 5.8417428747718621e172 < x Initial program 49.8
Taylor expanded around inf 17.4
Simplified17.4
rmApplied times-frac_binary6410.9
if -4.8337218446803486e87 < x < -1.6932163406705725e-159Initial program 16.4
rmApplied add-cbrt-cube_binary6416.4
if -1.6932163406705725e-159 < x < 7.08815993542595428e-155 or 5.71734574737866021e172 < x < 5.8417428747718621e172Initial program 31.0
Taylor expanded around 0 8.4
if 7.08815993542595428e-155 < x < 1.4090580343274923e70Initial program 17.0
rmApplied clear-num_binary6417.0
Simplified17.0
if 1.4090580343274923e70 < x < 2.8060004685656228e85Initial program 17.7
Taylor expanded around 0 37.5
Final simplification12.8
herbie shell --seed 2021118
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))