(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 -1.0371372005582628e+70)
-1.0
(if (<= y -2.029692625314952e-98)
(- (/ (* x x) t_1) (/ t_0 t_1))
(if (<= y 4.1575865434538223e-162)
1.0
(if (<= y 7.048940344096351e+96)
(/ 1.0 (/ t_1 (fma x x (* (* y y) -4.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 <= -1.0371372005582628e+70) {
tmp = -1.0;
} else if (y <= -2.029692625314952e-98) {
tmp = ((x * x) / t_1) - (t_0 / t_1);
} else if (y <= 4.1575865434538223e-162) {
tmp = 1.0;
} else if (y <= 7.048940344096351e+96) {
tmp = 1.0 / (t_1 / fma(x, x, ((y * y) * -4.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 <= -1.0371372005582628e+70) tmp = -1.0; elseif (y <= -2.029692625314952e-98) tmp = Float64(Float64(Float64(x * x) / t_1) - Float64(t_0 / t_1)); elseif (y <= 4.1575865434538223e-162) tmp = 1.0; elseif (y <= 7.048940344096351e+96) tmp = Float64(1.0 / Float64(t_1 / fma(x, x, Float64(Float64(y * y) * -4.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, -1.0371372005582628e+70], -1.0, If[LessEqual[y, -2.029692625314952e-98], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1575865434538223e-162], 1.0, If[LessEqual[y, 7.048940344096351e+96], N[(1.0 / N[(t$95$1 / N[(x * x + N[(N[(y * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -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 -1.0371372005582628 \cdot 10^{+70}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.029692625314952 \cdot 10^{-98}:\\
\;\;\;\;\frac{x \cdot x}{t_1} - \frac{t_0}{t_1}\\
\mathbf{elif}\;y \leq 4.1575865434538223 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.048940344096351 \cdot 10^{+96}:\\
\;\;\;\;\frac{1}{\frac{t_1}{\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 32.0 |
|---|---|
| Target | 31.7 |
| Herbie | 13.0 |
if y < -1.0371372005582628e70 or 7.04894034409635117e96 < y Initial program 49.5
Taylor expanded in x around 0 11.8
if -1.0371372005582628e70 < y < -2.029692625314952e-98Initial program 17.0
Applied div-sub_binary6417.0
Simplified17.0
Simplified17.0
if -2.029692625314952e-98 < y < 4.1575865434538223e-162Initial program 28.4
Taylor expanded in x around inf 9.9
if 4.1575865434538223e-162 < y < 7.04894034409635117e96Initial program 16.8
Applied clear-num_binary6416.8
Simplified16.8
Final simplification13.0
herbie shell --seed 2022131
(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))))