(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 x x (* -4.0 (* y y))) (fma x x (* y (* y 4.0)))))
(t_1 (fma (pow (/ y x) 2.0) -8.0 1.0))
(t_2 (fma (/ 0.5 y) (/ (* x x) y) -1.0)))
(if (<= x -2.3e+86)
t_1
(if (<= x -5e-125)
t_0
(if (<= x 1.1e-110)
t_2
(if (<= x 2.9e-39)
t_0
(if (<= x 8e-14) t_2 (if (<= x 2.1e+69) t_0 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(x, x, (-4.0 * (y * y))) / fma(x, x, (y * (y * 4.0)));
double t_1 = fma(pow((y / x), 2.0), -8.0, 1.0);
double t_2 = fma((0.5 / y), ((x * x) / y), -1.0);
double tmp;
if (x <= -2.3e+86) {
tmp = t_1;
} else if (x <= -5e-125) {
tmp = t_0;
} else if (x <= 1.1e-110) {
tmp = t_2;
} else if (x <= 2.9e-39) {
tmp = t_0;
} else if (x <= 8e-14) {
tmp = t_2;
} else if (x <= 2.1e+69) {
tmp = t_0;
} 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 = Float64(fma(x, x, Float64(-4.0 * Float64(y * y))) / fma(x, x, Float64(y * Float64(y * 4.0)))) t_1 = fma((Float64(y / x) ^ 2.0), -8.0, 1.0) t_2 = fma(Float64(0.5 / y), Float64(Float64(x * x) / y), -1.0) tmp = 0.0 if (x <= -2.3e+86) tmp = t_1; elseif (x <= -5e-125) tmp = t_0; elseif (x <= 1.1e-110) tmp = t_2; elseif (x <= 2.9e-39) tmp = t_0; elseif (x <= 8e-14) tmp = t_2; elseif (x <= 2.1e+69) tmp = t_0; 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[(x * x + N[(-4.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $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[(N[(0.5 / y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -2.3e+86], t$95$1, If[LessEqual[x, -5e-125], t$95$0, If[LessEqual[x, 1.1e-110], t$95$2, If[LessEqual[x, 2.9e-39], t$95$0, If[LessEqual[x, 8e-14], t$95$2, If[LessEqual[x, 2.1e+69], t$95$0, 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 := \frac{\mathsf{fma}\left(x, x, -4 \cdot \left(y \cdot y\right)\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\
t_1 := \mathsf{fma}\left({\left(\frac{y}{x}\right)}^{2}, -8, 1\right)\\
t_2 := \mathsf{fma}\left(\frac{0.5}{y}, \frac{x \cdot x}{y}, -1\right)\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{+86}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-110}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-14}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 31.9 |
|---|---|
| Target | 31.6 |
| Herbie | 13.0 |
if x < -2.2999999999999999e86 or 2.10000000000000015e69 < x Initial program 48.7
Simplified48.7
Taylor expanded in x around inf 18.1
Simplified11.9
Applied egg-rr12.2
Applied egg-rr12.4
Taylor expanded in y around 0 18.1
Simplified11.9
if -2.2999999999999999e86 < x < -4.99999999999999967e-125 or 1.1e-110 < x < 2.89999999999999988e-39 or 7.99999999999999999e-14 < x < 2.10000000000000015e69Initial program 16.3
Simplified16.3
if -4.99999999999999967e-125 < x < 1.1e-110 or 2.89999999999999988e-39 < x < 7.99999999999999999e-14Initial program 26.9
Simplified27.1
Taylor expanded in x around 0 16.2
Simplified11.2
Final simplification13.0
herbie shell --seed 2022160
(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))))