(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
(log (exp (/ (fma x x (* y (* y -4.0))) (fma x x (* y (* y 4.0)))))))
(t_1 (* x (/ x y)))
(t_2 (/ t_1 (* y 2.0))))
(if (<= y -3.2e+160)
(fma (/ 0.5 y) t_1 -1.0)
(if (<= y -4e-19)
t_0
(if (<= y 2.15e-163)
(fma (/ y x) (* (/ y x) -8.0) 1.0)
(if (<= y 1e+71) t_0 (/ (+ -1.0 (* t_2 t_2)) (+ 1.0 t_2))))))))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 = log(exp((fma(x, x, (y * (y * -4.0))) / fma(x, x, (y * (y * 4.0))))));
double t_1 = x * (x / y);
double t_2 = t_1 / (y * 2.0);
double tmp;
if (y <= -3.2e+160) {
tmp = fma((0.5 / y), t_1, -1.0);
} else if (y <= -4e-19) {
tmp = t_0;
} else if (y <= 2.15e-163) {
tmp = fma((y / x), ((y / x) * -8.0), 1.0);
} else if (y <= 1e+71) {
tmp = t_0;
} else {
tmp = (-1.0 + (t_2 * t_2)) / (1.0 + t_2);
}
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 = log(exp(Float64(fma(x, x, Float64(y * Float64(y * -4.0))) / fma(x, x, Float64(y * Float64(y * 4.0)))))) t_1 = Float64(x * Float64(x / y)) t_2 = Float64(t_1 / Float64(y * 2.0)) tmp = 0.0 if (y <= -3.2e+160) tmp = fma(Float64(0.5 / y), t_1, -1.0); elseif (y <= -4e-19) tmp = t_0; elseif (y <= 2.15e-163) tmp = fma(Float64(y / x), Float64(Float64(y / x) * -8.0), 1.0); elseif (y <= 1e+71) tmp = t_0; else tmp = Float64(Float64(-1.0 + Float64(t_2 * t_2)) / Float64(1.0 + t_2)); 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[Log[N[Exp[N[(N[(x * x + N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.2e+160], N[(N[(0.5 / y), $MachinePrecision] * t$95$1 + -1.0), $MachinePrecision], If[LessEqual[y, -4e-19], t$95$0, If[LessEqual[y, 2.15e-163], N[(N[(y / x), $MachinePrecision] * N[(N[(y / x), $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[y, 1e+71], t$95$0, N[(N[(-1.0 + N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$2), $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 := \log \left(e^{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot -4\right)\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}\right)\\
t_1 := x \cdot \frac{x}{y}\\
t_2 := \frac{t_1}{y \cdot 2}\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.5}{y}, t_1, -1\right)\\
\mathbf{elif}\;y \leq -4 \cdot 10^{-19}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-163}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x}, \frac{y}{x} \cdot -8, 1\right)\\
\mathbf{elif}\;y \leq 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 + t_2 \cdot t_2}{1 + t_2}\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 32.0 |
|---|---|
| Target | 31.7 |
| Herbie | 13.1 |
if y < -3.1999999999999998e160Initial program 64.0
Taylor expanded in x around 0 16.2
Simplified16.2
Taylor expanded in x around 0 16.2
Simplified8.1
if -3.1999999999999998e160 < y < -3.9999999999999999e-19 or 2.15000000000000004e-163 < y < 1e71Initial program 16.6
Applied egg-rr16.6
if -3.9999999999999999e-19 < y < 2.15000000000000004e-163Initial program 26.3
Taylor expanded in x around inf 17.5
Simplified12.0
if 1e71 < y Initial program 48.3
Taylor expanded in x around 0 18.3
Simplified18.3
Applied egg-rr12.6
Final simplification13.1
herbie shell --seed 2022156
(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))))