\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 -7.889294442251422 \cdot 10^{+82}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.0083469768504224 \cdot 10^{+35}:\\
\;\;\;\;-1 + 0.5 \cdot \frac{x \cdot x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x + t_0\\
t_2 := \sqrt{t_1}\\
\mathbf{if}\;x \leq -2.224894635750053 \cdot 10^{+19}:\\
\;\;\;\;\frac{-x}{t_2}\\
\mathbf{elif}\;x \leq -3.0650910469135724 \cdot 10^{-18}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := x \cdot x - t_0\\
\mathbf{if}\;x \leq -6.621764088875046 \cdot 10^{-123}:\\
\;\;\;\;\frac{t_3}{t_2 \cdot t_2}\\
\mathbf{elif}\;x \leq 1.6099882850021034 \cdot 10^{-142}:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt[3]{{\left(\frac{x}{y}\right)}^{2}}\\
-1 + 0.5 \cdot \left(t_4 \cdot \left(t_4 \cdot e^{\log t_4}\right)\right)
\end{array}\\
\mathbf{elif}\;x \leq 3.818174199742958 \cdot 10^{-25}:\\
\;\;\;\;\frac{t_3}{t_1}\\
\mathbf{elif}\;x \leq 7.583644193178865 \cdot 10^{-12}:\\
\;\;\;\;-1 + 0.5 \cdot e^{\left(\log x + \log x\right) - \log \left(y \cdot y\right)}\\
\mathbf{elif}\;x \leq 1.9416524250748645 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{\frac{t_1}{t_3}}\\
\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 -7.889294442251422e+82)
1.0
(if (<= x -1.0083469768504224e+35)
(+ -1.0 (* 0.5 (/ (* x x) (* y y))))
(let* ((t_0 (* y (* y 4.0))) (t_1 (+ (* x x) t_0)) (t_2 (sqrt t_1)))
(if (<= x -2.224894635750053e+19)
(/ (- x) t_2)
(if (<= x -3.0650910469135724e-18)
-1.0
(let* ((t_3 (- (* x x) t_0)))
(if (<= x -6.621764088875046e-123)
(/ t_3 (* t_2 t_2))
(if (<= x 1.6099882850021034e-142)
(let* ((t_4 (cbrt (pow (/ x y) 2.0))))
(+ -1.0 (* 0.5 (* t_4 (* t_4 (exp (log t_4)))))))
(if (<= x 3.818174199742958e-25)
(/ t_3 t_1)
(if (<= x 7.583644193178865e-12)
(+
-1.0
(* 0.5 (exp (- (+ (log x) (log x)) (log (* y y))))))
(if (<= x 1.9416524250748645e+139)
(/ 1.0 (/ t_1 t_3))
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 <= -7.889294442251422e+82) {
tmp = 1.0;
} else if (x <= -1.0083469768504224e+35) {
tmp = -1.0 + (0.5 * ((x * x) / (y * y)));
} else {
double t_0 = y * (y * 4.0);
double t_1 = (x * x) + t_0;
double t_2 = sqrt(t_1);
double tmp_1;
if (x <= -2.224894635750053e+19) {
tmp_1 = -x / t_2;
} else if (x <= -3.0650910469135724e-18) {
tmp_1 = -1.0;
} else {
double t_3 = (x * x) - t_0;
double tmp_2;
if (x <= -6.621764088875046e-123) {
tmp_2 = t_3 / (t_2 * t_2);
} else if (x <= 1.6099882850021034e-142) {
double t_4 = cbrt(pow((x / y), 2.0));
tmp_2 = -1.0 + (0.5 * (t_4 * (t_4 * exp(log(t_4)))));
} else if (x <= 3.818174199742958e-25) {
tmp_2 = t_3 / t_1;
} else if (x <= 7.583644193178865e-12) {
tmp_2 = -1.0 + (0.5 * exp((log(x) + log(x)) - log(y * y)));
} else if (x <= 1.9416524250748645e+139) {
tmp_2 = 1.0 / (t_1 / t_3);
} else {
tmp_2 = 1.0;
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 31.6 |
|---|---|
| Target | 31.3 |
| Herbie | 13.4 |
if x < -7.88929444225142226e82 or 1.94165242507486451e139 < x Initial program 54.2
Taylor expanded around inf 10.9
if -7.88929444225142226e82 < x < -1.00834697685042239e35Initial program 15.4
Taylor expanded around 0 37.9
Simplified37.9
if -1.00834697685042239e35 < x < -22248946357500530700Initial program 17.7
rmApplied add-sqr-sqrt_binary6417.7
Applied associate-/r*_binary6417.7
Simplified17.7
Taylor expanded around -inf 28.5
Simplified28.5
if -22248946357500530700 < x < -3.0650910469135724e-18Initial program 19.9
Taylor expanded around 0 28.3
if -3.0650910469135724e-18 < x < -6.6217640888750464e-123Initial program 16.1
rmApplied add-sqr-sqrt_binary6416.2
if -6.6217640888750464e-123 < x < 1.6099882850021034e-142Initial program 28.0
Taylor expanded around 0 15.4
Simplified15.4
rmApplied add-cube-cbrt_binary6415.4
Simplified15.4
Simplified8.2
rmApplied add-exp-log_binary648.2
if 1.6099882850021034e-142 < x < 3.8181741997429578e-25Initial program 14.2
if 3.8181741997429578e-25 < x < 7.58364419317886489e-12Initial program 21.8
Taylor expanded around 0 25.6
Simplified25.6
rmApplied add-exp-log_binary6425.6
Applied add-exp-log_binary6425.6
Applied add-exp-log_binary6425.6
Applied prod-exp_binary6425.6
Applied div-exp_binary6425.6
if 7.58364419317886489e-12 < x < 1.94165242507486451e139Initial program 15.4
rmApplied clear-num_binary6415.4
Final simplification13.4
herbie shell --seed 2021190
(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))))