
(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 7 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}
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 (let* ((t_0 (hypot x_m (* y_m 2.0)))) (/ (* (/ (+ x_m (* -2.0 y_m)) t_0) (fma y_m 2.0 x_m)) t_0)))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double t_0 = hypot(x_m, (y_m * 2.0));
return (((x_m + (-2.0 * y_m)) / t_0) * fma(y_m, 2.0, x_m)) / t_0;
}
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) t_0 = hypot(x_m, Float64(y_m * 2.0)) return Float64(Float64(Float64(Float64(x_m + Float64(-2.0 * y_m)) / t_0) * fma(y_m, 2.0, x_m)) / t_0) end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(N[(x$95$m + N[(-2.0 * y$95$m), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(y$95$m * 2.0 + x$95$m), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)\\
\frac{\frac{x\_m + -2 \cdot y\_m}{t\_0} \cdot \mathsf{fma}\left(y\_m, 2, x\_m\right)}{t\_0}
\end{array}
\end{array}
Initial program 54.3%
add-sqr-sqrt54.3%
difference-of-squares54.3%
*-commutative54.3%
associate-*r*54.3%
sqrt-prod54.3%
sqrt-unprod24.9%
add-sqr-sqrt40.3%
metadata-eval40.3%
*-commutative40.3%
associate-*r*40.3%
sqrt-prod40.3%
sqrt-unprod24.9%
add-sqr-sqrt54.3%
metadata-eval54.3%
Applied egg-rr54.3%
add-sqr-sqrt54.3%
times-frac55.4%
+-commutative55.4%
fma-define55.4%
add-sqr-sqrt55.4%
hypot-define55.4%
sqrt-prod25.4%
*-commutative25.4%
sqrt-prod25.4%
metadata-eval25.4%
associate-*r*25.4%
add-sqr-sqrt55.4%
*-commutative55.4%
Applied egg-rr100.0%
*-commutative100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
:precision binary64
(let* ((t_0 (* y_m (/ 2.0 x_m))))
(if (<= (* x_m x_m) 0.0)
-1.0
(if (<= (* x_m x_m) 1e-151)
(/
(* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0)))
(+ (* x_m x_m) (* y_m (* y_m 4.0))))
(/ (- 1.0 (pow t_0 2.0)) (+ 1.0 (* t_0 t_0)))))))x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double t_0 = y_m * (2.0 / x_m);
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 1e-151) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = (1.0 - pow(t_0, 2.0)) / (1.0 + (t_0 * t_0));
}
return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (2.0d0 / x_m)
if ((x_m * x_m) <= 0.0d0) then
tmp = -1.0d0
else if ((x_m * x_m) <= 1d-151) then
tmp = ((x_m + (y_m * 2.0d0)) * (x_m - (y_m * 2.0d0))) / ((x_m * x_m) + (y_m * (y_m * 4.0d0)))
else
tmp = (1.0d0 - (t_0 ** 2.0d0)) / (1.0d0 + (t_0 * t_0))
end if
code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double t_0 = y_m * (2.0 / x_m);
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 1e-151) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = (1.0 - Math.pow(t_0, 2.0)) / (1.0 + (t_0 * t_0));
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): t_0 = y_m * (2.0 / x_m) tmp = 0 if (x_m * x_m) <= 0.0: tmp = -1.0 elif (x_m * x_m) <= 1e-151: tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))) else: tmp = (1.0 - math.pow(t_0, 2.0)) / (1.0 + (t_0 * t_0)) return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) t_0 = Float64(y_m * Float64(2.0 / x_m)) tmp = 0.0 if (Float64(x_m * x_m) <= 0.0) tmp = -1.0; elseif (Float64(x_m * x_m) <= 1e-151) tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(Float64(x_m * x_m) + Float64(y_m * Float64(y_m * 4.0)))); else tmp = Float64(Float64(1.0 - (t_0 ^ 2.0)) / Float64(1.0 + Float64(t_0 * t_0))); end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) t_0 = y_m * (2.0 / x_m); tmp = 0.0; if ((x_m * x_m) <= 0.0) tmp = -1.0; elseif ((x_m * x_m) <= 1e-151) tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))); else tmp = (1.0 - (t_0 ^ 2.0)) / (1.0 + (t_0 * t_0)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(2.0 / x$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 1e-151], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \frac{2}{x\_m}\\
\mathbf{if}\;x\_m \cdot x\_m \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x\_m \cdot x\_m \leq 10^{-151}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{x\_m \cdot x\_m + y\_m \cdot \left(y\_m \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - {t\_0}^{2}}{1 + t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 53.4%
Taylor expanded in x around 0 91.5%
if 0.0 < (*.f64 x x) < 9.9999999999999994e-152Initial program 77.6%
add-sqr-sqrt77.6%
difference-of-squares77.8%
*-commutative77.8%
associate-*r*77.8%
sqrt-prod77.8%
sqrt-unprod33.3%
add-sqr-sqrt55.0%
metadata-eval55.0%
*-commutative55.0%
associate-*r*55.0%
sqrt-prod55.0%
sqrt-unprod33.3%
add-sqr-sqrt77.8%
metadata-eval77.8%
Applied egg-rr77.8%
if 9.9999999999999994e-152 < (*.f64 x x) Initial program 49.4%
Taylor expanded in x around inf 49.4%
associate-*r/49.4%
*-commutative49.4%
Simplified49.4%
unpow249.4%
metadata-eval49.4%
swap-sqr49.4%
pow249.4%
times-frac49.3%
Applied egg-rr49.3%
pow249.3%
associate-/r*49.4%
div-inv49.4%
pow249.4%
*-commutative49.4%
pow249.4%
pow249.4%
associate-/l*49.4%
Applied egg-rr49.4%
associate-*r/49.4%
Simplified93.2%
unpow293.2%
Applied egg-rr93.2%
Final simplification90.7%
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
:precision binary64
(if (<= (* x_m x_m) 0.0)
-1.0
(if (<= (* x_m x_m) 5e+216)
(/
(* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0)))
(+ (* x_m x_m) (* y_m (* y_m 4.0))))
(/ x_m (hypot x_m (* y_m 2.0))))))x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5e+216) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = x_m / hypot(x_m, (y_m * 2.0));
}
return tmp;
}
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5e+216) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = x_m / Math.hypot(x_m, (y_m * 2.0));
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): tmp = 0 if (x_m * x_m) <= 0.0: tmp = -1.0 elif (x_m * x_m) <= 5e+216: tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))) else: tmp = x_m / math.hypot(x_m, (y_m * 2.0)) return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (Float64(x_m * x_m) <= 0.0) tmp = -1.0; elseif (Float64(x_m * x_m) <= 5e+216) tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(Float64(x_m * x_m) + Float64(y_m * Float64(y_m * 4.0)))); else tmp = Float64(x_m / hypot(x_m, Float64(y_m * 2.0))); end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) tmp = 0.0; if ((x_m * x_m) <= 0.0) tmp = -1.0; elseif ((x_m * x_m) <= 5e+216) tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))); else tmp = x_m / hypot(x_m, (y_m * 2.0)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 5e+216], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m / N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \cdot x\_m \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x\_m \cdot x\_m \leq 5 \cdot 10^{+216}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{x\_m \cdot x\_m + y\_m \cdot \left(y\_m \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{\mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 53.4%
Taylor expanded in x around 0 91.5%
if 0.0 < (*.f64 x x) < 4.9999999999999998e216Initial program 81.7%
add-sqr-sqrt81.7%
difference-of-squares81.8%
*-commutative81.8%
associate-*r*81.8%
sqrt-prod81.8%
sqrt-unprod37.2%
add-sqr-sqrt67.2%
metadata-eval67.2%
*-commutative67.2%
associate-*r*67.2%
sqrt-prod67.2%
sqrt-unprod37.2%
add-sqr-sqrt81.8%
metadata-eval81.8%
Applied egg-rr81.8%
if 4.9999999999999998e216 < (*.f64 x x) Initial program 20.5%
add-sqr-sqrt20.5%
difference-of-squares20.5%
*-commutative20.5%
associate-*r*20.5%
sqrt-prod20.5%
sqrt-unprod13.6%
add-sqr-sqrt20.5%
metadata-eval20.5%
*-commutative20.5%
associate-*r*20.5%
sqrt-prod20.5%
sqrt-unprod13.6%
add-sqr-sqrt20.5%
metadata-eval20.5%
Applied egg-rr20.5%
add-sqr-sqrt20.5%
times-frac22.9%
+-commutative22.9%
fma-define22.9%
add-sqr-sqrt22.9%
hypot-define22.9%
sqrt-prod15.0%
*-commutative15.0%
sqrt-prod15.0%
metadata-eval15.0%
associate-*r*15.0%
add-sqr-sqrt22.9%
*-commutative22.9%
Applied egg-rr99.9%
*-commutative99.9%
associate-*r/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 44.4%
Final simplification71.1%
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
:precision binary64
(if (<= (* x_m x_m) 0.0)
-1.0
(if (<= (* x_m x_m) 5e+216)
(/
(* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0)))
(+ (* x_m x_m) (* y_m (* y_m 4.0))))
1.0)))x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5e+216) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = 1.0;
}
return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8) :: tmp
if ((x_m * x_m) <= 0.0d0) then
tmp = -1.0d0
else if ((x_m * x_m) <= 5d+216) then
tmp = ((x_m + (y_m * 2.0d0)) * (x_m - (y_m * 2.0d0))) / ((x_m * x_m) + (y_m * (y_m * 4.0d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5e+216) {
tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0)));
} else {
tmp = 1.0;
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): tmp = 0 if (x_m * x_m) <= 0.0: tmp = -1.0 elif (x_m * x_m) <= 5e+216: tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))) else: tmp = 1.0 return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (Float64(x_m * x_m) <= 0.0) tmp = -1.0; elseif (Float64(x_m * x_m) <= 5e+216) tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(Float64(x_m * x_m) + Float64(y_m * Float64(y_m * 4.0)))); else tmp = 1.0; end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) tmp = 0.0; if ((x_m * x_m) <= 0.0) tmp = -1.0; elseif ((x_m * x_m) <= 5e+216) tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / ((x_m * x_m) + (y_m * (y_m * 4.0))); else tmp = 1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 5e+216], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \cdot x\_m \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x\_m \cdot x\_m \leq 5 \cdot 10^{+216}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{x\_m \cdot x\_m + y\_m \cdot \left(y\_m \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 53.4%
Taylor expanded in x around 0 91.5%
if 0.0 < (*.f64 x x) < 4.9999999999999998e216Initial program 81.7%
add-sqr-sqrt81.7%
difference-of-squares81.8%
*-commutative81.8%
associate-*r*81.8%
sqrt-prod81.8%
sqrt-unprod37.2%
add-sqr-sqrt67.2%
metadata-eval67.2%
*-commutative67.2%
associate-*r*67.2%
sqrt-prod67.2%
sqrt-unprod37.2%
add-sqr-sqrt81.8%
metadata-eval81.8%
Applied egg-rr81.8%
if 4.9999999999999998e216 < (*.f64 x x) Initial program 20.5%
Taylor expanded in x around inf 84.1%
Final simplification84.8%
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
:precision binary64
(let* ((t_0 (* y_m (* y_m 4.0))))
(if (<= (* x_m x_m) 0.0)
-1.0
(if (<= (* x_m x_m) 5.8e+216)
(/ (- (* x_m x_m) t_0) (+ (* x_m x_m) t_0))
1.0))))x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5.8e+216) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0;
}
return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (y_m * 4.0d0)
if ((x_m * x_m) <= 0.0d0) then
tmp = -1.0d0
else if ((x_m * x_m) <= 5.8d+216) then
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0)
else
tmp = 1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double t_0 = y_m * (y_m * 4.0);
double tmp;
if ((x_m * x_m) <= 0.0) {
tmp = -1.0;
} else if ((x_m * x_m) <= 5.8e+216) {
tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0);
} else {
tmp = 1.0;
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): t_0 = y_m * (y_m * 4.0) tmp = 0 if (x_m * x_m) <= 0.0: tmp = -1.0 elif (x_m * x_m) <= 5.8e+216: tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0) else: tmp = 1.0 return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) t_0 = Float64(y_m * Float64(y_m * 4.0)) tmp = 0.0 if (Float64(x_m * x_m) <= 0.0) tmp = -1.0; elseif (Float64(x_m * x_m) <= 5.8e+216) tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(Float64(x_m * x_m) + t_0)); else tmp = 1.0; end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) t_0 = y_m * (y_m * 4.0); tmp = 0.0; if ((x_m * x_m) <= 0.0) tmp = -1.0; elseif ((x_m * x_m) <= 5.8e+216) tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0); else tmp = 1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 0.0], -1.0, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 5.8e+216], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;x\_m \cdot x\_m \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;x\_m \cdot x\_m \leq 5.8 \cdot 10^{+216}:\\
\;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{x\_m \cdot x\_m + t\_0}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 53.4%
Taylor expanded in x around 0 91.5%
if 0.0 < (*.f64 x x) < 5.8000000000000002e216Initial program 81.7%
if 5.8000000000000002e216 < (*.f64 x x) Initial program 20.5%
Taylor expanded in x around inf 84.1%
Final simplification84.8%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 (if (<= x_m 4.5e-156) -1.0 (if (<= x_m 7e-145) 1.0 (if (<= x_m 3.4e-76) -1.0 1.0))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
double tmp;
if (x_m <= 4.5e-156) {
tmp = -1.0;
} else if (x_m <= 7e-145) {
tmp = 1.0;
} else if (x_m <= 3.4e-76) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8) :: tmp
if (x_m <= 4.5d-156) then
tmp = -1.0d0
else if (x_m <= 7d-145) then
tmp = 1.0d0
else if (x_m <= 3.4d-76) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
double tmp;
if (x_m <= 4.5e-156) {
tmp = -1.0;
} else if (x_m <= 7e-145) {
tmp = 1.0;
} else if (x_m <= 3.4e-76) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): tmp = 0 if x_m <= 4.5e-156: tmp = -1.0 elif x_m <= 7e-145: tmp = 1.0 elif x_m <= 3.4e-76: tmp = -1.0 else: tmp = 1.0 return tmp
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) tmp = 0.0 if (x_m <= 4.5e-156) tmp = -1.0; elseif (x_m <= 7e-145) tmp = 1.0; elseif (x_m <= 3.4e-76) tmp = -1.0; else tmp = 1.0; end return tmp end
x_m = abs(x); y_m = abs(y); function tmp_2 = code(x_m, y_m) tmp = 0.0; if (x_m <= 4.5e-156) tmp = -1.0; elseif (x_m <= 7e-145) tmp = 1.0; elseif (x_m <= 3.4e-76) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := If[LessEqual[x$95$m, 4.5e-156], -1.0, If[LessEqual[x$95$m, 7e-145], 1.0, If[LessEqual[x$95$m, 3.4e-76], -1.0, 1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4.5 \cdot 10^{-156}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x\_m \leq 7 \cdot 10^{-145}:\\
\;\;\;\;1\\
\mathbf{elif}\;x\_m \leq 3.4 \cdot 10^{-76}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 4.49999999999999986e-156 or 6.99999999999999994e-145 < x < 3.3999999999999999e-76Initial program 57.4%
Taylor expanded in x around 0 55.8%
if 4.49999999999999986e-156 < x < 6.99999999999999994e-145 or 3.3999999999999999e-76 < x Initial program 47.5%
Taylor expanded in x around inf 75.4%
x_m = (fabs.f64 x) y_m = (fabs.f64 y) (FPCore (x_m y_m) :precision binary64 -1.0)
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
return -1.0;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
code = -1.0d0
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
return -1.0;
}
x_m = math.fabs(x) y_m = math.fabs(y) def code(x_m, y_m): return -1.0
x_m = abs(x) y_m = abs(y) function code(x_m, y_m) return -1.0 end
x_m = abs(x); y_m = abs(y); function tmp = code(x_m, y_m) tmp = -1.0; end
x_m = N[Abs[x], $MachinePrecision] y_m = N[Abs[y], $MachinePrecision] code[x$95$m_, y$95$m_] := -1.0
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|
\\
-1
\end{array}
Initial program 54.3%
Taylor expanded in x around 0 45.7%
(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 2024092
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(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))))