(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 x x t_0)))
(if (<= y -2.90709829270765e+109)
-1.0
(if (<= y -3.738119627219816e-161)
(- (/ (* x x) t_1) (/ t_0 t_1))
(if (<= y 3.0001361978417216e-145)
1.0
(if (<= y 174160338219.57495)
(/ (+ (* x x) (* y (* y -4.0))) (+ (* x x) (* y (* y 4.0))))
(if (<= y 4.8959736638846305e+33) 1.0 -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(x, x, t_0);
double tmp;
if (y <= -2.90709829270765e+109) {
tmp = -1.0;
} else if (y <= -3.738119627219816e-161) {
tmp = ((x * x) / t_1) - (t_0 / t_1);
} else if (y <= 3.0001361978417216e-145) {
tmp = 1.0;
} else if (y <= 174160338219.57495) {
tmp = ((x * x) + (y * (y * -4.0))) / ((x * x) + (y * (y * 4.0)));
} else if (y <= 4.8959736638846305e+33) {
tmp = 1.0;
} else {
tmp = -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(Float64(y * y) * 4.0) t_1 = fma(x, x, t_0) tmp = 0.0 if (y <= -2.90709829270765e+109) tmp = -1.0; elseif (y <= -3.738119627219816e-161) tmp = Float64(Float64(Float64(x * x) / t_1) - Float64(t_0 / t_1)); elseif (y <= 3.0001361978417216e-145) tmp = 1.0; elseif (y <= 174160338219.57495) tmp = Float64(Float64(Float64(x * x) + Float64(y * Float64(y * -4.0))) / Float64(Float64(x * x) + Float64(y * Float64(y * 4.0)))); elseif (y <= 4.8959736638846305e+33) tmp = 1.0; else tmp = -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[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(x * x + t$95$0), $MachinePrecision]}, If[LessEqual[y, -2.90709829270765e+109], -1.0, If[LessEqual[y, -3.738119627219816e-161], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.0001361978417216e-145], 1.0, If[LessEqual[y, 174160338219.57495], N[(N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8959736638846305e+33], 1.0, -1.0]]]]]]]
\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 := \left(y \cdot y\right) \cdot 4\\
t_1 := \mathsf{fma}\left(x, x, t_0\right)\\
\mathbf{if}\;y \leq -2.90709829270765 \cdot 10^{+109}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.738119627219816 \cdot 10^{-161}:\\
\;\;\;\;\frac{x \cdot x}{t_1} - \frac{t_0}{t_1}\\
\mathbf{elif}\;y \leq 3.0001361978417216 \cdot 10^{-145}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 174160338219.57495:\\
\;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\
\mathbf{elif}\;y \leq 4.8959736638846305 \cdot 10^{+33}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 32.0 |
|---|---|
| Target | 31.7 |
| Herbie | 13.2 |
if y < -2.9070982927076501e109 or 4.8959736638846305e33 < y Initial program 47.4
Taylor expanded in x around 0 12.8
if -2.9070982927076501e109 < y < -3.73811962721981598e-161Initial program 15.8
Applied div-sub_binary6415.8
Simplified15.8
Simplified15.8
if -3.73811962721981598e-161 < y < 3.00013619784172163e-145 or 174160338219.57495 < y < 4.8959736638846305e33Initial program 28.9
Taylor expanded in x around inf 9.9
if 3.00013619784172163e-145 < y < 174160338219.57495Initial program 16.8
Applied cancel-sign-sub-inv_binary6416.8
Final simplification13.2
herbie shell --seed 2022137
(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))))