
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (if (<= x_m 2.7e-176) (pow (* c (* s_m x_m)) -2.0) (/ (/ (cos (* x_m 2.0)) (* x_m (* s_m c))) (* s_m (* x_m c)))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.7e-176) {
tmp = pow((c * (s_m * x_m)), -2.0);
} else {
tmp = (cos((x_m * 2.0)) / (x_m * (s_m * c))) / (s_m * (x_m * c));
}
return tmp;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 2.7d-176) then
tmp = (c * (s_m * x_m)) ** (-2.0d0)
else
tmp = (cos((x_m * 2.0d0)) / (x_m * (s_m * c))) / (s_m * (x_m * c))
end if
code = tmp
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.7e-176) {
tmp = Math.pow((c * (s_m * x_m)), -2.0);
} else {
tmp = (Math.cos((x_m * 2.0)) / (x_m * (s_m * c))) / (s_m * (x_m * c));
}
return tmp;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): tmp = 0 if x_m <= 2.7e-176: tmp = math.pow((c * (s_m * x_m)), -2.0) else: tmp = (math.cos((x_m * 2.0)) / (x_m * (s_m * c))) / (s_m * (x_m * c)) return tmp
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) tmp = 0.0 if (x_m <= 2.7e-176) tmp = Float64(c * Float64(s_m * x_m)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / Float64(x_m * Float64(s_m * c))) / Float64(s_m * Float64(x_m * c))); end return tmp end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp_2 = code(x_m, c, s_m)
tmp = 0.0;
if (x_m <= 2.7e-176)
tmp = (c * (s_m * x_m)) ^ -2.0;
else
tmp = (cos((x_m * 2.0)) / (x_m * (s_m * c))) / (s_m * (x_m * c));
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := If[LessEqual[x$95$m, 2.7e-176], N[Power[N[(c * N[(s$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * N[(s$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.7 \cdot 10^{-176}:\\
\;\;\;\;{\left(c \cdot \left(s\_m \cdot x\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{x\_m \cdot \left(s\_m \cdot c\right)}}{s\_m \cdot \left(x\_m \cdot c\right)}\\
\end{array}
\end{array}
if x < 2.6999999999999998e-176Initial program 63.3%
associate-/r*62.6%
*-commutative62.6%
unpow262.6%
sqr-neg62.6%
unpow262.6%
cos-neg62.6%
*-commutative62.6%
distribute-rgt-neg-in62.6%
metadata-eval62.6%
unpow262.6%
sqr-neg62.6%
unpow262.6%
associate-*r*59.3%
unpow259.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in x around 0 55.1%
associate-/r*54.4%
*-commutative54.4%
unpow254.4%
unpow254.4%
swap-sqr66.1%
unpow266.1%
associate-/r*66.8%
unpow266.8%
unpow266.8%
swap-sqr82.6%
unpow282.6%
Simplified82.6%
*-un-lft-identity82.6%
pow-flip83.0%
*-commutative83.0%
*-commutative83.0%
associate-*l*82.7%
metadata-eval82.7%
Applied egg-rr82.7%
*-lft-identity82.7%
associate-*r*83.0%
*-commutative83.0%
*-commutative83.0%
*-commutative83.0%
Simplified83.0%
if 2.6999999999999998e-176 < x Initial program 69.1%
Taylor expanded in x around inf 65.4%
associate-/r*65.3%
*-commutative65.3%
unpow265.3%
unpow265.3%
swap-sqr77.0%
unpow277.0%
associate-/r*77.1%
*-commutative77.1%
unpow277.1%
unpow277.1%
swap-sqr93.9%
unpow293.9%
*-commutative93.9%
associate-*l*98.6%
Simplified98.6%
*-commutative98.6%
associate-*r*93.9%
*-commutative93.9%
div-inv93.8%
*-commutative93.8%
pow-flip94.5%
*-commutative94.5%
*-commutative94.5%
associate-*l*99.7%
metadata-eval99.7%
*-commutative99.7%
Applied egg-rr99.7%
metadata-eval99.7%
pow-flip98.6%
unpow298.6%
associate-/r*99.7%
associate-*l/99.7%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in s around 0 94.5%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification89.4%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (if (<= x_m 1e-9) (pow (* c (* s_m x_m)) -2.0) (/ (cos (* x_m 2.0)) (* s_m (* (* x_m c) (* s_m (* x_m c)))))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 1e-9) {
tmp = pow((c * (s_m * x_m)), -2.0);
} else {
tmp = cos((x_m * 2.0)) / (s_m * ((x_m * c) * (s_m * (x_m * c))));
}
return tmp;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 1d-9) then
tmp = (c * (s_m * x_m)) ** (-2.0d0)
else
tmp = cos((x_m * 2.0d0)) / (s_m * ((x_m * c) * (s_m * (x_m * c))))
end if
code = tmp
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 1e-9) {
tmp = Math.pow((c * (s_m * x_m)), -2.0);
} else {
tmp = Math.cos((x_m * 2.0)) / (s_m * ((x_m * c) * (s_m * (x_m * c))));
}
return tmp;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): tmp = 0 if x_m <= 1e-9: tmp = math.pow((c * (s_m * x_m)), -2.0) else: tmp = math.cos((x_m * 2.0)) / (s_m * ((x_m * c) * (s_m * (x_m * c)))) return tmp
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) tmp = 0.0 if (x_m <= 1e-9) tmp = Float64(c * Float64(s_m * x_m)) ^ -2.0; else tmp = Float64(cos(Float64(x_m * 2.0)) / Float64(s_m * Float64(Float64(x_m * c) * Float64(s_m * Float64(x_m * c))))); end return tmp end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp_2 = code(x_m, c, s_m)
tmp = 0.0;
if (x_m <= 1e-9)
tmp = (c * (s_m * x_m)) ^ -2.0;
else
tmp = cos((x_m * 2.0)) / (s_m * ((x_m * c) * (s_m * (x_m * c))));
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := If[LessEqual[x$95$m, 1e-9], N[Power[N[(c * N[(s$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c), $MachinePrecision] * N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 10^{-9}:\\
\;\;\;\;{\left(c \cdot \left(s\_m \cdot x\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot 2\right)}{s\_m \cdot \left(\left(x\_m \cdot c\right) \cdot \left(s\_m \cdot \left(x\_m \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.00000000000000006e-9Initial program 64.4%
associate-/r*63.9%
*-commutative63.9%
unpow263.9%
sqr-neg63.9%
unpow263.9%
cos-neg63.9%
*-commutative63.9%
distribute-rgt-neg-in63.9%
metadata-eval63.9%
unpow263.9%
sqr-neg63.9%
unpow263.9%
associate-*r*61.2%
unpow261.2%
*-commutative61.2%
Simplified61.2%
Taylor expanded in x around 0 57.7%
associate-/r*57.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr68.3%
unpow268.3%
associate-/r*68.8%
unpow268.8%
unpow268.8%
swap-sqr85.4%
unpow285.4%
Simplified85.4%
*-un-lft-identity85.4%
pow-flip85.9%
*-commutative85.9%
*-commutative85.9%
associate-*l*85.6%
metadata-eval85.6%
Applied egg-rr85.6%
*-lft-identity85.6%
associate-*r*85.9%
*-commutative85.9%
*-commutative85.9%
*-commutative85.9%
Simplified85.9%
if 1.00000000000000006e-9 < x Initial program 68.6%
Taylor expanded in x around inf 62.9%
associate-/r*62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr76.1%
unpow276.1%
associate-/r*76.2%
*-commutative76.2%
unpow276.2%
unpow276.2%
swap-sqr91.3%
unpow291.3%
*-commutative91.3%
associate-*l*98.5%
Simplified98.5%
associate-*r*91.3%
*-commutative91.3%
unpow291.3%
associate-*r*91.3%
associate-*r*88.5%
*-commutative88.5%
*-commutative88.5%
associate-*l*95.7%
*-commutative95.7%
Applied egg-rr95.7%
Final simplification88.4%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (if (<= x_m 2.3e-12) (pow (* c (* s_m x_m)) -2.0) (/ (cos (* x_m 2.0)) (* (* x_m c) (* s_m (* s_m (* x_m c)))))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.3e-12) {
tmp = pow((c * (s_m * x_m)), -2.0);
} else {
tmp = cos((x_m * 2.0)) / ((x_m * c) * (s_m * (s_m * (x_m * c))));
}
return tmp;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 2.3d-12) then
tmp = (c * (s_m * x_m)) ** (-2.0d0)
else
tmp = cos((x_m * 2.0d0)) / ((x_m * c) * (s_m * (s_m * (x_m * c))))
end if
code = tmp
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.3e-12) {
tmp = Math.pow((c * (s_m * x_m)), -2.0);
} else {
tmp = Math.cos((x_m * 2.0)) / ((x_m * c) * (s_m * (s_m * (x_m * c))));
}
return tmp;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): tmp = 0 if x_m <= 2.3e-12: tmp = math.pow((c * (s_m * x_m)), -2.0) else: tmp = math.cos((x_m * 2.0)) / ((x_m * c) * (s_m * (s_m * (x_m * c)))) return tmp
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) tmp = 0.0 if (x_m <= 2.3e-12) tmp = Float64(c * Float64(s_m * x_m)) ^ -2.0; else tmp = Float64(cos(Float64(x_m * 2.0)) / Float64(Float64(x_m * c) * Float64(s_m * Float64(s_m * Float64(x_m * c))))); end return tmp end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp_2 = code(x_m, c, s_m)
tmp = 0.0;
if (x_m <= 2.3e-12)
tmp = (c * (s_m * x_m)) ^ -2.0;
else
tmp = cos((x_m * 2.0)) / ((x_m * c) * (s_m * (s_m * (x_m * c))));
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := If[LessEqual[x$95$m, 2.3e-12], N[Power[N[(c * N[(s$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x$95$m * c), $MachinePrecision] * N[(s$95$m * N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.3 \cdot 10^{-12}:\\
\;\;\;\;{\left(c \cdot \left(s\_m \cdot x\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot 2\right)}{\left(x\_m \cdot c\right) \cdot \left(s\_m \cdot \left(s\_m \cdot \left(x\_m \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.29999999999999989e-12Initial program 64.8%
associate-/r*64.2%
*-commutative64.2%
unpow264.2%
sqr-neg64.2%
unpow264.2%
cos-neg64.2%
*-commutative64.2%
distribute-rgt-neg-in64.2%
metadata-eval64.2%
unpow264.2%
sqr-neg64.2%
unpow264.2%
associate-*r*61.5%
unpow261.5%
*-commutative61.5%
Simplified61.5%
Taylor expanded in x around 0 57.9%
associate-/r*57.4%
*-commutative57.4%
unpow257.4%
unpow257.4%
swap-sqr68.6%
unpow268.6%
associate-/r*69.2%
unpow269.2%
unpow269.2%
swap-sqr85.3%
unpow285.3%
Simplified85.3%
*-un-lft-identity85.3%
pow-flip85.8%
*-commutative85.8%
*-commutative85.8%
associate-*l*85.5%
metadata-eval85.5%
Applied egg-rr85.5%
*-lft-identity85.5%
associate-*r*85.8%
*-commutative85.8%
*-commutative85.8%
*-commutative85.8%
Simplified85.8%
if 2.29999999999999989e-12 < x Initial program 67.6%
Taylor expanded in x around inf 62.0%
associate-/r*62.0%
*-commutative62.0%
unpow262.0%
unpow262.0%
swap-sqr75.0%
unpow275.0%
associate-/r*75.1%
*-commutative75.1%
unpow275.1%
unpow275.1%
swap-sqr91.4%
unpow291.4%
*-commutative91.4%
associate-*l*98.5%
Simplified98.5%
associate-*r*91.4%
*-commutative91.4%
unpow291.4%
associate-*r*91.5%
associate-*l*91.4%
*-commutative91.4%
*-commutative91.4%
*-commutative91.4%
associate-*l*95.7%
Applied egg-rr95.7%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (/ (* (/ (/ 1.0 s_m) (* x_m c)) (cos (* x_m 2.0))) (* s_m (* x_m c))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return (((1.0 / s_m) / (x_m * c)) * cos((x_m * 2.0))) / (s_m * (x_m * c));
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (((1.0d0 / s_m) / (x_m * c)) * cos((x_m * 2.0d0))) / (s_m * (x_m * c))
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return (((1.0 / s_m) / (x_m * c)) * Math.cos((x_m * 2.0))) / (s_m * (x_m * c));
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return (((1.0 / s_m) / (x_m * c)) * math.cos((x_m * 2.0))) / (s_m * (x_m * c))
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(Float64(Float64(Float64(1.0 / s_m) / Float64(x_m * c)) * cos(Float64(x_m * 2.0))) / Float64(s_m * Float64(x_m * c))) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = (((1.0 / s_m) / (x_m * c)) * cos((x_m * 2.0))) / (s_m * (x_m * c));
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[(N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / N[(x$95$m * c), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\frac{\frac{\frac{1}{s\_m}}{x\_m \cdot c} \cdot \cos \left(x\_m \cdot 2\right)}{s\_m \cdot \left(x\_m \cdot c\right)}
\end{array}
Initial program 65.5%
Taylor expanded in x around inf 62.0%
associate-/r*61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr74.1%
unpow274.1%
associate-/r*74.6%
*-commutative74.6%
unpow274.6%
unpow274.6%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*l*96.7%
Simplified96.7%
*-commutative96.7%
associate-*r*95.0%
*-commutative95.0%
div-inv95.0%
*-commutative95.0%
pow-flip95.5%
*-commutative95.5%
*-commutative95.5%
associate-*l*97.5%
metadata-eval97.5%
*-commutative97.5%
Applied egg-rr97.5%
metadata-eval97.5%
pow-flip96.9%
unpow296.9%
associate-/r*97.6%
associate-*l/97.6%
associate-/r*97.6%
Applied egg-rr97.6%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (let* ((t_0 (* s_m (* x_m c)))) (/ (/ (cos (* x_m 2.0)) t_0) t_0)))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double t_0 = s_m * (x_m * c);
return (cos((x_m * 2.0)) / t_0) / t_0;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = s_m * (x_m * c)
code = (cos((x_m * 2.0d0)) / t_0) / t_0
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double t_0 = s_m * (x_m * c);
return (Math.cos((x_m * 2.0)) / t_0) / t_0;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): t_0 = s_m * (x_m * c) return (math.cos((x_m * 2.0)) / t_0) / t_0
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) t_0 = Float64(s_m * Float64(x_m * c)) return Float64(Float64(cos(Float64(x_m * 2.0)) / t_0) / t_0) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
t_0 = s_m * (x_m * c);
tmp = (cos((x_m * 2.0)) / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x\_m \cdot c\right)\\
\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.5%
Taylor expanded in x around inf 62.0%
associate-/r*61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr74.1%
unpow274.1%
associate-/r*74.6%
*-commutative74.6%
unpow274.6%
unpow274.6%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*l*96.7%
Simplified96.7%
*-commutative96.7%
associate-*r*95.0%
*-commutative95.0%
div-inv95.0%
*-commutative95.0%
pow-flip95.5%
*-commutative95.5%
*-commutative95.5%
associate-*l*97.5%
metadata-eval97.5%
*-commutative97.5%
Applied egg-rr97.5%
metadata-eval97.5%
pow-pow97.5%
inv-pow97.5%
pow297.5%
frac-times96.9%
metadata-eval96.9%
unpow296.9%
associate-*l/96.9%
unpow296.9%
*-un-lft-identity96.9%
associate-/r*97.5%
Applied egg-rr97.5%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (pow (* c (* s_m x_m)) -2.0))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return pow((c * (s_m * x_m)), -2.0);
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (c * (s_m * x_m)) ** (-2.0d0)
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return Math.pow((c * (s_m * x_m)), -2.0);
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return math.pow((c * (s_m * x_m)), -2.0)
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(c * Float64(s_m * x_m)) ^ -2.0 end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = (c * (s_m * x_m)) ^ -2.0;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[Power[N[(c * N[(s$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
{\left(c \cdot \left(s\_m \cdot x\_m\right)\right)}^{-2}
\end{array}
Initial program 65.5%
associate-/r*65.1%
*-commutative65.1%
unpow265.1%
sqr-neg65.1%
unpow265.1%
cos-neg65.1%
*-commutative65.1%
distribute-rgt-neg-in65.1%
metadata-eval65.1%
unpow265.1%
sqr-neg65.1%
unpow265.1%
associate-*r*61.6%
unpow261.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in x around 0 57.7%
associate-/r*57.3%
*-commutative57.3%
unpow257.3%
unpow257.3%
swap-sqr66.3%
unpow266.3%
associate-/r*66.7%
unpow266.7%
unpow266.7%
swap-sqr80.9%
unpow280.9%
Simplified80.9%
*-un-lft-identity80.9%
pow-flip81.2%
*-commutative81.2%
*-commutative81.2%
associate-*l*81.2%
metadata-eval81.2%
Applied egg-rr81.2%
*-lft-identity81.2%
associate-*r*81.2%
*-commutative81.2%
*-commutative81.2%
*-commutative81.2%
Simplified81.2%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (/ (/ (/ 1.0 s_m) (* x_m c)) (* s_m (* x_m c))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return ((1.0 / s_m) / (x_m * c)) / (s_m * (x_m * c));
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = ((1.0d0 / s_m) / (x_m * c)) / (s_m * (x_m * c))
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return ((1.0 / s_m) / (x_m * c)) / (s_m * (x_m * c));
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return ((1.0 / s_m) / (x_m * c)) / (s_m * (x_m * c))
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(Float64(Float64(1.0 / s_m) / Float64(x_m * c)) / Float64(s_m * Float64(x_m * c))) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = ((1.0 / s_m) / (x_m * c)) / (s_m * (x_m * c));
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / N[(x$95$m * c), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\frac{\frac{\frac{1}{s\_m}}{x\_m \cdot c}}{s\_m \cdot \left(x\_m \cdot c\right)}
\end{array}
Initial program 65.5%
Taylor expanded in x around inf 62.0%
associate-/r*61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr74.1%
unpow274.1%
associate-/r*74.6%
*-commutative74.6%
unpow274.6%
unpow274.6%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*l*96.7%
Simplified96.7%
*-commutative96.7%
associate-*r*95.0%
*-commutative95.0%
div-inv95.0%
*-commutative95.0%
pow-flip95.5%
*-commutative95.5%
*-commutative95.5%
associate-*l*97.5%
metadata-eval97.5%
*-commutative97.5%
Applied egg-rr97.5%
metadata-eval97.5%
pow-flip96.9%
unpow296.9%
associate-/r*97.6%
associate-*l/97.6%
associate-/r*97.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 80.7%
*-commutative80.7%
associate-*r*81.1%
associate-/r*81.2%
Simplified81.2%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (/ (/ 1.0 (* c (* s_m x_m))) (* s_m (* x_m c))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return (1.0 / (c * (s_m * x_m))) / (s_m * (x_m * c));
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (1.0d0 / (c * (s_m * x_m))) / (s_m * (x_m * c))
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return (1.0 / (c * (s_m * x_m))) / (s_m * (x_m * c));
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return (1.0 / (c * (s_m * x_m))) / (s_m * (x_m * c))
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(Float64(1.0 / Float64(c * Float64(s_m * x_m))) / Float64(s_m * Float64(x_m * c))) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = (1.0 / (c * (s_m * x_m))) / (s_m * (x_m * c));
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[(N[(1.0 / N[(c * N[(s$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\frac{\frac{1}{c \cdot \left(s\_m \cdot x\_m\right)}}{s\_m \cdot \left(x\_m \cdot c\right)}
\end{array}
Initial program 65.5%
Taylor expanded in x around inf 62.0%
associate-/r*61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr74.1%
unpow274.1%
associate-/r*74.6%
*-commutative74.6%
unpow274.6%
unpow274.6%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*l*96.7%
Simplified96.7%
*-commutative96.7%
associate-*r*95.0%
*-commutative95.0%
div-inv95.0%
*-commutative95.0%
pow-flip95.5%
*-commutative95.5%
*-commutative95.5%
associate-*l*97.5%
metadata-eval97.5%
*-commutative97.5%
Applied egg-rr97.5%
metadata-eval97.5%
pow-flip96.9%
unpow296.9%
associate-/r*97.6%
associate-*l/97.6%
associate-/r*97.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 80.7%
*-commutative80.7%
Simplified80.7%
Final simplification80.7%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (/ 1.0 (* s_m (* (* x_m c) (* s_m (* x_m c))))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return 1.0 / (s_m * ((x_m * c) * (s_m * (x_m * c))));
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = 1.0d0 / (s_m * ((x_m * c) * (s_m * (x_m * c))))
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return 1.0 / (s_m * ((x_m * c) * (s_m * (x_m * c))));
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return 1.0 / (s_m * ((x_m * c) * (s_m * (x_m * c))))
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(1.0 / Float64(s_m * Float64(Float64(x_m * c) * Float64(s_m * Float64(x_m * c))))) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = 1.0 / (s_m * ((x_m * c) * (s_m * (x_m * c))));
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[(1.0 / N[(s$95$m * N[(N[(x$95$m * c), $MachinePrecision] * N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\frac{1}{s\_m \cdot \left(\left(x\_m \cdot c\right) \cdot \left(s\_m \cdot \left(x\_m \cdot c\right)\right)\right)}
\end{array}
Initial program 65.5%
Taylor expanded in x around inf 62.0%
associate-/r*61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr74.1%
unpow274.1%
associate-/r*74.6%
*-commutative74.6%
unpow274.6%
unpow274.6%
swap-sqr95.0%
unpow295.0%
*-commutative95.0%
associate-*l*96.7%
Simplified96.7%
associate-*r*95.0%
*-commutative95.0%
unpow295.0%
associate-*r*93.7%
associate-*r*90.3%
*-commutative90.3%
*-commutative90.3%
associate-*l*93.4%
*-commutative93.4%
Applied egg-rr93.4%
Taylor expanded in x around 0 79.0%
Final simplification79.0%
herbie shell --seed 2024150
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))