(FPCore (x y) :precision binary64 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (fma (pow (/ y x) 2.0) -8.0 1.0))
(t_2 (fma x x t_0))
(t_3 (- (/ x (/ t_2 x)) (/ y (/ t_2 (* y 4.0))))))
(if (<= t_0 0.0)
t_1
(if (<= t_0 4e-222)
(log (exp (/ (fma x x (* y (* y -4.0))) t_2)))
(if (<= t_0 1e-147)
t_1
(if (<= t_0 4e-48)
t_3
(if (<= t_0 1e+22)
(log E)
(if (<= t_0 2e+218)
t_3
(log
(fma
0.5
(* (* (/ x y) (/ x y)) (exp -1.0))
(exp -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 t_0 = y * (y * 4.0);
double t_1 = fma(pow((y / x), 2.0), -8.0, 1.0);
double t_2 = fma(x, x, t_0);
double t_3 = (x / (t_2 / x)) - (y / (t_2 / (y * 4.0)));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 4e-222) {
tmp = log(exp((fma(x, x, (y * (y * -4.0))) / t_2)));
} else if (t_0 <= 1e-147) {
tmp = t_1;
} else if (t_0 <= 4e-48) {
tmp = t_3;
} else if (t_0 <= 1e+22) {
tmp = log(((double) M_E));
} else if (t_0 <= 2e+218) {
tmp = t_3;
} else {
tmp = log(fma(0.5, (((x / y) * (x / y)) * exp(-1.0)), exp(-1.0)));
}
return tmp;
}
function code(x, y) return Float64(Float64(Float64(x * x) - Float64(Float64(y * 4.0) * y)) / Float64(Float64(x * x) + Float64(Float64(y * 4.0) * y))) end
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) t_1 = fma((Float64(y / x) ^ 2.0), -8.0, 1.0) t_2 = fma(x, x, t_0) t_3 = Float64(Float64(x / Float64(t_2 / x)) - Float64(y / Float64(t_2 / Float64(y * 4.0)))) tmp = 0.0 if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 4e-222) tmp = log(exp(Float64(fma(x, x, Float64(y * Float64(y * -4.0))) / t_2))); elseif (t_0 <= 1e-147) tmp = t_1; elseif (t_0 <= 4e-48) tmp = t_3; elseif (t_0 <= 1e+22) tmp = log(exp(1)); elseif (t_0 <= 2e+218) tmp = t_3; else tmp = log(fma(0.5, Float64(Float64(Float64(x / y) * Float64(x / y)) * exp(-1.0)), exp(-1.0))); end return tmp end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0 + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(x * x + t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x / N[(t$95$2 / x), $MachinePrecision]), $MachinePrecision] - N[(y / N[(t$95$2 / N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 4e-222], N[Log[N[Exp[N[(N[(x * x + N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 1e-147], t$95$1, If[LessEqual[t$95$0, 4e-48], t$95$3, If[LessEqual[t$95$0, 1e+22], N[Log[E], $MachinePrecision], If[LessEqual[t$95$0, 2e+218], t$95$3, N[Log[N[(0.5 * N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * N[Exp[-1.0], $MachinePrecision]), $MachinePrecision] + N[Exp[-1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]]]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \mathsf{fma}\left({\left(\frac{y}{x}\right)}^{2}, -8, 1\right)\\
t_2 := \mathsf{fma}\left(x, x, t_0\right)\\
t_3 := \frac{x}{\frac{t_2}{x}} - \frac{y}{\frac{t_2}{y \cdot 4}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{-222}:\\
\;\;\;\;\log \left(e^{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot -4\right)\right)}{t_2}}\right)\\
\mathbf{elif}\;t_0 \leq 10^{-147}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{-48}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_0 \leq 10^{+22}:\\
\;\;\;\;\log e\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+218}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(0.5, \left(\frac{x}{y} \cdot \frac{x}{y}\right) \cdot e^{-1}, e^{-1}\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 31.0 |
|---|---|
| Target | 30.7 |
| Herbie | 11.9 |
if (*.f64 (*.f64 y 4) y) < 0.0 or 4.00000000000000019e-222 < (*.f64 (*.f64 y 4) y) < 9.9999999999999997e-148Initial program 28.1
Applied egg-rr28.1
Taylor expanded in x around inf 15.8
Simplified10.0
Applied egg-rr9.5
if 0.0 < (*.f64 (*.f64 y 4) y) < 4.00000000000000019e-222Initial program 12.9
Applied egg-rr12.9
if 9.9999999999999997e-148 < (*.f64 (*.f64 y 4) y) < 3.9999999999999999e-48 or 1e22 < (*.f64 (*.f64 y 4) y) < 2.00000000000000017e218Initial program 15.3
Applied egg-rr14.9
if 3.9999999999999999e-48 < (*.f64 (*.f64 y 4) y) < 1e22Initial program 17.0
Applied egg-rr17.0
Taylor expanded in x around inf 31.7
Simplified31.7
if 2.00000000000000017e218 < (*.f64 (*.f64 y 4) y) Initial program 53.1
Applied egg-rr53.1
Taylor expanded in x around 0 15.0
Simplified8.2
Final simplification11.9
herbie shell --seed 2022170
(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))))