(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 (pow (/ y x) 2.0)))
(if (<= y -2.7e+180)
-1.0
(if (<= y -6e+110)
(pow (cbrt (+ 1.0 (* t_1 -8.0))) 3.0)
(if (<= y -1e-22)
t_0
(if (<= y -1.5e-23)
(cbrt (pow (+ 1.0 (* -8.0 (log (exp t_1)))) 3.0))
(if (<= y -1.45e-85)
t_0
(if (<= y 2.05e-159)
(fma t_1 -8.0 1.0)
(if (<= y 1.12e+123) 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(x, x, (-4.0 * (y * y))) / fma(x, x, (y * (y * 4.0)));
double t_1 = pow((y / x), 2.0);
double tmp;
if (y <= -2.7e+180) {
tmp = -1.0;
} else if (y <= -6e+110) {
tmp = pow(cbrt((1.0 + (t_1 * -8.0))), 3.0);
} else if (y <= -1e-22) {
tmp = t_0;
} else if (y <= -1.5e-23) {
tmp = cbrt(pow((1.0 + (-8.0 * log(exp(t_1)))), 3.0));
} else if (y <= -1.45e-85) {
tmp = t_0;
} else if (y <= 2.05e-159) {
tmp = fma(t_1, -8.0, 1.0);
} else if (y <= 1.12e+123) {
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(x, x, Float64(-4.0 * Float64(y * y))) / fma(x, x, Float64(y * Float64(y * 4.0)))) t_1 = Float64(y / x) ^ 2.0 tmp = 0.0 if (y <= -2.7e+180) tmp = -1.0; elseif (y <= -6e+110) tmp = cbrt(Float64(1.0 + Float64(t_1 * -8.0))) ^ 3.0; elseif (y <= -1e-22) tmp = t_0; elseif (y <= -1.5e-23) tmp = cbrt((Float64(1.0 + Float64(-8.0 * log(exp(t_1)))) ^ 3.0)); elseif (y <= -1.45e-85) tmp = t_0; elseif (y <= 2.05e-159) tmp = fma(t_1, -8.0, 1.0); elseif (y <= 1.12e+123) 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[(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[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[y, -2.7e+180], -1.0, If[LessEqual[y, -6e+110], N[Power[N[Power[N[(1.0 + N[(t$95$1 * -8.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[y, -1e-22], t$95$0, If[LessEqual[y, -1.5e-23], N[Power[N[Power[N[(1.0 + N[(-8.0 * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[y, -1.45e-85], t$95$0, If[LessEqual[y, 2.05e-159], N[(t$95$1 * -8.0 + 1.0), $MachinePrecision], If[LessEqual[y, 1.12e+123], 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(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 := {\left(\frac{y}{x}\right)}^{2}\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{+180}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -6 \cdot 10^{+110}:\\
\;\;\;\;{\left(\sqrt[3]{1 + t_1 \cdot -8}\right)}^{3}\\
\mathbf{elif}\;y \leq -1 \cdot 10^{-22}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-23}:\\
\;\;\;\;\sqrt[3]{{\left(1 + -8 \cdot \log \left(e^{t_1}\right)\right)}^{3}}\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-85}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-159}:\\
\;\;\;\;\mathsf{fma}\left(t_1, -8, 1\right)\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+123}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 31.5 |
|---|---|
| Target | 31.2 |
| Herbie | 13.8 |
if y < -2.70000000000000016e180 or 1.12e123 < y Initial program 59.7
Taylor expanded in x around 0 8.8
if -2.70000000000000016e180 < y < -6.00000000000000014e110Initial program 34.9
Taylor expanded in x around inf 52.6
Simplified46.3
Applied egg-rr46.4
if -6.00000000000000014e110 < y < -1e-22 or -1.50000000000000001e-23 < y < -1.4500000000000001e-85 or 2.05000000000000007e-159 < y < 1.12e123Initial program 15.0
Simplified15.1
if -1e-22 < y < -1.50000000000000001e-23Initial program 11.6
Taylor expanded in x around inf 16.7
Simplified16.7
Applied egg-rr17.0
Applied egg-rr17.5
if -1.4500000000000001e-85 < y < 2.05000000000000007e-159Initial program 28.1
Taylor expanded in x around inf 16.5
Simplified10.0
Applied egg-rr10.2
Applied egg-rr10.0
Final simplification13.8
herbie shell --seed 2022165
(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))))