
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
\end{array}
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (let* ((t_0 (hypot x (* y_m 2.0)))) (/ (/ (fma y_m -2.0 x) t_0) (/ t_0 (+ x (* y_m 2.0))))))
y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = hypot(x, (y_m * 2.0));
return (fma(y_m, -2.0, x) / t_0) / (t_0 / (x + (y_m * 2.0)));
}
y_m = abs(y) function code(x, y_m) t_0 = hypot(x, Float64(y_m * 2.0)) return Float64(Float64(fma(y_m, -2.0, x) / t_0) / Float64(t_0 / Float64(x + Float64(y_m * 2.0)))) end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y$95$m * -2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 / N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y\_m \cdot 2\right)\\
\frac{\frac{\mathsf{fma}\left(y\_m, -2, x\right)}{t\_0}}{\frac{t\_0}{x + y\_m \cdot 2}}
\end{array}
\end{array}
Initial program 51.2%
add-sqr-sqrt51.2%
difference-of-squares51.2%
*-commutative51.2%
associate-*r*51.2%
sqrt-prod51.2%
sqrt-unprod28.0%
add-sqr-sqrt39.1%
metadata-eval39.1%
*-commutative39.1%
associate-*r*39.1%
sqrt-prod39.1%
sqrt-unprod28.0%
add-sqr-sqrt51.2%
metadata-eval51.2%
Applied egg-rr51.2%
add-sqr-sqrt51.2%
times-frac52.7%
+-commutative52.7%
fma-define52.7%
+-commutative52.7%
add-sqr-sqrt52.7%
hypot-define52.7%
*-commutative52.7%
sqrt-prod28.6%
sqrt-prod28.6%
metadata-eval28.6%
associate-*l*28.6%
add-sqr-sqrt52.7%
Applied egg-rr99.9%
*-commutative99.9%
clear-num100.0%
un-div-inv100.0%
add-sqr-sqrt99.2%
add-sqr-sqrt100.0%
hypot-undefine52.7%
+-commutative52.7%
hypot-define100.0%
hypot-undefine52.7%
+-commutative52.7%
hypot-define100.0%
Applied egg-rr100.0%
fma-undefine100.0%
Applied egg-rr100.0%
Final simplification100.0%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (let* ((t_0 (hypot (* y_m 2.0) x))) (* (/ (+ x (* y_m 2.0)) t_0) (/ (+ x (* y_m -2.0)) t_0))))
y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = hypot((y_m * 2.0), x);
return ((x + (y_m * 2.0)) / t_0) * ((x + (y_m * -2.0)) / t_0);
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = Math.hypot((y_m * 2.0), x);
return ((x + (y_m * 2.0)) / t_0) * ((x + (y_m * -2.0)) / t_0);
}
y_m = math.fabs(y) def code(x, y_m): t_0 = math.hypot((y_m * 2.0), x) return ((x + (y_m * 2.0)) / t_0) * ((x + (y_m * -2.0)) / t_0)
y_m = abs(y) function code(x, y_m) t_0 = hypot(Float64(y_m * 2.0), x) return Float64(Float64(Float64(x + Float64(y_m * 2.0)) / t_0) * Float64(Float64(x + Float64(y_m * -2.0)) / t_0)) end
y_m = abs(y); function tmp = code(x, y_m) t_0 = hypot((y_m * 2.0), x); tmp = ((x + (y_m * 2.0)) / t_0) * ((x + (y_m * -2.0)) / t_0); end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[Sqrt[N[(y$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, N[(N[(N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y\_m \cdot 2, x\right)\\
\frac{x + y\_m \cdot 2}{t\_0} \cdot \frac{x + y\_m \cdot -2}{t\_0}
\end{array}
\end{array}
Initial program 51.2%
add-sqr-sqrt51.2%
difference-of-squares51.2%
*-commutative51.2%
associate-*r*51.2%
sqrt-prod51.2%
sqrt-unprod28.0%
add-sqr-sqrt39.1%
metadata-eval39.1%
*-commutative39.1%
associate-*r*39.1%
sqrt-prod39.1%
sqrt-unprod28.0%
add-sqr-sqrt51.2%
metadata-eval51.2%
Applied egg-rr51.2%
add-sqr-sqrt51.2%
times-frac52.7%
+-commutative52.7%
fma-define52.7%
+-commutative52.7%
add-sqr-sqrt52.7%
hypot-define52.7%
*-commutative52.7%
sqrt-prod28.6%
sqrt-prod28.6%
metadata-eval28.6%
associate-*l*28.6%
add-sqr-sqrt52.7%
Applied egg-rr99.9%
fma-undefine100.0%
Applied egg-rr99.9%
fma-undefine99.9%
Applied egg-rr99.9%
Final simplification99.9%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0)))
(t_1 (+ x (* y_m 2.0)))
(t_2 (hypot (* y_m 2.0) x)))
(if (<= t_0 5e-157)
(* (/ t_1 t_2) (+ 1.0 (* -2.0 (/ y_m x))))
(if (<= t_0 1e+270)
(/ (* t_1 (- x (* y_m 2.0))) (+ t_0 (* x x)))
(* (/ (+ x (* y_m -2.0)) t_2) (+ 1.0 (* 0.5 (/ x y_m))))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = x + (y_m * 2.0);
double t_2 = hypot((y_m * 2.0), x);
double tmp;
if (t_0 <= 5e-157) {
tmp = (t_1 / t_2) * (1.0 + (-2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = (t_1 * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = ((x + (y_m * -2.0)) / t_2) * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = x + (y_m * 2.0);
double t_2 = Math.hypot((y_m * 2.0), x);
double tmp;
if (t_0 <= 5e-157) {
tmp = (t_1 / t_2) * (1.0 + (-2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = (t_1 * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = ((x + (y_m * -2.0)) / t_2) * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = x + (y_m * 2.0) t_2 = math.hypot((y_m * 2.0), x) tmp = 0 if t_0 <= 5e-157: tmp = (t_1 / t_2) * (1.0 + (-2.0 * (y_m / x))) elif t_0 <= 1e+270: tmp = (t_1 * (x - (y_m * 2.0))) / (t_0 + (x * x)) else: tmp = ((x + (y_m * -2.0)) / t_2) * (1.0 + (0.5 * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(x + Float64(y_m * 2.0)) t_2 = hypot(Float64(y_m * 2.0), x) tmp = 0.0 if (t_0 <= 5e-157) tmp = Float64(Float64(t_1 / t_2) * Float64(1.0 + Float64(-2.0 * Float64(y_m / x)))); elseif (t_0 <= 1e+270) tmp = Float64(Float64(t_1 * Float64(x - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(Float64(x + Float64(y_m * -2.0)) / t_2) * Float64(1.0 + Float64(0.5 * Float64(x / y_m)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); t_1 = x + (y_m * 2.0); t_2 = hypot((y_m * 2.0), x); tmp = 0.0; if (t_0 <= 5e-157) tmp = (t_1 / t_2) * (1.0 + (-2.0 * (y_m / x))); elseif (t_0 <= 1e+270) tmp = (t_1 * (x - (y_m * 2.0))) / (t_0 + (x * x)); else tmp = ((x + (y_m * -2.0)) / t_2) * (1.0 + (0.5 * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(y$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]}, If[LessEqual[t$95$0, 5e-157], N[(N[(t$95$1 / t$95$2), $MachinePrecision] * N[(1.0 + N[(-2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+270], N[(N[(t$95$1 * N[(x - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] * N[(1.0 + N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := x + y\_m \cdot 2\\
t_2 := \mathsf{hypot}\left(y\_m \cdot 2, x\right)\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-157}:\\
\;\;\;\;\frac{t\_1}{t\_2} \cdot \left(1 + -2 \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+270}:\\
\;\;\;\;\frac{t\_1 \cdot \left(x - y\_m \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y\_m \cdot -2}{t\_2} \cdot \left(1 + 0.5 \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 5.0000000000000002e-157Initial program 53.9%
add-sqr-sqrt53.9%
difference-of-squares53.9%
*-commutative53.9%
associate-*r*53.9%
sqrt-prod53.9%
sqrt-unprod28.1%
add-sqr-sqrt49.5%
metadata-eval49.5%
*-commutative49.5%
associate-*r*49.5%
sqrt-prod49.5%
sqrt-unprod28.1%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
add-sqr-sqrt53.9%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
+-commutative55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
*-commutative55.4%
sqrt-prod28.8%
sqrt-prod28.8%
metadata-eval28.8%
associate-*l*28.8%
add-sqr-sqrt55.4%
Applied egg-rr99.9%
fma-undefine100.0%
Applied egg-rr99.9%
Taylor expanded in y around 0 48.3%
if 5.0000000000000002e-157 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1e270Initial program 80.0%
add-sqr-sqrt80.0%
difference-of-squares80.0%
*-commutative80.0%
associate-*r*80.0%
sqrt-prod80.0%
sqrt-unprod44.6%
add-sqr-sqrt54.2%
metadata-eval54.2%
*-commutative54.2%
associate-*r*54.2%
sqrt-prod54.2%
sqrt-unprod44.7%
add-sqr-sqrt80.0%
metadata-eval80.0%
Applied egg-rr80.0%
if 1e270 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 4.5%
add-sqr-sqrt4.5%
difference-of-squares4.5%
*-commutative4.5%
associate-*r*4.5%
sqrt-prod4.5%
sqrt-unprod2.9%
add-sqr-sqrt3.0%
metadata-eval3.0%
*-commutative3.0%
associate-*r*3.0%
sqrt-prod3.0%
sqrt-unprod2.9%
add-sqr-sqrt4.5%
metadata-eval4.5%
Applied egg-rr4.5%
add-sqr-sqrt4.5%
times-frac7.4%
+-commutative7.4%
fma-define7.4%
+-commutative7.4%
add-sqr-sqrt7.4%
hypot-define7.4%
*-commutative7.4%
sqrt-prod4.3%
sqrt-prod4.3%
metadata-eval4.3%
associate-*l*4.3%
add-sqr-sqrt7.4%
Applied egg-rr99.9%
Taylor expanded in y around inf 36.4%
fma-undefine99.9%
Applied egg-rr36.4%
Final simplification57.5%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0)))
(t_1 (/ (+ x (* y_m -2.0)) (hypot (* y_m 2.0) x))))
(if (<= t_0 5e-157)
(* t_1 (+ 1.0 (* 2.0 (/ y_m x))))
(if (<= t_0 1e+270)
(/ (* (+ x (* y_m 2.0)) (- x (* y_m 2.0))) (+ t_0 (* x x)))
(* t_1 (+ 1.0 (* 0.5 (/ x y_m))))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = (x + (y_m * -2.0)) / hypot((y_m * 2.0), x);
double tmp;
if (t_0 <= 5e-157) {
tmp = t_1 * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = t_1 * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = (x + (y_m * -2.0)) / Math.hypot((y_m * 2.0), x);
double tmp;
if (t_0 <= 5e-157) {
tmp = t_1 * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = t_1 * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = (x + (y_m * -2.0)) / math.hypot((y_m * 2.0), x) tmp = 0 if t_0 <= 5e-157: tmp = t_1 * (1.0 + (2.0 * (y_m / x))) elif t_0 <= 1e+270: tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)) else: tmp = t_1 * (1.0 + (0.5 * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(Float64(x + Float64(y_m * -2.0)) / hypot(Float64(y_m * 2.0), x)) tmp = 0.0 if (t_0 <= 5e-157) tmp = Float64(t_1 * Float64(1.0 + Float64(2.0 * Float64(y_m / x)))); elseif (t_0 <= 1e+270) tmp = Float64(Float64(Float64(x + Float64(y_m * 2.0)) * Float64(x - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(t_1 * Float64(1.0 + Float64(0.5 * Float64(x / y_m)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); t_1 = (x + (y_m * -2.0)) / hypot((y_m * 2.0), x); tmp = 0.0; if (t_0 <= 5e-157) tmp = t_1 * (1.0 + (2.0 * (y_m / x))); elseif (t_0 <= 1e+270) tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)); else tmp = t_1 * (1.0 + (0.5 * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(y$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-157], N[(t$95$1 * N[(1.0 + N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+270], N[(N[(N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 + N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := \frac{x + y\_m \cdot -2}{\mathsf{hypot}\left(y\_m \cdot 2, x\right)}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-157}:\\
\;\;\;\;t\_1 \cdot \left(1 + 2 \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+270}:\\
\;\;\;\;\frac{\left(x + y\_m \cdot 2\right) \cdot \left(x - y\_m \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 + 0.5 \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 5.0000000000000002e-157Initial program 53.9%
add-sqr-sqrt53.9%
difference-of-squares53.9%
*-commutative53.9%
associate-*r*53.9%
sqrt-prod53.9%
sqrt-unprod28.1%
add-sqr-sqrt49.5%
metadata-eval49.5%
*-commutative49.5%
associate-*r*49.5%
sqrt-prod49.5%
sqrt-unprod28.1%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
add-sqr-sqrt53.9%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
+-commutative55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
*-commutative55.4%
sqrt-prod28.8%
sqrt-prod28.8%
metadata-eval28.8%
associate-*l*28.8%
add-sqr-sqrt55.4%
Applied egg-rr99.9%
Taylor expanded in y around 0 48.3%
fma-undefine99.9%
Applied egg-rr48.3%
if 5.0000000000000002e-157 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1e270Initial program 80.0%
add-sqr-sqrt80.0%
difference-of-squares80.0%
*-commutative80.0%
associate-*r*80.0%
sqrt-prod80.0%
sqrt-unprod44.6%
add-sqr-sqrt54.2%
metadata-eval54.2%
*-commutative54.2%
associate-*r*54.2%
sqrt-prod54.2%
sqrt-unprod44.7%
add-sqr-sqrt80.0%
metadata-eval80.0%
Applied egg-rr80.0%
if 1e270 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 4.5%
add-sqr-sqrt4.5%
difference-of-squares4.5%
*-commutative4.5%
associate-*r*4.5%
sqrt-prod4.5%
sqrt-unprod2.9%
add-sqr-sqrt3.0%
metadata-eval3.0%
*-commutative3.0%
associate-*r*3.0%
sqrt-prod3.0%
sqrt-unprod2.9%
add-sqr-sqrt4.5%
metadata-eval4.5%
Applied egg-rr4.5%
add-sqr-sqrt4.5%
times-frac7.4%
+-commutative7.4%
fma-define7.4%
+-commutative7.4%
add-sqr-sqrt7.4%
hypot-define7.4%
*-commutative7.4%
sqrt-prod4.3%
sqrt-prod4.3%
metadata-eval4.3%
associate-*l*4.3%
add-sqr-sqrt7.4%
Applied egg-rr99.9%
Taylor expanded in y around inf 36.4%
fma-undefine99.9%
Applied egg-rr36.4%
Final simplification57.6%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))))
(if (<= t_0 5e-157)
(* (+ 1.0 (* -2.0 (/ y_m x))) (+ 1.0 (* 2.0 (/ y_m x))))
(if (<= t_0 1e+270)
(/ (* (+ x (* y_m 2.0)) (- x (* y_m 2.0))) (+ t_0 (* x x)))
(*
(/ (+ x (* y_m -2.0)) (hypot (* y_m 2.0) x))
(+ 1.0 (* 0.5 (/ x y_m))))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = ((x + (y_m * -2.0)) / hypot((y_m * 2.0), x)) * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 1e+270) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = ((x + (y_m * -2.0)) / Math.hypot((y_m * 2.0), x)) * (1.0 + (0.5 * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) tmp = 0 if t_0 <= 5e-157: tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))) elif t_0 <= 1e+270: tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)) else: tmp = ((x + (y_m * -2.0)) / math.hypot((y_m * 2.0), x)) * (1.0 + (0.5 * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) tmp = 0.0 if (t_0 <= 5e-157) tmp = Float64(Float64(1.0 + Float64(-2.0 * Float64(y_m / x))) * Float64(1.0 + Float64(2.0 * Float64(y_m / x)))); elseif (t_0 <= 1e+270) tmp = Float64(Float64(Float64(x + Float64(y_m * 2.0)) * Float64(x - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(Float64(x + Float64(y_m * -2.0)) / hypot(Float64(y_m * 2.0), x)) * Float64(1.0 + Float64(0.5 * Float64(x / y_m)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); tmp = 0.0; if (t_0 <= 5e-157) tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))); elseif (t_0 <= 1e+270) tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)); else tmp = ((x + (y_m * -2.0)) / hypot((y_m * 2.0), x)) * (1.0 + (0.5 * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-157], N[(N[(1.0 + N[(-2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+270], N[(N[(N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + N[(y$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(y$95$m * 2.0), $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-157}:\\
\;\;\;\;\left(1 + -2 \cdot \frac{y\_m}{x}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+270}:\\
\;\;\;\;\frac{\left(x + y\_m \cdot 2\right) \cdot \left(x - y\_m \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y\_m \cdot -2}{\mathsf{hypot}\left(y\_m \cdot 2, x\right)} \cdot \left(1 + 0.5 \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 5.0000000000000002e-157Initial program 53.9%
add-sqr-sqrt53.9%
difference-of-squares53.9%
*-commutative53.9%
associate-*r*53.9%
sqrt-prod53.9%
sqrt-unprod28.1%
add-sqr-sqrt49.5%
metadata-eval49.5%
*-commutative49.5%
associate-*r*49.5%
sqrt-prod49.5%
sqrt-unprod28.1%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
add-sqr-sqrt53.9%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
+-commutative55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
*-commutative55.4%
sqrt-prod28.8%
sqrt-prod28.8%
metadata-eval28.8%
associate-*l*28.8%
add-sqr-sqrt55.4%
Applied egg-rr99.9%
Taylor expanded in y around 0 48.3%
Taylor expanded in y around 0 86.0%
if 5.0000000000000002e-157 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1e270Initial program 80.0%
add-sqr-sqrt80.0%
difference-of-squares80.0%
*-commutative80.0%
associate-*r*80.0%
sqrt-prod80.0%
sqrt-unprod44.6%
add-sqr-sqrt54.2%
metadata-eval54.2%
*-commutative54.2%
associate-*r*54.2%
sqrt-prod54.2%
sqrt-unprod44.7%
add-sqr-sqrt80.0%
metadata-eval80.0%
Applied egg-rr80.0%
if 1e270 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 4.5%
add-sqr-sqrt4.5%
difference-of-squares4.5%
*-commutative4.5%
associate-*r*4.5%
sqrt-prod4.5%
sqrt-unprod2.9%
add-sqr-sqrt3.0%
metadata-eval3.0%
*-commutative3.0%
associate-*r*3.0%
sqrt-prod3.0%
sqrt-unprod2.9%
add-sqr-sqrt4.5%
metadata-eval4.5%
Applied egg-rr4.5%
add-sqr-sqrt4.5%
times-frac7.4%
+-commutative7.4%
fma-define7.4%
+-commutative7.4%
add-sqr-sqrt7.4%
hypot-define7.4%
*-commutative7.4%
sqrt-prod4.3%
sqrt-prod4.3%
metadata-eval4.3%
associate-*l*4.3%
add-sqr-sqrt7.4%
Applied egg-rr99.9%
Taylor expanded in y around inf 36.4%
fma-undefine99.9%
Applied egg-rr36.4%
Final simplification70.7%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (* 0.5 (/ x y_m))))
(if (<= t_0 5e-157)
(* (+ 1.0 (* -2.0 (/ y_m x))) (+ 1.0 (* 2.0 (/ y_m x))))
(if (<= t_0 2e+254)
(/ (* (+ x (* y_m 2.0)) (- x (* y_m 2.0))) (+ t_0 (* x x)))
(* (+ 1.0 t_1) (+ t_1 -1.0))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = 0.5 * (x / y_m);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 2e+254) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = (1.0 + t_1) * (t_1 + -1.0);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
t_1 = 0.5d0 * (x / y_m)
if (t_0 <= 5d-157) then
tmp = (1.0d0 + ((-2.0d0) * (y_m / x))) * (1.0d0 + (2.0d0 * (y_m / x)))
else if (t_0 <= 2d+254) then
tmp = ((x + (y_m * 2.0d0)) * (x - (y_m * 2.0d0))) / (t_0 + (x * x))
else
tmp = (1.0d0 + t_1) * (t_1 + (-1.0d0))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = 0.5 * (x / y_m);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 2e+254) {
tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x));
} else {
tmp = (1.0 + t_1) * (t_1 + -1.0);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = 0.5 * (x / y_m) tmp = 0 if t_0 <= 5e-157: tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))) elif t_0 <= 2e+254: tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)) else: tmp = (1.0 + t_1) * (t_1 + -1.0) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(0.5 * Float64(x / y_m)) tmp = 0.0 if (t_0 <= 5e-157) tmp = Float64(Float64(1.0 + Float64(-2.0 * Float64(y_m / x))) * Float64(1.0 + Float64(2.0 * Float64(y_m / x)))); elseif (t_0 <= 2e+254) tmp = Float64(Float64(Float64(x + Float64(y_m * 2.0)) * Float64(x - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(1.0 + t_1) * Float64(t_1 + -1.0)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); t_1 = 0.5 * (x / y_m); tmp = 0.0; if (t_0 <= 5e-157) tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))); elseif (t_0 <= 2e+254) tmp = ((x + (y_m * 2.0)) * (x - (y_m * 2.0))) / (t_0 + (x * x)); else tmp = (1.0 + t_1) * (t_1 + -1.0); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-157], N[(N[(1.0 + N[(-2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+254], N[(N[(N[(x + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := 0.5 \cdot \frac{x}{y\_m}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-157}:\\
\;\;\;\;\left(1 + -2 \cdot \frac{y\_m}{x}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+254}:\\
\;\;\;\;\frac{\left(x + y\_m \cdot 2\right) \cdot \left(x - y\_m \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 5.0000000000000002e-157Initial program 53.9%
add-sqr-sqrt53.9%
difference-of-squares53.9%
*-commutative53.9%
associate-*r*53.9%
sqrt-prod53.9%
sqrt-unprod28.1%
add-sqr-sqrt49.5%
metadata-eval49.5%
*-commutative49.5%
associate-*r*49.5%
sqrt-prod49.5%
sqrt-unprod28.1%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
add-sqr-sqrt53.9%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
+-commutative55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
*-commutative55.4%
sqrt-prod28.8%
sqrt-prod28.8%
metadata-eval28.8%
associate-*l*28.8%
add-sqr-sqrt55.4%
Applied egg-rr99.9%
Taylor expanded in y around 0 48.3%
Taylor expanded in y around 0 86.0%
if 5.0000000000000002e-157 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1.9999999999999999e254Initial program 79.2%
add-sqr-sqrt79.2%
difference-of-squares79.2%
*-commutative79.2%
associate-*r*79.2%
sqrt-prod79.2%
sqrt-unprod42.4%
add-sqr-sqrt52.3%
metadata-eval52.3%
*-commutative52.3%
associate-*r*52.3%
sqrt-prod52.3%
sqrt-unprod42.4%
add-sqr-sqrt79.2%
metadata-eval79.2%
Applied egg-rr79.2%
if 1.9999999999999999e254 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 9.9%
add-sqr-sqrt9.9%
difference-of-squares9.8%
*-commutative9.8%
associate-*r*9.8%
sqrt-prod9.8%
sqrt-unprod8.3%
add-sqr-sqrt8.5%
metadata-eval8.5%
*-commutative8.5%
associate-*r*8.5%
sqrt-prod8.5%
sqrt-unprod8.3%
add-sqr-sqrt9.8%
metadata-eval9.8%
Applied egg-rr9.8%
add-sqr-sqrt9.8%
times-frac12.6%
+-commutative12.6%
fma-define12.6%
+-commutative12.6%
add-sqr-sqrt12.6%
hypot-define12.6%
*-commutative12.6%
sqrt-prod9.6%
sqrt-prod9.6%
metadata-eval9.6%
associate-*l*9.6%
add-sqr-sqrt12.6%
Applied egg-rr99.9%
Taylor expanded in y around inf 39.9%
Taylor expanded in y around inf 85.9%
Final simplification83.4%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (* 0.5 (/ x y_m))))
(if (<= t_0 5e-157)
(* (+ 1.0 (* -2.0 (/ y_m x))) (+ 1.0 (* 2.0 (/ y_m x))))
(if (<= t_0 2e+254)
(/ (- (* x x) t_0) (+ t_0 (* x x)))
(* (+ 1.0 t_1) (+ t_1 -1.0))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = 0.5 * (x / y_m);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 2e+254) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = (1.0 + t_1) * (t_1 + -1.0);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
t_1 = 0.5d0 * (x / y_m)
if (t_0 <= 5d-157) then
tmp = (1.0d0 + ((-2.0d0) * (y_m / x))) * (1.0d0 + (2.0d0 * (y_m / x)))
else if (t_0 <= 2d+254) then
tmp = ((x * x) - t_0) / (t_0 + (x * x))
else
tmp = (1.0d0 + t_1) * (t_1 + (-1.0d0))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double t_1 = 0.5 * (x / y_m);
double tmp;
if (t_0 <= 5e-157) {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
} else if (t_0 <= 2e+254) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = (1.0 + t_1) * (t_1 + -1.0);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = y_m * (y_m * 4.0) t_1 = 0.5 * (x / y_m) tmp = 0 if t_0 <= 5e-157: tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))) elif t_0 <= 2e+254: tmp = ((x * x) - t_0) / (t_0 + (x * x)) else: tmp = (1.0 + t_1) * (t_1 + -1.0) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) t_1 = Float64(0.5 * Float64(x / y_m)) tmp = 0.0 if (t_0 <= 5e-157) tmp = Float64(Float64(1.0 + Float64(-2.0 * Float64(y_m / x))) * Float64(1.0 + Float64(2.0 * Float64(y_m / x)))); elseif (t_0 <= 2e+254) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(1.0 + t_1) * Float64(t_1 + -1.0)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = y_m * (y_m * 4.0); t_1 = 0.5 * (x / y_m); tmp = 0.0; if (t_0 <= 5e-157) tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))); elseif (t_0 <= 2e+254) tmp = ((x * x) - t_0) / (t_0 + (x * x)); else tmp = (1.0 + t_1) * (t_1 + -1.0); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-157], N[(N[(1.0 + N[(-2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+254], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := 0.5 \cdot \frac{x}{y\_m}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-157}:\\
\;\;\;\;\left(1 + -2 \cdot \frac{y\_m}{x}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+254}:\\
\;\;\;\;\frac{x \cdot x - t\_0}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 5.0000000000000002e-157Initial program 53.9%
add-sqr-sqrt53.9%
difference-of-squares53.9%
*-commutative53.9%
associate-*r*53.9%
sqrt-prod53.9%
sqrt-unprod28.1%
add-sqr-sqrt49.5%
metadata-eval49.5%
*-commutative49.5%
associate-*r*49.5%
sqrt-prod49.5%
sqrt-unprod28.1%
add-sqr-sqrt53.9%
metadata-eval53.9%
Applied egg-rr53.9%
add-sqr-sqrt53.9%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
+-commutative55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
*-commutative55.4%
sqrt-prod28.8%
sqrt-prod28.8%
metadata-eval28.8%
associate-*l*28.8%
add-sqr-sqrt55.4%
Applied egg-rr99.9%
Taylor expanded in y around 0 48.3%
Taylor expanded in y around 0 86.0%
if 5.0000000000000002e-157 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1.9999999999999999e254Initial program 79.2%
if 1.9999999999999999e254 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 9.9%
add-sqr-sqrt9.9%
difference-of-squares9.8%
*-commutative9.8%
associate-*r*9.8%
sqrt-prod9.8%
sqrt-unprod8.3%
add-sqr-sqrt8.5%
metadata-eval8.5%
*-commutative8.5%
associate-*r*8.5%
sqrt-prod8.5%
sqrt-unprod8.3%
add-sqr-sqrt9.8%
metadata-eval9.8%
Applied egg-rr9.8%
add-sqr-sqrt9.8%
times-frac12.6%
+-commutative12.6%
fma-define12.6%
+-commutative12.6%
add-sqr-sqrt12.6%
hypot-define12.6%
*-commutative12.6%
sqrt-prod9.6%
sqrt-prod9.6%
metadata-eval9.6%
associate-*l*9.6%
add-sqr-sqrt12.6%
Applied egg-rr99.9%
Taylor expanded in y around inf 39.9%
Taylor expanded in y around inf 85.9%
Final simplification83.4%
y_m = (fabs.f64 y)
(FPCore (x y_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ x y_m))))
(if (<= x 6.5e+53)
(* (+ 1.0 t_0) (+ t_0 -1.0))
(* (+ 1.0 (* -2.0 (/ y_m x))) (+ 1.0 (* 2.0 (/ y_m x)))))))y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = 0.5 * (x / y_m);
double tmp;
if (x <= 6.5e+53) {
tmp = (1.0 + t_0) * (t_0 + -1.0);
} else {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (x / y_m)
if (x <= 6.5d+53) then
tmp = (1.0d0 + t_0) * (t_0 + (-1.0d0))
else
tmp = (1.0d0 + ((-2.0d0) * (y_m / x))) * (1.0d0 + (2.0d0 * (y_m / x)))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = 0.5 * (x / y_m);
double tmp;
if (x <= 6.5e+53) {
tmp = (1.0 + t_0) * (t_0 + -1.0);
} else {
tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = 0.5 * (x / y_m) tmp = 0 if x <= 6.5e+53: tmp = (1.0 + t_0) * (t_0 + -1.0) else: tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(0.5 * Float64(x / y_m)) tmp = 0.0 if (x <= 6.5e+53) tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0)); else tmp = Float64(Float64(1.0 + Float64(-2.0 * Float64(y_m / x))) * Float64(1.0 + Float64(2.0 * Float64(y_m / x)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = 0.5 * (x / y_m); tmp = 0.0; if (x <= 6.5e+53) tmp = (1.0 + t_0) * (t_0 + -1.0); else tmp = (1.0 + (-2.0 * (y_m / x))) * (1.0 + (2.0 * (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6.5e+53], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{y\_m}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{+53}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + -2 \cdot \frac{y\_m}{x}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x}\right)\\
\end{array}
\end{array}
if x < 6.50000000000000017e53Initial program 55.9%
add-sqr-sqrt55.9%
difference-of-squares55.9%
*-commutative55.9%
associate-*r*55.9%
sqrt-prod55.9%
sqrt-unprod30.5%
add-sqr-sqrt40.7%
metadata-eval40.7%
*-commutative40.7%
associate-*r*40.7%
sqrt-prod40.7%
sqrt-unprod30.5%
add-sqr-sqrt55.9%
metadata-eval55.9%
Applied egg-rr55.9%
add-sqr-sqrt55.9%
times-frac57.3%
+-commutative57.3%
fma-define57.3%
+-commutative57.3%
add-sqr-sqrt57.3%
hypot-define57.3%
*-commutative57.3%
sqrt-prod31.1%
sqrt-prod31.1%
metadata-eval31.1%
associate-*l*31.1%
add-sqr-sqrt57.3%
Applied egg-rr99.9%
Taylor expanded in y around inf 31.7%
Taylor expanded in y around inf 62.4%
if 6.50000000000000017e53 < x Initial program 33.3%
add-sqr-sqrt33.3%
difference-of-squares33.3%
*-commutative33.3%
associate-*r*33.3%
sqrt-prod33.3%
sqrt-unprod18.4%
add-sqr-sqrt33.3%
metadata-eval33.3%
*-commutative33.3%
associate-*r*33.3%
sqrt-prod33.3%
sqrt-unprod18.4%
add-sqr-sqrt33.3%
metadata-eval33.3%
Applied egg-rr33.3%
add-sqr-sqrt33.3%
times-frac35.4%
+-commutative35.4%
fma-define35.4%
+-commutative35.4%
add-sqr-sqrt35.4%
hypot-define35.4%
*-commutative35.4%
sqrt-prod19.5%
sqrt-prod19.5%
metadata-eval19.5%
associate-*l*19.5%
add-sqr-sqrt35.4%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.8%
Taylor expanded in y around 0 82.5%
Final simplification66.7%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (let* ((t_0 (* 0.5 (/ x y_m)))) (if (<= x 2.3e+56) (* (+ 1.0 t_0) (+ t_0 -1.0)) 1.0)))
y_m = fabs(y);
double code(double x, double y_m) {
double t_0 = 0.5 * (x / y_m);
double tmp;
if (x <= 2.3e+56) {
tmp = (1.0 + t_0) * (t_0 + -1.0);
} else {
tmp = 1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (x / y_m)
if (x <= 2.3d+56) then
tmp = (1.0d0 + t_0) * (t_0 + (-1.0d0))
else
tmp = 1.0d0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double t_0 = 0.5 * (x / y_m);
double tmp;
if (x <= 2.3e+56) {
tmp = (1.0 + t_0) * (t_0 + -1.0);
} else {
tmp = 1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): t_0 = 0.5 * (x / y_m) tmp = 0 if x <= 2.3e+56: tmp = (1.0 + t_0) * (t_0 + -1.0) else: tmp = 1.0 return tmp
y_m = abs(y) function code(x, y_m) t_0 = Float64(0.5 * Float64(x / y_m)) tmp = 0.0 if (x <= 2.3e+56) tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0)); else tmp = 1.0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) t_0 = 0.5 * (x / y_m); tmp = 0.0; if (x <= 2.3e+56) tmp = (1.0 + t_0) * (t_0 + -1.0); else tmp = 1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e+56], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{y\_m}\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{+56}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 2.30000000000000015e56Initial program 55.9%
add-sqr-sqrt55.9%
difference-of-squares55.9%
*-commutative55.9%
associate-*r*55.9%
sqrt-prod55.9%
sqrt-unprod30.5%
add-sqr-sqrt40.7%
metadata-eval40.7%
*-commutative40.7%
associate-*r*40.7%
sqrt-prod40.7%
sqrt-unprod30.5%
add-sqr-sqrt55.9%
metadata-eval55.9%
Applied egg-rr55.9%
add-sqr-sqrt55.9%
times-frac57.3%
+-commutative57.3%
fma-define57.3%
+-commutative57.3%
add-sqr-sqrt57.3%
hypot-define57.3%
*-commutative57.3%
sqrt-prod31.1%
sqrt-prod31.1%
metadata-eval31.1%
associate-*l*31.1%
add-sqr-sqrt57.3%
Applied egg-rr99.9%
Taylor expanded in y around inf 31.7%
Taylor expanded in y around inf 62.4%
if 2.30000000000000015e56 < x Initial program 33.3%
*-commutative33.3%
fma-define33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in x around inf 81.8%
Final simplification66.5%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (if (<= x 5.8e+54) -1.0 1.0))
y_m = fabs(y);
double code(double x, double y_m) {
double tmp;
if (x <= 5.8e+54) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if (x <= 5.8d+54) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
double tmp;
if (x <= 5.8e+54) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m): tmp = 0 if x <= 5.8e+54: tmp = -1.0 else: tmp = 1.0 return tmp
y_m = abs(y) function code(x, y_m) tmp = 0.0 if (x <= 5.8e+54) tmp = -1.0; else tmp = 1.0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m) tmp = 0.0; if (x <= 5.8e+54) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := If[LessEqual[x, 5.8e+54], -1.0, 1.0]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{+54}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 5.7999999999999997e54Initial program 55.9%
*-commutative55.9%
fma-define55.9%
*-commutative55.9%
Simplified55.9%
Taylor expanded in x around 0 61.2%
if 5.7999999999999997e54 < x Initial program 33.3%
*-commutative33.3%
fma-define33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in x around inf 81.8%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 -1.0)
y_m = fabs(y);
double code(double x, double y_m) {
return -1.0;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = -1.0d0
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return -1.0;
}
y_m = math.fabs(y) def code(x, y_m): return -1.0
y_m = abs(y) function code(x, y_m) return -1.0 end
y_m = abs(y); function tmp = code(x, y_m) tmp = -1.0; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := -1.0
\begin{array}{l}
y_m = \left|y\right|
\\
-1
\end{array}
Initial program 51.2%
*-commutative51.2%
fma-define51.2%
*-commutative51.2%
Simplified51.2%
Taylor expanded in x around 0 52.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* y y) 4.0))
(t_1 (+ (* x x) t_0))
(t_2 (/ t_0 t_1))
(t_3 (* (* y 4.0) y)))
(if (< (/ (- (* x x) t_3) (+ (* x x) t_3)) 0.9743233849626781)
(- (/ (* x x) t_1) t_2)
(- (pow (/ x (sqrt t_1)) 2.0) t_2))))
double code(double x, double y) {
double t_0 = (y * y) * 4.0;
double t_1 = (x * x) + t_0;
double t_2 = t_0 / t_1;
double t_3 = (y * 4.0) * y;
double tmp;
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
tmp = ((x * x) / t_1) - t_2;
} else {
tmp = pow((x / sqrt(t_1)), 2.0) - t_2;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (y * y) * 4.0d0
t_1 = (x * x) + t_0
t_2 = t_0 / t_1
t_3 = (y * 4.0d0) * y
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781d0) then
tmp = ((x * x) / t_1) - t_2
else
tmp = ((x / sqrt(t_1)) ** 2.0d0) - t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y * y) * 4.0;
double t_1 = (x * x) + t_0;
double t_2 = t_0 / t_1;
double t_3 = (y * 4.0) * y;
double tmp;
if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
tmp = ((x * x) / t_1) - t_2;
} else {
tmp = Math.pow((x / Math.sqrt(t_1)), 2.0) - t_2;
}
return tmp;
}
def code(x, y): t_0 = (y * y) * 4.0 t_1 = (x * x) + t_0 t_2 = t_0 / t_1 t_3 = (y * 4.0) * y tmp = 0 if (((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781: tmp = ((x * x) / t_1) - t_2 else: tmp = math.pow((x / math.sqrt(t_1)), 2.0) - t_2 return tmp
function code(x, y) t_0 = Float64(Float64(y * y) * 4.0) t_1 = Float64(Float64(x * x) + t_0) t_2 = Float64(t_0 / t_1) t_3 = Float64(Float64(y * 4.0) * y) tmp = 0.0 if (Float64(Float64(Float64(x * x) - t_3) / Float64(Float64(x * x) + t_3)) < 0.9743233849626781) tmp = Float64(Float64(Float64(x * x) / t_1) - t_2); else tmp = Float64((Float64(x / sqrt(t_1)) ^ 2.0) - t_2); end return tmp end
function tmp_2 = code(x, y) t_0 = (y * y) * 4.0; t_1 = (x * x) + t_0; t_2 = t_0 / t_1; t_3 = (y * 4.0) * y; tmp = 0.0; if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) tmp = ((x * x) / t_1) - t_2; else tmp = ((x / sqrt(t_1)) ^ 2.0) - t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[Less[N[(N[(N[(x * x), $MachinePrecision] - t$95$3), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], 0.9743233849626781], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], N[(N[Power[N[(x / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot y\right) \cdot 4\\
t_1 := x \cdot x + t\_0\\
t_2 := \frac{t\_0}{t\_1}\\
t_3 := \left(y \cdot 4\right) \cdot y\\
\mathbf{if}\;\frac{x \cdot x - t\_3}{x \cdot x + t\_3} < 0.9743233849626781:\\
\;\;\;\;\frac{x \cdot x}{t\_1} - t\_2\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\sqrt{t\_1}}\right)}^{2} - t\_2\\
\end{array}
\end{array}
herbie shell --seed 2024170
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 9743233849626781/10000000000000000) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4))))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))