
(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 8 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}
(FPCore (x y) :precision binary64 (let* ((t_0 (hypot x (* y 2.0)))) (* (/ (fma y 2.0 x) t_0) (/ (+ x (* y -2.0)) t_0))))
double code(double x, double y) {
double t_0 = hypot(x, (y * 2.0));
return (fma(y, 2.0, x) / t_0) * ((x + (y * -2.0)) / t_0);
}
function code(x, y) t_0 = hypot(x, Float64(y * 2.0)) return Float64(Float64(fma(y, 2.0, x) / t_0) * Float64(Float64(x + Float64(y * -2.0)) / t_0)) end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t\_0} \cdot \frac{x + y \cdot -2}{t\_0}
\end{array}
\end{array}
Initial program 51.1%
add-sqr-sqrt51.1%
difference-of-squares51.2%
*-commutative51.2%
associate-*r*51.2%
sqrt-prod51.2%
sqrt-unprod27.3%
add-sqr-sqrt38.3%
metadata-eval38.3%
*-commutative38.3%
associate-*r*38.3%
sqrt-prod38.3%
sqrt-unprod27.3%
add-sqr-sqrt51.2%
metadata-eval51.2%
Applied egg-rr51.2%
add-sqr-sqrt51.2%
times-frac52.5%
+-commutative52.5%
fma-define52.5%
add-sqr-sqrt52.5%
hypot-define52.5%
sqrt-prod28.0%
*-commutative28.0%
sqrt-prod28.0%
metadata-eval28.0%
associate-*r*28.0%
add-sqr-sqrt52.5%
*-commutative52.5%
Applied egg-rr100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 0.0)
(* (/ (+ x (* y -2.0)) (hypot x (* y 2.0))) (+ 1.0 (* 2.0 (/ y x))))
(if (<= t_0 2e+263)
(/ (* (+ x (* y 2.0)) (- x (* y 2.0))) (+ t_0 (* x x)))
(+ (* 0.5 (* (/ x y) (/ x y))) -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = ((x + (y * -2.0)) / hypot(x, (y * 2.0))) * (1.0 + (2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = ((x + (y * -2.0)) / Math.hypot(x, (y * 2.0))) * (1.0 + (2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 0.0: tmp = ((x + (y * -2.0)) / math.hypot(x, (y * 2.0))) * (1.0 + (2.0 * (y / x))) elif t_0 <= 2e+263: tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x)) else: tmp = (0.5 * ((x / y) * (x / y))) + -1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(Float64(x + Float64(y * -2.0)) / hypot(x, Float64(y * 2.0))) * Float64(1.0 + Float64(2.0 * Float64(y / x)))); elseif (t_0 <= 2e+263) tmp = Float64(Float64(Float64(x + Float64(y * 2.0)) * Float64(x - Float64(y * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y) * Float64(x / y))) + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 0.0) tmp = ((x + (y * -2.0)) / hypot(x, (y * 2.0))) * (1.0 + (2.0 * (y / x))); elseif (t_0 <= 2e+263) tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x)); else tmp = (0.5 * ((x / y) * (x / y))) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+263], N[(N[(N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \left(1 + 2 \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;\frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 0.0Initial program 53.8%
add-sqr-sqrt53.8%
difference-of-squares53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
Applied egg-rr53.8%
add-sqr-sqrt53.8%
times-frac54.7%
+-commutative54.7%
fma-define54.7%
add-sqr-sqrt54.7%
hypot-define54.7%
sqrt-prod31.4%
*-commutative31.4%
sqrt-prod31.4%
metadata-eval31.4%
associate-*r*31.4%
add-sqr-sqrt54.7%
*-commutative54.7%
Applied egg-rr100.0%
Taylor expanded in y around 0 43.7%
if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 2.00000000000000003e263Initial program 76.9%
add-sqr-sqrt76.9%
difference-of-squares76.9%
*-commutative76.9%
associate-*r*76.9%
sqrt-prod76.9%
sqrt-unprod40.0%
add-sqr-sqrt51.4%
metadata-eval51.4%
*-commutative51.4%
associate-*r*51.4%
sqrt-prod51.4%
sqrt-unprod40.0%
add-sqr-sqrt76.9%
metadata-eval76.9%
Applied egg-rr76.9%
if 2.00000000000000003e263 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 8.1%
Taylor expanded in x around 0 74.4%
pow274.4%
unpow274.4%
times-frac92.5%
Applied egg-rr92.5%
Final simplification73.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 0.0)
(* (+ 1.0 (* 2.0 (/ y x))) (+ 1.0 (* -2.0 (/ y x))))
(if (<= t_0 2e+263)
(/ (* (+ x (* y 2.0)) (- x (* y 2.0))) (+ t_0 (* x x)))
(+ (* 0.5 (* (/ x y) (/ x y))) -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (t_0 <= 0.0d0) then
tmp = (1.0d0 + (2.0d0 * (y / x))) * (1.0d0 + ((-2.0d0) * (y / x)))
else if (t_0 <= 2d+263) then
tmp = ((x + (y * 2.0d0)) * (x - (y * 2.0d0))) / (t_0 + (x * x))
else
tmp = (0.5d0 * ((x / y) * (x / y))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 0.0: tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))) elif t_0 <= 2e+263: tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x)) else: tmp = (0.5 * ((x / y) * (x / y))) + -1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(1.0 + Float64(2.0 * Float64(y / x))) * Float64(1.0 + Float64(-2.0 * Float64(y / x)))); elseif (t_0 <= 2e+263) tmp = Float64(Float64(Float64(x + Float64(y * 2.0)) * Float64(x - Float64(y * 2.0))) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y) * Float64(x / y))) + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 0.0) tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))); elseif (t_0 <= 2e+263) tmp = ((x + (y * 2.0)) * (x - (y * 2.0))) / (t_0 + (x * x)); else tmp = (0.5 * ((x / y) * (x / y))) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 + N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+263], N[(N[(N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left(1 + 2 \cdot \frac{y}{x}\right) \cdot \left(1 + -2 \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;\frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 0.0Initial program 53.8%
add-sqr-sqrt53.8%
difference-of-squares53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
Applied egg-rr53.8%
add-sqr-sqrt53.8%
times-frac54.7%
+-commutative54.7%
fma-define54.7%
add-sqr-sqrt54.7%
hypot-define54.7%
sqrt-prod31.4%
*-commutative31.4%
sqrt-prod31.4%
metadata-eval31.4%
associate-*r*31.4%
add-sqr-sqrt54.7%
*-commutative54.7%
Applied egg-rr100.0%
Taylor expanded in y around 0 43.7%
Taylor expanded in x around inf 91.1%
if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 2.00000000000000003e263Initial program 76.9%
add-sqr-sqrt76.9%
difference-of-squares76.9%
*-commutative76.9%
associate-*r*76.9%
sqrt-prod76.9%
sqrt-unprod40.0%
add-sqr-sqrt51.4%
metadata-eval51.4%
*-commutative51.4%
associate-*r*51.4%
sqrt-prod51.4%
sqrt-unprod40.0%
add-sqr-sqrt76.9%
metadata-eval76.9%
Applied egg-rr76.9%
if 2.00000000000000003e263 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 8.1%
Taylor expanded in x around 0 74.4%
pow274.4%
unpow274.4%
times-frac92.5%
Applied egg-rr92.5%
Final simplification85.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 0.0)
(* (+ 1.0 (* 2.0 (/ y x))) (+ 1.0 (* -2.0 (/ y x))))
(if (<= t_0 2e+263)
(/ (- (* x x) t_0) (+ t_0 (* x x)))
(+ (* 0.5 (* (/ x y) (/ x y))) -1.0)))))
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (t_0 <= 0.0d0) then
tmp = (1.0d0 + (2.0d0 * (y / x))) * (1.0d0 + ((-2.0d0) * (y / x)))
else if (t_0 <= 2d+263) then
tmp = ((x * x) - t_0) / (t_0 + (x * x))
else
tmp = (0.5d0 * ((x / y) * (x / y))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if (t_0 <= 2e+263) {
tmp = ((x * x) - t_0) / (t_0 + (x * x));
} else {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 0.0: tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))) elif t_0 <= 2e+263: tmp = ((x * x) - t_0) / (t_0 + (x * x)) else: tmp = (0.5 * ((x / y) * (x / y))) + -1.0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(1.0 + Float64(2.0 * Float64(y / x))) * Float64(1.0 + Float64(-2.0 * Float64(y / x)))); elseif (t_0 <= 2e+263) tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x))); else tmp = Float64(Float64(0.5 * Float64(Float64(x / y) * Float64(x / y))) + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 0.0) tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))); elseif (t_0 <= 2e+263) tmp = ((x * x) - t_0) / (t_0 + (x * x)); else tmp = (0.5 * ((x / y) * (x / y))) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 + N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+263], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left(1 + 2 \cdot \frac{y}{x}\right) \cdot \left(1 + -2 \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;\frac{x \cdot x - t\_0}{t\_0 + x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 0.0Initial program 53.8%
add-sqr-sqrt53.8%
difference-of-squares53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
*-commutative53.8%
associate-*r*53.8%
sqrt-prod53.8%
sqrt-unprod30.8%
add-sqr-sqrt53.8%
metadata-eval53.8%
Applied egg-rr53.8%
add-sqr-sqrt53.8%
times-frac54.7%
+-commutative54.7%
fma-define54.7%
add-sqr-sqrt54.7%
hypot-define54.7%
sqrt-prod31.4%
*-commutative31.4%
sqrt-prod31.4%
metadata-eval31.4%
associate-*r*31.4%
add-sqr-sqrt54.7%
*-commutative54.7%
Applied egg-rr100.0%
Taylor expanded in y around 0 43.7%
Taylor expanded in x around inf 91.1%
if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 2.00000000000000003e263Initial program 76.9%
if 2.00000000000000003e263 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 8.1%
Taylor expanded in x around 0 74.4%
pow274.4%
unpow274.4%
times-frac92.5%
Applied egg-rr92.5%
Final simplification85.0%
(FPCore (x y)
:precision binary64
(if (<= y 6.2e-155)
1.0
(if (or (<= y 9e-109)
(and (not (<= y 1.6e-45))
(or (<= y 1.75e+108) (not (<= y 9.2e+119)))))
(+ (* 0.5 (* (/ x y) (/ x y))) -1.0)
1.0)))
double code(double x, double y) {
double tmp;
if (y <= 6.2e-155) {
tmp = 1.0;
} else if ((y <= 9e-109) || (!(y <= 1.6e-45) && ((y <= 1.75e+108) || !(y <= 9.2e+119)))) {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 6.2d-155) then
tmp = 1.0d0
else if ((y <= 9d-109) .or. (.not. (y <= 1.6d-45)) .and. (y <= 1.75d+108) .or. (.not. (y <= 9.2d+119))) then
tmp = (0.5d0 * ((x / y) * (x / y))) + (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 6.2e-155) {
tmp = 1.0;
} else if ((y <= 9e-109) || (!(y <= 1.6e-45) && ((y <= 1.75e+108) || !(y <= 9.2e+119)))) {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.2e-155: tmp = 1.0 elif (y <= 9e-109) or (not (y <= 1.6e-45) and ((y <= 1.75e+108) or not (y <= 9.2e+119))): tmp = (0.5 * ((x / y) * (x / y))) + -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 6.2e-155) tmp = 1.0; elseif ((y <= 9e-109) || (!(y <= 1.6e-45) && ((y <= 1.75e+108) || !(y <= 9.2e+119)))) tmp = Float64(Float64(0.5 * Float64(Float64(x / y) * Float64(x / y))) + -1.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 6.2e-155) tmp = 1.0; elseif ((y <= 9e-109) || (~((y <= 1.6e-45)) && ((y <= 1.75e+108) || ~((y <= 9.2e+119))))) tmp = (0.5 * ((x / y) * (x / y))) + -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.2e-155], 1.0, If[Or[LessEqual[y, 9e-109], And[N[Not[LessEqual[y, 1.6e-45]], $MachinePrecision], Or[LessEqual[y, 1.75e+108], N[Not[LessEqual[y, 9.2e+119]], $MachinePrecision]]]], N[(N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{-155}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-109} \lor \neg \left(y \leq 1.6 \cdot 10^{-45}\right) \land \left(y \leq 1.75 \cdot 10^{+108} \lor \neg \left(y \leq 9.2 \cdot 10^{+119}\right)\right):\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < 6.2e-155 or 9.0000000000000002e-109 < y < 1.60000000000000004e-45 or 1.7500000000000001e108 < y < 9.2000000000000003e119Initial program 53.4%
Taylor expanded in x around inf 59.1%
if 6.2e-155 < y < 9.0000000000000002e-109 or 1.60000000000000004e-45 < y < 1.7500000000000001e108 or 9.2000000000000003e119 < y Initial program 46.2%
Taylor expanded in x around 0 72.3%
pow272.3%
unpow272.3%
times-frac79.0%
Applied egg-rr79.0%
Final simplification65.3%
(FPCore (x y)
:precision binary64
(if (<= y 1.6e-45)
(* (+ 1.0 (* 2.0 (/ y x))) (+ 1.0 (* -2.0 (/ y x))))
(if (or (<= y 1.75e+108) (not (<= y 9.2e+119)))
(+ (* 0.5 (* (/ x y) (/ x y))) -1.0)
1.0)))
double code(double x, double y) {
double tmp;
if (y <= 1.6e-45) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if ((y <= 1.75e+108) || !(y <= 9.2e+119)) {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.6d-45) then
tmp = (1.0d0 + (2.0d0 * (y / x))) * (1.0d0 + ((-2.0d0) * (y / x)))
else if ((y <= 1.75d+108) .or. (.not. (y <= 9.2d+119))) then
tmp = (0.5d0 * ((x / y) * (x / y))) + (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.6e-45) {
tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x)));
} else if ((y <= 1.75e+108) || !(y <= 9.2e+119)) {
tmp = (0.5 * ((x / y) * (x / y))) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.6e-45: tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))) elif (y <= 1.75e+108) or not (y <= 9.2e+119): tmp = (0.5 * ((x / y) * (x / y))) + -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.6e-45) tmp = Float64(Float64(1.0 + Float64(2.0 * Float64(y / x))) * Float64(1.0 + Float64(-2.0 * Float64(y / x)))); elseif ((y <= 1.75e+108) || !(y <= 9.2e+119)) tmp = Float64(Float64(0.5 * Float64(Float64(x / y) * Float64(x / y))) + -1.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.6e-45) tmp = (1.0 + (2.0 * (y / x))) * (1.0 + (-2.0 * (y / x))); elseif ((y <= 1.75e+108) || ~((y <= 9.2e+119))) tmp = (0.5 * ((x / y) * (x / y))) + -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.6e-45], N[(N[(1.0 + N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.75e+108], N[Not[LessEqual[y, 9.2e+119]], $MachinePrecision]], N[(N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-45}:\\
\;\;\;\;\left(1 + 2 \cdot \frac{y}{x}\right) \cdot \left(1 + -2 \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+108} \lor \neg \left(y \leq 9.2 \cdot 10^{+119}\right):\\
\;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < 1.60000000000000004e-45Initial program 55.6%
add-sqr-sqrt55.6%
difference-of-squares55.7%
*-commutative55.7%
associate-*r*55.7%
sqrt-prod55.7%
sqrt-unprod22.7%
add-sqr-sqrt37.9%
metadata-eval37.9%
*-commutative37.9%
associate-*r*37.9%
sqrt-prod37.9%
sqrt-unprod22.7%
add-sqr-sqrt55.7%
metadata-eval55.7%
Applied egg-rr55.7%
add-sqr-sqrt55.7%
times-frac56.8%
+-commutative56.8%
fma-define56.8%
add-sqr-sqrt56.8%
hypot-define56.8%
sqrt-prod23.0%
*-commutative23.0%
sqrt-prod23.0%
metadata-eval23.0%
associate-*r*23.0%
add-sqr-sqrt56.8%
*-commutative56.8%
Applied egg-rr100.0%
Taylor expanded in y around 0 29.7%
Taylor expanded in x around inf 58.7%
if 1.60000000000000004e-45 < y < 1.7500000000000001e108 or 9.2000000000000003e119 < y Initial program 39.1%
Taylor expanded in x around 0 73.3%
pow273.3%
unpow273.3%
times-frac81.2%
Applied egg-rr81.2%
if 1.7500000000000001e108 < y < 9.2000000000000003e119Initial program 50.0%
Taylor expanded in x around inf 100.0%
Final simplification65.1%
(FPCore (x y) :precision binary64 (if (<= y 8e-46) 1.0 (if (<= y 7e+107) -1.0 (if (<= y 9.2e+119) 1.0 -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 8e-46) {
tmp = 1.0;
} else if (y <= 7e+107) {
tmp = -1.0;
} else if (y <= 9.2e+119) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 8d-46) then
tmp = 1.0d0
else if (y <= 7d+107) then
tmp = -1.0d0
else if (y <= 9.2d+119) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8e-46) {
tmp = 1.0;
} else if (y <= 7e+107) {
tmp = -1.0;
} else if (y <= 9.2e+119) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e-46: tmp = 1.0 elif y <= 7e+107: tmp = -1.0 elif y <= 9.2e+119: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 8e-46) tmp = 1.0; elseif (y <= 7e+107) tmp = -1.0; elseif (y <= 9.2e+119) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8e-46) tmp = 1.0; elseif (y <= 7e+107) tmp = -1.0; elseif (y <= 9.2e+119) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e-46], 1.0, If[LessEqual[y, 7e+107], -1.0, If[LessEqual[y, 9.2e+119], 1.0, -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-46}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+107}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+119}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 8.00000000000000018e-46 or 6.9999999999999995e107 < y < 9.2000000000000003e119Initial program 55.6%
Taylor expanded in x around inf 57.8%
if 8.00000000000000018e-46 < y < 6.9999999999999995e107 or 9.2000000000000003e119 < y Initial program 39.1%
Taylor expanded in x around 0 80.4%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 51.1%
Taylor expanded in x around 0 52.4%
(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 2024091
(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))))