\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}\;y \leq -7.413866609077746 \cdot 10^{+103}:\\
\;\;\;\;-1 + 0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right)\\
\mathbf{elif}\;y \leq -2.7183403829409112 \cdot 10^{-102}:\\
\;\;\;\;\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}\;y \leq 4.472181259931087 \cdot 10^{-75}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2199607436705692 \cdot 10^{+119}:\\
\;\;\;\;\frac{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\sqrt{x \cdot x + y \cdot \left(y \cdot 4\right)}}}{\sqrt{x \cdot x + y \cdot \left(y \cdot 4\right)}}\\
\mathbf{else}:\\
\;\;\;\;-1 + 0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right)\\
\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 (<= y -7.413866609077746e+103)
(+ -1.0 (* 0.5 (* (/ x y) (/ x y))))
(if (<= y -2.7183403829409112e-102)
(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 (<= y 4.472181259931087e-75)
1.0
(if (<= y 3.2199607436705692e+119)
(/
(/ (- (* x x) (* y (* y 4.0))) (sqrt (+ (* x x) (* y (* y 4.0)))))
(sqrt (+ (* x x) (* y (* y 4.0)))))
(+ -1.0 (* 0.5 (* (/ x y) (/ x y)))))))))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 (y <= -7.413866609077746e+103) {
tmp = -1.0 + (0.5 * ((x / y) * (x / y)));
} else if (y <= -2.7183403829409112e-102) {
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 (y <= 4.472181259931087e-75) {
tmp = 1.0;
} else if (y <= 3.2199607436705692e+119) {
tmp = (((x * x) - (y * (y * 4.0))) / sqrt((x * x) + (y * (y * 4.0)))) / sqrt((x * x) + (y * (y * 4.0)));
} else {
tmp = -1.0 + (0.5 * ((x / y) * (x / y)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 12.7 |
if y < -7.4138666090777461e103 or 3.2199607436705692e119 < y Initial program 54.2
Taylor expanded around 0 16.5
Simplified16.5
rmApplied times-frac_binary64_161119.9
if -7.4138666090777461e103 < y < -2.7183403829409112e-102Initial program 16.4
rmApplied add-cbrt-cube_binary64_1614116.4
if -2.7183403829409112e-102 < y < 4.47218125993108705e-75Initial program 26.8
Taylor expanded around inf 12.0
if 4.47218125993108705e-75 < y < 3.2199607436705692e119Initial program 15.9
rmApplied add-sqr-sqrt_binary64_1612715.9
Applied associate-/r*_binary64_1604916.0
Final simplification12.7
herbie shell --seed 2021043
(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))))