
(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 9 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) (FPCore (x_m y) :precision binary64 (let* ((t_0 (hypot x_m (* y 2.0)))) (/ (/ (fma y 2.0 x_m) (/ t_0 (+ x_m (* y -2.0)))) t_0)))
x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = hypot(x_m, (y * 2.0));
return (fma(y, 2.0, x_m) / (t_0 / (x_m + (y * -2.0)))) / t_0;
}
x_m = abs(x) function code(x_m, y) t_0 = hypot(x_m, Float64(y * 2.0)) return Float64(Float64(fma(y, 2.0, x_m) / Float64(t_0 / Float64(x_m + Float64(y * -2.0)))) / t_0) end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[Sqrt[x$95$m ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x$95$m), $MachinePrecision] / N[(t$95$0 / N[(x$95$m + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x_m, y \cdot 2\right)\\
\frac{\frac{\mathsf{fma}\left(y, 2, x_m\right)}{\frac{t_0}{x_m + y \cdot -2}}}{t_0}
\end{array}
\end{array}
Initial program 50.8%
add-sqr-sqrt50.8%
difference-of-squares50.8%
*-commutative50.8%
associate-*r*50.8%
sqrt-prod50.8%
sqrt-unprod23.7%
add-sqr-sqrt37.5%
metadata-eval37.5%
*-commutative37.5%
associate-*r*37.5%
sqrt-prod37.5%
sqrt-unprod23.7%
add-sqr-sqrt50.8%
metadata-eval50.8%
Applied egg-rr50.8%
*-un-lft-identity50.8%
*-commutative50.8%
fma-udef50.8%
add-sqr-sqrt50.8%
times-frac50.6%
Applied egg-rr51.8%
associate-*l/51.9%
*-lft-identity51.9%
associate-/l*100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 4e-149)
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))
(if (<= t_0 1e+280)
(*
(fma y 2.0 x_m)
(/ (+ x_m (* y -2.0)) (pow (hypot x_m (* y 2.0)) 2.0)))
(fma 0.125 (pow (/ x_m y) 2.0) -1.0)))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = fma(y, 2.0, x_m) * ((x_m + (y * -2.0)) / pow(hypot(x_m, (y * 2.0)), 2.0));
} else {
tmp = fma(0.125, pow((x_m / y), 2.0), -1.0);
}
return tmp;
}
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 4e-149) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (t_0 <= 1e+280) tmp = Float64(fma(y, 2.0, x_m) * Float64(Float64(x_m + Float64(y * -2.0)) / (hypot(x_m, Float64(y * 2.0)) ^ 2.0))); else tmp = fma(0.125, (Float64(x_m / y) ^ 2.0), -1.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-149], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+280], N[(N[(y * 2.0 + x$95$m), $MachinePrecision] * N[(N[(x$95$m + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / N[Power[N[Sqrt[x$95$m ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.125 * N[Power[N[(x$95$m / y), $MachinePrecision], 2.0], $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-149}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+280}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, x_m\right) \cdot \frac{x_m + y \cdot -2}{{\left(\mathsf{hypot}\left(x_m, y \cdot 2\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.125, {\left(\frac{x_m}{y}\right)}^{2}, -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 3.99999999999999992e-149Initial program 55.6%
Taylor expanded in y around 0 75.8%
pow275.8%
unpow275.8%
times-frac85.3%
Applied egg-rr85.3%
if 3.99999999999999992e-149 < (*.f64 (*.f64 y 4) y) < 1e280Initial program 77.2%
add-sqr-sqrt77.2%
difference-of-squares77.2%
*-commutative77.2%
associate-*r*77.2%
sqrt-prod77.2%
sqrt-unprod37.1%
add-sqr-sqrt46.4%
metadata-eval46.4%
*-commutative46.4%
associate-*r*46.4%
sqrt-prod46.4%
sqrt-unprod37.1%
add-sqr-sqrt77.2%
metadata-eval77.2%
Applied egg-rr77.2%
*-commutative77.2%
fma-udef77.2%
add-sqr-sqrt17.0%
Applied egg-rr17.7%
times-frac17.0%
rem-square-sqrt77.2%
unpow277.2%
associate-*r/77.7%
*-commutative77.7%
cancel-sign-sub-inv77.7%
metadata-eval77.7%
Simplified77.7%
if 1e280 < (*.f64 (*.f64 y 4) y) Initial program 4.8%
add-sqr-sqrt4.8%
difference-of-squares4.8%
*-commutative4.8%
associate-*r*4.8%
sqrt-prod4.8%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
metadata-eval0.1%
*-commutative0.1%
associate-*r*0.1%
sqrt-prod0.1%
sqrt-unprod0.0%
add-sqr-sqrt4.8%
metadata-eval4.8%
Applied egg-rr4.8%
*-un-lft-identity4.8%
*-commutative4.8%
fma-udef4.8%
add-sqr-sqrt4.8%
times-frac4.8%
Applied egg-rr7.8%
associate-*l/7.8%
*-lft-identity7.8%
associate-/l*100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 37.0%
*-commutative37.0%
Simplified37.0%
Taylor expanded in y around inf 69.5%
fma-neg69.5%
unpow269.5%
unpow269.5%
times-frac84.4%
unpow284.4%
metadata-eval84.4%
Simplified84.4%
Final simplification82.5%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 4e-149)
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))
(if (<= t_0 1e+280)
(/ (* (+ x_m (* y 2.0)) (- x_m (* y 2.0))) (+ t_0 (* x_m x_m)))
(fma 0.125 (pow (/ x_m y) 2.0) -1.0)))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m));
} else {
tmp = fma(0.125, pow((x_m / y), 2.0), -1.0);
}
return tmp;
}
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 4e-149) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (t_0 <= 1e+280) tmp = Float64(Float64(Float64(x_m + Float64(y * 2.0)) * Float64(x_m - Float64(y * 2.0))) / Float64(t_0 + Float64(x_m * x_m))); else tmp = fma(0.125, (Float64(x_m / y) ^ 2.0), -1.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-149], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+280], N[(N[(N[(x$95$m + N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.125 * N[Power[N[(x$95$m / y), $MachinePrecision], 2.0], $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-149}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+280}:\\
\;\;\;\;\frac{\left(x_m + y \cdot 2\right) \cdot \left(x_m - y \cdot 2\right)}{t_0 + x_m \cdot x_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.125, {\left(\frac{x_m}{y}\right)}^{2}, -1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 3.99999999999999992e-149Initial program 55.6%
Taylor expanded in y around 0 75.8%
pow275.8%
unpow275.8%
times-frac85.3%
Applied egg-rr85.3%
if 3.99999999999999992e-149 < (*.f64 (*.f64 y 4) y) < 1e280Initial program 77.2%
add-sqr-sqrt77.2%
difference-of-squares77.2%
*-commutative77.2%
associate-*r*77.2%
sqrt-prod77.2%
sqrt-unprod37.1%
add-sqr-sqrt46.4%
metadata-eval46.4%
*-commutative46.4%
associate-*r*46.4%
sqrt-prod46.4%
sqrt-unprod37.1%
add-sqr-sqrt77.2%
metadata-eval77.2%
Applied egg-rr77.2%
if 1e280 < (*.f64 (*.f64 y 4) y) Initial program 4.8%
add-sqr-sqrt4.8%
difference-of-squares4.8%
*-commutative4.8%
associate-*r*4.8%
sqrt-prod4.8%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
metadata-eval0.1%
*-commutative0.1%
associate-*r*0.1%
sqrt-prod0.1%
sqrt-unprod0.0%
add-sqr-sqrt4.8%
metadata-eval4.8%
Applied egg-rr4.8%
*-un-lft-identity4.8%
*-commutative4.8%
fma-udef4.8%
add-sqr-sqrt4.8%
times-frac4.8%
Applied egg-rr7.8%
associate-*l/7.8%
*-lft-identity7.8%
associate-/l*100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 37.0%
*-commutative37.0%
Simplified37.0%
Taylor expanded in y around inf 69.5%
fma-neg69.5%
unpow269.5%
unpow269.5%
times-frac84.4%
unpow284.4%
metadata-eval84.4%
Simplified84.4%
Final simplification82.3%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 4e-149)
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))
(if (<= t_0 1e+280)
(/ (* (+ x_m (* y 2.0)) (- x_m (* y 2.0))) (+ t_0 (* x_m x_m)))
(/ (* y -2.0) (hypot x_m (* y 2.0)))))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m));
} else {
tmp = (y * -2.0) / hypot(x_m, (y * 2.0));
}
return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m));
} else {
tmp = (y * -2.0) / Math.hypot(x_m, (y * 2.0));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 4e-149: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) elif t_0 <= 1e+280: tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m)) else: tmp = (y * -2.0) / math.hypot(x_m, (y * 2.0)) return tmp
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 4e-149) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (t_0 <= 1e+280) tmp = Float64(Float64(Float64(x_m + Float64(y * 2.0)) * Float64(x_m - Float64(y * 2.0))) / Float64(t_0 + Float64(x_m * x_m))); else tmp = Float64(Float64(y * -2.0) / hypot(x_m, Float64(y * 2.0))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 4e-149) tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); elseif (t_0 <= 1e+280) tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m)); else tmp = (y * -2.0) / hypot(x_m, (y * 2.0)); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-149], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+280], N[(N[(N[(x$95$m + N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * -2.0), $MachinePrecision] / N[Sqrt[x$95$m ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-149}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+280}:\\
\;\;\;\;\frac{\left(x_m + y \cdot 2\right) \cdot \left(x_m - y \cdot 2\right)}{t_0 + x_m \cdot x_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot -2}{\mathsf{hypot}\left(x_m, y \cdot 2\right)}\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 3.99999999999999992e-149Initial program 55.6%
Taylor expanded in y around 0 75.8%
pow275.8%
unpow275.8%
times-frac85.3%
Applied egg-rr85.3%
if 3.99999999999999992e-149 < (*.f64 (*.f64 y 4) y) < 1e280Initial program 77.2%
add-sqr-sqrt77.2%
difference-of-squares77.2%
*-commutative77.2%
associate-*r*77.2%
sqrt-prod77.2%
sqrt-unprod37.1%
add-sqr-sqrt46.4%
metadata-eval46.4%
*-commutative46.4%
associate-*r*46.4%
sqrt-prod46.4%
sqrt-unprod37.1%
add-sqr-sqrt77.2%
metadata-eval77.2%
Applied egg-rr77.2%
if 1e280 < (*.f64 (*.f64 y 4) y) Initial program 4.8%
add-sqr-sqrt4.8%
difference-of-squares4.8%
*-commutative4.8%
associate-*r*4.8%
sqrt-prod4.8%
sqrt-unprod0.0%
add-sqr-sqrt0.1%
metadata-eval0.1%
*-commutative0.1%
associate-*r*0.1%
sqrt-prod0.1%
sqrt-unprod0.0%
add-sqr-sqrt4.8%
metadata-eval4.8%
Applied egg-rr4.8%
*-un-lft-identity4.8%
*-commutative4.8%
fma-udef4.8%
add-sqr-sqrt4.8%
times-frac4.8%
Applied egg-rr7.8%
associate-*l/7.8%
*-lft-identity7.8%
associate-/l*100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 37.0%
*-commutative37.0%
Simplified37.0%
Final simplification70.8%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 4e-149)
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))
(if (<= t_0 1e+280)
(/ (* (+ x_m (* y 2.0)) (- x_m (* y 2.0))) (+ t_0 (* x_m x_m)))
-1.0))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m));
} else {
tmp = -1.0;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (t_0 <= 4d-149) then
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
else if (t_0 <= 1d+280) then
tmp = ((x_m + (y * 2.0d0)) * (x_m - (y * 2.0d0))) / (t_0 + (x_m * x_m))
else
tmp = -1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m));
} else {
tmp = -1.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 4e-149: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) elif t_0 <= 1e+280: tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m)) else: tmp = -1.0 return tmp
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 4e-149) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (t_0 <= 1e+280) tmp = Float64(Float64(Float64(x_m + Float64(y * 2.0)) * Float64(x_m - Float64(y * 2.0))) / Float64(t_0 + Float64(x_m * x_m))); else tmp = -1.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 4e-149) tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); elseif (t_0 <= 1e+280) tmp = ((x_m + (y * 2.0)) * (x_m - (y * 2.0))) / (t_0 + (x_m * x_m)); else tmp = -1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-149], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+280], N[(N[(N[(x$95$m + N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-149}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+280}:\\
\;\;\;\;\frac{\left(x_m + y \cdot 2\right) \cdot \left(x_m - y \cdot 2\right)}{t_0 + x_m \cdot x_m}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 3.99999999999999992e-149Initial program 55.6%
Taylor expanded in y around 0 75.8%
pow275.8%
unpow275.8%
times-frac85.3%
Applied egg-rr85.3%
if 3.99999999999999992e-149 < (*.f64 (*.f64 y 4) y) < 1e280Initial program 77.2%
add-sqr-sqrt77.2%
difference-of-squares77.2%
*-commutative77.2%
associate-*r*77.2%
sqrt-prod77.2%
sqrt-unprod37.1%
add-sqr-sqrt46.4%
metadata-eval46.4%
*-commutative46.4%
associate-*r*46.4%
sqrt-prod46.4%
sqrt-unprod37.1%
add-sqr-sqrt77.2%
metadata-eval77.2%
Applied egg-rr77.2%
if 1e280 < (*.f64 (*.f64 y 4) y) Initial program 4.8%
Taylor expanded in x around 0 83.8%
Final simplification82.2%
x_m = (fabs.f64 x)
(FPCore (x_m y)
:precision binary64
(let* ((t_0 (* y (* y 4.0))))
(if (<= t_0 4e-149)
(+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m))))
(if (<= t_0 1e+280) (/ (- (* x_m x_m) t_0) (+ t_0 (* x_m x_m))) -1.0))))x_m = fabs(x);
double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m));
} else {
tmp = -1.0;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (y * 4.0d0)
if (t_0 <= 4d-149) then
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
else if (t_0 <= 1d+280) then
tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m))
else
tmp = -1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double t_0 = y * (y * 4.0);
double tmp;
if (t_0 <= 4e-149) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (t_0 <= 1e+280) {
tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m));
} else {
tmp = -1.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): t_0 = y * (y * 4.0) tmp = 0 if t_0 <= 4e-149: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) elif t_0 <= 1e+280: tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m)) else: tmp = -1.0 return tmp
x_m = abs(x) function code(x_m, y) t_0 = Float64(y * Float64(y * 4.0)) tmp = 0.0 if (t_0 <= 4e-149) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (t_0 <= 1e+280) tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(t_0 + Float64(x_m * x_m))); else tmp = -1.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) t_0 = y * (y * 4.0); tmp = 0.0; if (t_0 <= 4e-149) tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); elseif (t_0 <= 1e+280) tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m)); else tmp = -1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-149], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+280], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-149}:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+280}:\\
\;\;\;\;\frac{x_m \cdot x_m - t_0}{t_0 + x_m \cdot x_m}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if (*.f64 (*.f64 y 4) y) < 3.99999999999999992e-149Initial program 55.6%
Taylor expanded in y around 0 75.8%
pow275.8%
unpow275.8%
times-frac85.3%
Applied egg-rr85.3%
if 3.99999999999999992e-149 < (*.f64 (*.f64 y 4) y) < 1e280Initial program 77.2%
if 1e280 < (*.f64 (*.f64 y 4) y) Initial program 4.8%
Taylor expanded in x around 0 83.8%
Final simplification82.2%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= y 0.29) 1.0 (if (<= y 2e+42) -1.0 (if (<= y 1.1e+49) 1.0 -1.0))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (y <= 0.29) {
tmp = 1.0;
} else if (y <= 2e+42) {
tmp = -1.0;
} else if (y <= 1.1e+49) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.29d0) then
tmp = 1.0d0
else if (y <= 2d+42) then
tmp = -1.0d0
else if (y <= 1.1d+49) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (y <= 0.29) {
tmp = 1.0;
} else if (y <= 2e+42) {
tmp = -1.0;
} else if (y <= 1.1e+49) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if y <= 0.29: tmp = 1.0 elif y <= 2e+42: tmp = -1.0 elif y <= 1.1e+49: tmp = 1.0 else: tmp = -1.0 return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (y <= 0.29) tmp = 1.0; elseif (y <= 2e+42) tmp = -1.0; elseif (y <= 1.1e+49) tmp = 1.0; else tmp = -1.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (y <= 0.29) tmp = 1.0; elseif (y <= 2e+42) tmp = -1.0; elseif (y <= 1.1e+49) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[y, 0.29], 1.0, If[LessEqual[y, 2e+42], -1.0, If[LessEqual[y, 1.1e+49], 1.0, -1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.29:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+42}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+49}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 0.28999999999999998 or 2.00000000000000009e42 < y < 1.1e49Initial program 53.2%
Taylor expanded in x around inf 61.8%
if 0.28999999999999998 < y < 2.00000000000000009e42 or 1.1e49 < y Initial program 41.5%
Taylor expanded in x around 0 81.8%
Final simplification66.0%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 (if (<= y 0.35) (+ 1.0 (* -8.0 (* (/ y x_m) (/ y x_m)))) (if (<= y 2.55e+43) -1.0 (if (<= y 2e+48) 1.0 -1.0))))
x_m = fabs(x);
double code(double x_m, double y) {
double tmp;
if (y <= 0.35) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (y <= 2.55e+43) {
tmp = -1.0;
} else if (y <= 2e+48) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.35d0) then
tmp = 1.0d0 + ((-8.0d0) * ((y / x_m) * (y / x_m)))
else if (y <= 2.55d+43) then
tmp = -1.0d0
else if (y <= 2d+48) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
double tmp;
if (y <= 0.35) {
tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m)));
} else if (y <= 2.55e+43) {
tmp = -1.0;
} else if (y <= 2e+48) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y): tmp = 0 if y <= 0.35: tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))) elif y <= 2.55e+43: tmp = -1.0 elif y <= 2e+48: tmp = 1.0 else: tmp = -1.0 return tmp
x_m = abs(x) function code(x_m, y) tmp = 0.0 if (y <= 0.35) tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x_m) * Float64(y / x_m)))); elseif (y <= 2.55e+43) tmp = -1.0; elseif (y <= 2e+48) tmp = 1.0; else tmp = -1.0; end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y) tmp = 0.0; if (y <= 0.35) tmp = 1.0 + (-8.0 * ((y / x_m) * (y / x_m))); elseif (y <= 2.55e+43) tmp = -1.0; elseif (y <= 2e+48) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := If[LessEqual[y, 0.35], N[(1.0 + N[(-8.0 * N[(N[(y / x$95$m), $MachinePrecision] * N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.55e+43], -1.0, If[LessEqual[y, 2e+48], 1.0, -1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.35:\\
\;\;\;\;1 + -8 \cdot \left(\frac{y}{x_m} \cdot \frac{y}{x_m}\right)\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{+43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+48}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 0.34999999999999998Initial program 53.5%
Taylor expanded in y around 0 55.9%
pow255.9%
unpow255.9%
times-frac62.7%
Applied egg-rr62.7%
if 0.34999999999999998 < y < 2.54999999999999997e43 or 2.00000000000000009e48 < y Initial program 41.5%
Taylor expanded in x around 0 81.8%
if 2.54999999999999997e43 < y < 2.00000000000000009e48Initial program 33.3%
Taylor expanded in x around inf 100.0%
Final simplification67.1%
x_m = (fabs.f64 x) (FPCore (x_m y) :precision binary64 -1.0)
x_m = fabs(x);
double code(double x_m, double y) {
return -1.0;
}
x_m = abs(x)
real(8) function code(x_m, y)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
code = -1.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y) {
return -1.0;
}
x_m = math.fabs(x) def code(x_m, y): return -1.0
x_m = abs(x) function code(x_m, y) return -1.0 end
x_m = abs(x); function tmp = code(x_m, y) tmp = -1.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_] := -1.0
\begin{array}{l}
x_m = \left|x\right|
\\
-1
\end{array}
Initial program 50.8%
Taylor expanded in x around 0 47.2%
Final simplification47.2%
(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 2024024
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))