\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 -2.329334044066695 \cdot 10^{+153}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x + t_0\\
t_2 := x \cdot x - t_0\\
\mathbf{if}\;x \leq -1.8134981297322904 \cdot 10^{-53}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{t_2}{t_1}\\
\sqrt[3]{t_3 \cdot \left(t_3 \cdot t_3\right)}
\end{array}\\
\mathbf{elif}\;x \leq -3.9297601949890104 \cdot 10^{-88}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x \cdot x, \frac{-0.5}{y \cdot y}, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \frac{1}{\frac{t_1}{t_2}}\\
\mathbf{if}\;x \leq -3.889732912922227 \cdot 10^{-141}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;x \leq 4.844477666462499 \cdot 10^{-218}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6.7124149431424 \cdot 10^{+28}:\\
\;\;\;\;t_4\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}\\
\end{array}\\
\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 -2.329334044066695e+153)
1.0
(let* ((t_0 (* y (* y 4.0))) (t_1 (+ (* x x) t_0)) (t_2 (- (* x x) t_0)))
(if (<= x -1.8134981297322904e-53)
(let* ((t_3 (/ t_2 t_1))) (cbrt (* t_3 (* t_3 t_3))))
(if (<= x -3.9297601949890104e-88)
(/ 1.0 (fma (* x x) (/ -0.5 (* y y)) -1.0))
(let* ((t_4 (/ 1.0 (/ t_1 t_2))))
(if (<= x -3.889732912922227e-141)
t_4
(if (<= x 4.844477666462499e-218)
-1.0
(if (<= x 6.7124149431424e+28) t_4 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 <= -2.329334044066695e+153) {
tmp = 1.0;
} else {
double t_0 = y * (y * 4.0);
double t_1 = (x * x) + t_0;
double t_2 = (x * x) - t_0;
double tmp_1;
if (x <= -1.8134981297322904e-53) {
double t_3_2 = t_2 / t_1;
tmp_1 = cbrt(t_3_2 * (t_3_2 * t_3_2));
} else if (x <= -3.9297601949890104e-88) {
tmp_1 = 1.0 / fma((x * x), (-0.5 / (y * y)), -1.0);
} else {
double t_4 = 1.0 / (t_1 / t_2);
double tmp_3;
if (x <= -3.889732912922227e-141) {
tmp_3 = t_4;
} else if (x <= 4.844477666462499e-218) {
tmp_3 = -1.0;
} else if (x <= 6.7124149431424e+28) {
tmp_3 = t_4;
} else {
tmp_3 = 1.0;
}
tmp_1 = tmp_3;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 13.7 |
if x < -2.3293340440666951e153 or 6.71241494314239984e28 < x Initial program 49.9
Taylor expanded in x around inf 12.7
if -2.3293340440666951e153 < x < -1.8134981297322904e-53Initial program 15.1
Applied add-cbrt-cube_binary6415.1
if -1.8134981297322904e-53 < x < -3.92976019498901042e-88Initial program 22.1
Applied clear-num_binary6422.1
Simplified22.1
Taylor expanded in x around 0 18.2
Simplified18.2
if -3.92976019498901042e-88 < x < -3.88973291292222692e-141 or 4.8444776664624986e-218 < x < 6.71241494314239984e28Initial program 19.2
Applied clear-num_binary6419.2
if -3.88973291292222692e-141 < x < 4.8444776664624986e-218Initial program 30.3
Taylor expanded in x around 0 7.6
Final simplification13.7
herbie shell --seed 2021357
(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))))