\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 4.040004113947438 \cdot 10^{-200}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 1.2864016597837409 \cdot 10^{-130}:\\
\;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{elif}\;x \cdot x \leq 8.302497373615917 \cdot 10^{-66}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \cdot x \leq 3.4612524063184616 \cdot 10^{+242}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{x \cdot x - y \cdot \left(y \cdot 4\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 x) 4.040004113947438e-200)
-1.0
(if (<= (* x x) 1.2864016597837409e-130)
(/ (- (* x x) (* y (* y 4.0))) (+ (* x x) (* y (* y 4.0))))
(if (<= (* x x) 8.302497373615917e-66)
-1.0
(if (<= (* x x) 3.4612524063184616e+242)
(/ 1.0 (/ (+ (* x x) (* y (* y 4.0))) (- (* x x) (* y (* y 4.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) <= 4.040004113947438e-200) {
tmp = -1.0;
} else if ((x * x) <= 1.2864016597837409e-130) {
tmp = ((x * x) - (y * (y * 4.0))) / ((x * x) + (y * (y * 4.0)));
} else if ((x * x) <= 8.302497373615917e-66) {
tmp = -1.0;
} else if ((x * x) <= 3.4612524063184616e+242) {
tmp = 1.0 / (((x * x) + (y * (y * 4.0))) / ((x * x) - (y * (y * 4.0))));
} else {
tmp = 1.0;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 32.1 |
|---|---|
| Target | 31.8 |
| Herbie | 12.9 |
if (*.f64 x x) < 4.0400041139474382e-200 or 1.28640165978374089e-130 < (*.f64 x x) < 8.3024973736159172e-66Initial program 26.0
Taylor expanded around 0 12.5
if 4.0400041139474382e-200 < (*.f64 x x) < 1.28640165978374089e-130Initial program 17.7
if 8.3024973736159172e-66 < (*.f64 x x) < 3.46125240631846158e242Initial program 16.2
rmApplied clear-num_binary64_1439916.2
Simplified16.2
if 3.46125240631846158e242 < (*.f64 x x) Initial program 55.3
Taylor expanded around inf 10.0
Final simplification12.9
herbie shell --seed 2020342
(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))))