(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 (fma (/ 0.5 y) (/ (* x x) y) -1.0))
(t_1 (+ (* (pow (/ y x) 2.0) -8.0) 1.0))
(t_2 (/ (fma (* y -4.0) y (* x x)) (+ (* x x) (* y (* y 4.0))))))
(if (<= x -1.6e+90)
t_1
(if (<= x -3.9e+77)
t_0
(if (<= x -4.3e+18)
1.0
(if (<= x -1.48e-100)
t_2
(if (<= x 1.45e-48) t_0 (if (<= x 1.7e+139) t_2 t_1))))))))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 = fma((0.5 / y), ((x * x) / y), -1.0);
double t_1 = (pow((y / x), 2.0) * -8.0) + 1.0;
double t_2 = fma((y * -4.0), y, (x * x)) / ((x * x) + (y * (y * 4.0)));
double tmp;
if (x <= -1.6e+90) {
tmp = t_1;
} else if (x <= -3.9e+77) {
tmp = t_0;
} else if (x <= -4.3e+18) {
tmp = 1.0;
} else if (x <= -1.48e-100) {
tmp = t_2;
} else if (x <= 1.45e-48) {
tmp = t_0;
} else if (x <= 1.7e+139) {
tmp = t_2;
} else {
tmp = t_1;
}
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 = fma(Float64(0.5 / y), Float64(Float64(x * x) / y), -1.0) t_1 = Float64(Float64((Float64(y / x) ^ 2.0) * -8.0) + 1.0) t_2 = Float64(fma(Float64(y * -4.0), y, Float64(x * x)) / Float64(Float64(x * x) + Float64(y * Float64(y * 4.0)))) tmp = 0.0 if (x <= -1.6e+90) tmp = t_1; elseif (x <= -3.9e+77) tmp = t_0; elseif (x <= -4.3e+18) tmp = 1.0; elseif (x <= -1.48e-100) tmp = t_2; elseif (x <= 1.45e-48) tmp = t_0; elseif (x <= 1.7e+139) tmp = t_2; else tmp = t_1; 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[(N[(0.5 / y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y * -4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.6e+90], t$95$1, If[LessEqual[x, -3.9e+77], t$95$0, If[LessEqual[x, -4.3e+18], 1.0, If[LessEqual[x, -1.48e-100], t$95$2, If[LessEqual[x, 1.45e-48], t$95$0, If[LessEqual[x, 1.7e+139], t$95$2, t$95$1]]]]]]]]]
\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 := \mathsf{fma}\left(\frac{0.5}{y}, \frac{x \cdot x}{y}, -1\right)\\
t_1 := {\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\
t_2 := \frac{\mathsf{fma}\left(y \cdot -4, y, x \cdot x\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{+90}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.9 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.3 \cdot 10^{+18}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.48 \cdot 10^{-100}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-48}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+139}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 13.0 |
if x < -1.59999999999999999e90 or 1.7000000000000001e139 < x Initial program 54.7
Taylor expanded in x around inf 15.8
Simplified9.4
Applied egg-rr9.4
if -1.59999999999999999e90 < x < -3.8999999999999998e77 or -1.48000000000000002e-100 < x < 1.4500000000000001e-48Initial program 25.4
Taylor expanded in x around 0 17.4
Simplified12.6
if -3.8999999999999998e77 < x < -4.3e18Initial program 14.6
Taylor expanded in x around inf 24.6
if -4.3e18 < x < -1.48000000000000002e-100 or 1.4500000000000001e-48 < x < 1.7000000000000001e139Initial program 16.2
Applied egg-rr16.2
Final simplification13.0
herbie shell --seed 2022166
(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))))