\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 \cdot x \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 20744661527.68968:\\
\;\;\;\;\frac{\sqrt[3]{1}}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{\left(x \cdot x - y \cdot \left(y \cdot 4\right)\right) \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)}}\\
\mathbf{elif}\;x \cdot x \leq 2.7895917333309595 \cdot 10^{+118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 2.928184284468576 \cdot 10^{+240}:\\
\;\;\;\;\frac{\sqrt[3]{1}}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{\left(x \cdot x - y \cdot \left(y \cdot 4\right)\right) \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)}}\\
\mathbf{elif}\;x \cdot x \leq 2.661347435828539 \cdot 10^{+286}:\\
\;\;\;\;-1\\
\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 x) 0.0)
-1.0
(if (<= (* x x) 20744661527.68968)
(/
(cbrt 1.0)
(/
(+ (* x x) (* y (* y 4.0)))
(* (- (* x x) (* y (* y 4.0))) (* (cbrt 1.0) (cbrt 1.0)))))
(if (<= (* x x) 2.7895917333309595e+118)
-1.0
(if (<= (* x x) 2.928184284468576e+240)
(/
(cbrt 1.0)
(/
(+ (* x x) (* y (* y 4.0)))
(* (- (* x x) (* y (* y 4.0))) (* (cbrt 1.0) (cbrt 1.0)))))
(if (<= (* x x) 2.661347435828539e+286) -1.0 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 * x) <= 0.0) {
tmp = -1.0;
} else if ((x * x) <= 20744661527.68968) {
tmp = cbrt(1.0) / (((x * x) + (y * (y * 4.0))) / (((x * x) - (y * (y * 4.0))) * (cbrt(1.0) * cbrt(1.0))));
} else if ((x * x) <= 2.7895917333309595e+118) {
tmp = -1.0;
} else if ((x * x) <= 2.928184284468576e+240) {
tmp = cbrt(1.0) / (((x * x) + (y * (y * 4.0))) / (((x * x) - (y * (y * 4.0))) * (cbrt(1.0) * cbrt(1.0))));
} else if ((x * x) <= 2.661347435828539e+286) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}








Bits error versus x








Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 14.5 |
| Alternative 1 | |
|---|---|
| Accuracy | 15.5 |
| Cost | 3137 |
| Alternative 2 | |
|---|---|
| Accuracy | 31.9 |
| Cost | 1792 |
| Alternative 3 | |
|---|---|
| Accuracy | 31.9 |
| Cost | 4992 |
| Alternative 4 | |
|---|---|
| Accuracy | 31.9 |
| Cost | 4096 |
if (*.f64 x x) < 0.0 or 20744661527.6896782 < (*.f64 x x) < 2.78959173333095949e118 or 2.928184284468576e240 < (*.f64 x x) < 2.6613474358285388e286Initial program 26.5
rmApplied clear-num_binary64_1815026.5
Simplified26.5
Taylor expanded around 0 18.3
if 0.0 < (*.f64 x x) < 20744661527.6896782 or 2.78959173333095949e118 < (*.f64 x x) < 2.928184284468576e240Initial program 15.6
rmApplied clear-num_binary64_1815015.6
Simplified15.6
rmApplied add-cube-cbrt_binary64_1818615.6
Applied associate-/l*_binary64_1809615.6
Simplified15.6
rmApplied associate-/l*_binary64_1809615.6
Simplified15.6
if 2.6613474358285388e286 < (*.f64 x x) Initial program 61.2
rmApplied clear-num_binary64_1815061.2
Simplified61.2
Taylor expanded around inf 8.1
Final simplification14.5
herbie shell --seed 2020322
(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))))