(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 y (* y -4.0) (* x x)) (fma x x (* y (* y 4.0))))))
(if (<= x -1.7380791032682012e+96)
1.0
(if (<= x -2.2617666078219922e+61)
(fma 0.5 (/ (* x x) (* y y)) -1.0)
(if (<= x -4.611780839164092e-70)
t_0
(if (<= x 2.961072780439151e-61)
-1.0
(if (<= x 6.846130813274231e+127) t_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 = fma(y, (y * -4.0), (x * x)) / fma(x, x, (y * (y * 4.0)));
double tmp;
if (x <= -1.7380791032682012e+96) {
tmp = 1.0;
} else if (x <= -2.2617666078219922e+61) {
tmp = fma(0.5, ((x * x) / (y * y)), -1.0);
} else if (x <= -4.611780839164092e-70) {
tmp = t_0;
} else if (x <= 2.961072780439151e-61) {
tmp = -1.0;
} else if (x <= 6.846130813274231e+127) {
tmp = t_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(fma(y, Float64(y * -4.0), Float64(x * x)) / fma(x, x, Float64(y * Float64(y * 4.0)))) tmp = 0.0 if (x <= -1.7380791032682012e+96) tmp = 1.0; elseif (x <= -2.2617666078219922e+61) tmp = fma(0.5, Float64(Float64(x * x) / Float64(y * y)), -1.0); elseif (x <= -4.611780839164092e-70) tmp = t_0; elseif (x <= 2.961072780439151e-61) tmp = -1.0; elseif (x <= 6.846130813274231e+127) tmp = t_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 * N[(y * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7380791032682012e+96], 1.0, If[LessEqual[x, -2.2617666078219922e+61], N[(0.5 * N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -4.611780839164092e-70], t$95$0, If[LessEqual[x, 2.961072780439151e-61], -1.0, If[LessEqual[x, 6.846130813274231e+127], t$95$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 := \frac{\mathsf{fma}\left(y, y \cdot -4, x \cdot x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\
\mathbf{if}\;x \leq -1.7380791032682012 \cdot 10^{+96}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.2617666078219922 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot x}{y \cdot y}, -1\right)\\
\mathbf{elif}\;x \leq -4.611780839164092 \cdot 10^{-70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.961072780439151 \cdot 10^{-61}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6.846130813274231 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 31.8 |
|---|---|
| Target | 31.5 |
| Herbie | 13.9 |
if x < -1.73807910326820117e96 or 6.8461308132742313e127 < x Initial program 54.2
Simplified54.2
Taylor expanded in y around 0 11.3
if -1.73807910326820117e96 < x < -2.26176660782199216e61Initial program 17.0
Simplified17.0
Taylor expanded in y around inf 40.0
Simplified40.0
if -2.26176660782199216e61 < x < -4.6117808391640921e-70 or 2.961072780439151e-61 < x < 6.8461308132742313e127Initial program 15.6
Simplified15.6
Taylor expanded in y around 0 15.6
Simplified15.6
if -4.6117808391640921e-70 < x < 2.961072780439151e-61Initial program 25.2
Simplified25.3
Taylor expanded in y around inf 13.1
Final simplification13.9
herbie shell --seed 2022134
(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))))