(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 (/ 0.5 y) (* x (/ x y)) -1.0)))
(if (<= x -5e+162)
1.0
(if (<= x -2.4e+115)
(pow (cbrt t_0) 3.0)
(if (<= x -3e-83)
(/ (fma x x (* -4.0 (* y y))) (fma x x (* y (* y 4.0))))
(if (<= x 3.1e-94) 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((0.5 / y), (x * (x / y)), -1.0);
double tmp;
if (x <= -5e+162) {
tmp = 1.0;
} else if (x <= -2.4e+115) {
tmp = pow(cbrt(t_0), 3.0);
} else if (x <= -3e-83) {
tmp = fma(x, x, (-4.0 * (y * y))) / fma(x, x, (y * (y * 4.0)));
} else if (x <= 3.1e-94) {
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 = fma(Float64(0.5 / y), Float64(x * Float64(x / y)), -1.0) tmp = 0.0 if (x <= -5e+162) tmp = 1.0; elseif (x <= -2.4e+115) tmp = cbrt(t_0) ^ 3.0; elseif (x <= -3e-83) tmp = Float64(fma(x, x, Float64(-4.0 * Float64(y * y))) / fma(x, x, Float64(y * Float64(y * 4.0)))); elseif (x <= 3.1e-94) 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[(0.5 / y), $MachinePrecision] * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -5e+162], 1.0, If[LessEqual[x, -2.4e+115], N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[x, -3e-83], 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], If[LessEqual[x, 3.1e-94], 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 := \mathsf{fma}\left(\frac{0.5}{y}, x \cdot \frac{x}{y}, -1\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{+162}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{+115}:\\
\;\;\;\;{\left(\sqrt[3]{t_0}\right)}^{3}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-83}:\\
\;\;\;\;\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)}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-94}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 32.1 |
|---|---|
| Target | 31.8 |
| Herbie | 15.8 |
if x < -4.9999999999999997e162 or 3.0999999999999998e-94 < x Initial program 42.6
Taylor expanded in x around inf 17.6
if -4.9999999999999997e162 < x < -2.4e115Initial program 26.7
Taylor expanded in x around 0 49.2
Simplified49.2
Applied egg-rr46.0
if -2.4e115 < x < -3.0000000000000001e-83Initial program 15.4
Simplified15.4
if -3.0000000000000001e-83 < x < 3.0999999999999998e-94Initial program 26.9
Taylor expanded in x around 0 16.5
Simplified11.0
Taylor expanded in x around 0 11.0
Simplified10.6
Final simplification15.8
herbie shell --seed 2022162
(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))))