
(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
(let* ((t_0 (cos (* 2.0 x_m))))
(if (<= (/ t_0 (* (pow c 2.0) (* x_m (* x_m (pow s_m 2.0))))) INFINITY)
(/ (* (/ t_0 c) (/ 1.0 (* x_m s_m))) (* c (fabs (* x_m s_m))))
(* (/ t_0 (* x_m (* c s_m))) (* (/ (/ 1.0 s_m) c) (/ 1.0 x_m))))))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 = cos((2.0 * x_m));
double tmp;
if ((t_0 / (pow(c, 2.0) * (x_m * (x_m * pow(s_m, 2.0))))) <= ((double) INFINITY)) {
tmp = ((t_0 / c) * (1.0 / (x_m * s_m))) / (c * fabs((x_m * s_m)));
} else {
tmp = (t_0 / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
}
return tmp;
}
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 = Math.cos((2.0 * x_m));
double tmp;
if ((t_0 / (Math.pow(c, 2.0) * (x_m * (x_m * Math.pow(s_m, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = ((t_0 / c) * (1.0 / (x_m * s_m))) / (c * Math.abs((x_m * s_m)));
} else {
tmp = (t_0 / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
}
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): t_0 = math.cos((2.0 * x_m)) tmp = 0 if (t_0 / (math.pow(c, 2.0) * (x_m * (x_m * math.pow(s_m, 2.0))))) <= math.inf: tmp = ((t_0 / c) * (1.0 / (x_m * s_m))) / (c * math.fabs((x_m * s_m))) else: tmp = (t_0 / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m)) 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) t_0 = cos(Float64(2.0 * x_m)) tmp = 0.0 if (Float64(t_0 / Float64((c ^ 2.0) * Float64(x_m * Float64(x_m * (s_m ^ 2.0))))) <= Inf) tmp = Float64(Float64(Float64(t_0 / c) * Float64(1.0 / Float64(x_m * s_m))) / Float64(c * abs(Float64(x_m * s_m)))); else tmp = Float64(Float64(t_0 / Float64(x_m * Float64(c * s_m))) * Float64(Float64(Float64(1.0 / s_m) / c) * Float64(1.0 / x_m))); 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)
t_0 = cos((2.0 * x_m));
tmp = 0.0;
if ((t_0 / ((c ^ 2.0) * (x_m * (x_m * (s_m ^ 2.0))))) <= Inf)
tmp = ((t_0 / c) * (1.0 / (x_m * s_m))) / (c * abs((x_m * s_m)));
else
tmp = (t_0 / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
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_] := Block[{t$95$0 = N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$0 / c), $MachinePrecision] * N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c * N[Abs[N[(x$95$m * s$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / c), $MachinePrecision] * N[(1.0 / x$95$m), $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}
t_0 := \cos \left(2 \cdot x\_m\right)\\
\mathbf{if}\;\frac{t\_0}{{c}^{2} \cdot \left(x\_m \cdot \left(x\_m \cdot {s\_m}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\frac{t\_0}{c} \cdot \frac{1}{x\_m \cdot s\_m}}{c \cdot \left|x\_m \cdot s\_m\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x\_m \cdot \left(c \cdot s\_m\right)} \cdot \left(\frac{\frac{1}{s\_m}}{c} \cdot \frac{1}{x\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0Initial program 81.9%
*-un-lft-identity81.9%
add-sqr-sqrt81.9%
times-frac81.9%
sqrt-prod81.9%
sqrt-pow161.7%
metadata-eval61.7%
pow161.7%
*-commutative61.7%
associate-*r*57.4%
unpow257.4%
pow-prod-down61.7%
sqrt-prod61.7%
Applied egg-rr95.6%
associate-*l/95.6%
*-lft-identity95.6%
unpow295.6%
rem-sqrt-square95.6%
unpow295.6%
rem-sqrt-square99.7%
Simplified99.7%
associate-/r*99.8%
add-sqr-sqrt55.4%
fabs-sqr55.4%
add-sqr-sqrt66.7%
div-inv66.6%
*-commutative66.6%
Applied egg-rr66.6%
if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
sqrt-prod0.0%
sqrt-pow10.0%
metadata-eval0.0%
pow10.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
pow-prod-down0.0%
sqrt-prod0.0%
Applied egg-rr56.7%
associate-*l/56.7%
*-lft-identity56.7%
unpow256.7%
rem-sqrt-square56.7%
unpow256.7%
rem-sqrt-square89.7%
Simplified89.7%
div-inv89.7%
*-commutative89.7%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt49.8%
associate-*r*49.9%
add-sqr-sqrt40.8%
fabs-sqr40.8%
add-sqr-sqrt90.0%
associate-*r*99.4%
Applied egg-rr99.4%
associate-/r*99.5%
div-inv99.5%
*-commutative99.5%
associate-/r*99.5%
Applied egg-rr99.5%
Final simplification72.9%
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 (* c (* x_m s_m))) (t_1 (* x_m (* c s_m))))
(if (<= c 6e-245)
(/ (cos (* x_m -2.0)) (* t_1 t_1))
(/ (/ (cos (* 2.0 x_m)) 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 = c * (x_m * s_m);
double t_1 = x_m * (c * s_m);
double tmp;
if (c <= 6e-245) {
tmp = cos((x_m * -2.0)) / (t_1 * t_1);
} else {
tmp = (cos((2.0 * x_m)) / t_0) / t_0;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c * (x_m * s_m)
t_1 = x_m * (c * s_m)
if (c <= 6d-245) then
tmp = cos((x_m * (-2.0d0))) / (t_1 * t_1)
else
tmp = (cos((2.0d0 * x_m)) / t_0) / t_0
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 t_0 = c * (x_m * s_m);
double t_1 = x_m * (c * s_m);
double tmp;
if (c <= 6e-245) {
tmp = Math.cos((x_m * -2.0)) / (t_1 * t_1);
} else {
tmp = (Math.cos((2.0 * x_m)) / t_0) / t_0;
}
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): t_0 = c * (x_m * s_m) t_1 = x_m * (c * s_m) tmp = 0 if c <= 6e-245: tmp = math.cos((x_m * -2.0)) / (t_1 * t_1) else: tmp = (math.cos((2.0 * x_m)) / t_0) / t_0 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) t_0 = Float64(c * Float64(x_m * s_m)) t_1 = Float64(x_m * Float64(c * s_m)) tmp = 0.0 if (c <= 6e-245) tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(t_1 * t_1)); else tmp = Float64(Float64(cos(Float64(2.0 * x_m)) / t_0) / t_0); 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)
t_0 = c * (x_m * s_m);
t_1 = x_m * (c * s_m);
tmp = 0.0;
if (c <= 6e-245)
tmp = cos((x_m * -2.0)) / (t_1 * t_1);
else
tmp = (cos((2.0 * x_m)) / t_0) / t_0;
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_] := Block[{t$95$0 = N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, 6e-245], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(2.0 * x$95$m), $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 := c \cdot \left(x\_m \cdot s\_m\right)\\
t_1 := x\_m \cdot \left(c \cdot s\_m\right)\\
\mathbf{if}\;c \leq 6 \cdot 10^{-245}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot -2\right)}{t\_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(2 \cdot x\_m\right)}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if c < 6.0000000000000004e-245Initial program 67.0%
associate-/l/67.0%
remove-double-neg67.0%
distribute-frac-neg67.0%
distribute-neg-frac67.0%
remove-double-neg67.0%
*-commutative67.0%
associate-*r*60.2%
unpow260.2%
associate-/r*59.5%
cos-neg59.5%
*-commutative59.5%
distribute-rgt-neg-in59.5%
metadata-eval59.5%
Simplified59.5%
Taylor expanded in x around inf 60.2%
associate-/r*60.2%
unpow260.2%
unpow260.2%
swap-sqr75.1%
unpow275.1%
associate-/r*75.1%
*-commutative75.1%
unpow275.1%
rem-square-sqrt75.1%
swap-sqr84.8%
unpow284.8%
unpow284.8%
rem-sqrt-square96.8%
Simplified96.8%
unpow-prod-down75.1%
unpow275.1%
pow275.1%
sqr-abs75.1%
swap-sqr96.8%
associate-*r*95.5%
associate-*r*98.3%
Applied egg-rr98.3%
if 6.0000000000000004e-245 < c Initial program 65.4%
*-un-lft-identity65.4%
add-sqr-sqrt65.4%
times-frac65.4%
sqrt-prod65.4%
sqrt-pow165.4%
metadata-eval65.4%
pow165.4%
*-commutative65.4%
associate-*r*61.6%
unpow261.6%
pow-prod-down65.4%
sqrt-prod65.5%
Applied egg-rr91.9%
associate-*l/91.9%
*-lft-identity91.9%
unpow291.9%
rem-sqrt-square91.9%
unpow291.9%
rem-sqrt-square98.9%
Simplified98.9%
div-inv98.9%
*-commutative98.9%
add-sqr-sqrt48.3%
fabs-sqr48.3%
add-sqr-sqrt59.9%
associate-*r*59.2%
add-sqr-sqrt38.6%
fabs-sqr38.6%
add-sqr-sqrt95.3%
associate-*r*96.0%
Applied egg-rr96.0%
un-div-inv96.0%
associate-*l*95.3%
associate-*l*98.9%
Applied egg-rr98.9%
Final simplification98.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 (* (/ (cos (* 2.0 x_m)) (* x_m (* c s_m))) (* (/ (/ 1.0 s_m) c) (/ 1.0 x_m))))
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 (cos((2.0 * x_m)) / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
}
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 = (cos((2.0d0 * x_m)) / (x_m * (c * s_m))) * (((1.0d0 / s_m) / c) * (1.0d0 / x_m))
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.cos((2.0 * x_m)) / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
}
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.cos((2.0 * x_m)) / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m))
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(cos(Float64(2.0 * x_m)) / Float64(x_m * Float64(c * s_m))) * Float64(Float64(Float64(1.0 / s_m) / c) * Float64(1.0 / x_m))) 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 = (cos((2.0 * x_m)) / (x_m * (c * s_m))) * (((1.0 / s_m) / c) * (1.0 / x_m));
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[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / c), $MachinePrecision] * N[(1.0 / x$95$m), $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{\cos \left(2 \cdot x\_m\right)}{x\_m \cdot \left(c \cdot s\_m\right)} \cdot \left(\frac{\frac{1}{s\_m}}{c} \cdot \frac{1}{x\_m}\right)
\end{array}
Initial program 66.2%
*-un-lft-identity66.2%
add-sqr-sqrt66.2%
times-frac66.2%
sqrt-prod66.2%
sqrt-pow149.9%
metadata-eval49.9%
pow149.9%
*-commutative49.9%
associate-*r*46.4%
unpow246.4%
pow-prod-down49.9%
sqrt-prod49.9%
Applied egg-rr88.1%
associate-*l/88.2%
*-lft-identity88.2%
unpow288.2%
rem-sqrt-square88.2%
unpow288.2%
rem-sqrt-square97.8%
Simplified97.8%
div-inv97.8%
*-commutative97.8%
add-sqr-sqrt55.0%
fabs-sqr55.0%
add-sqr-sqrt63.4%
associate-*r*62.4%
add-sqr-sqrt46.5%
fabs-sqr46.5%
add-sqr-sqrt95.4%
associate-*r*97.1%
Applied egg-rr97.1%
associate-/r*97.2%
div-inv97.2%
*-commutative97.2%
associate-/r*97.2%
Applied egg-rr97.2%
Final simplification97.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 (let* ((t_0 (* x_m (* c s_m)))) (* (/ (cos (* 2.0 x_m)) t_0) (/ 1.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 = x_m * (c * s_m);
return (cos((2.0 * x_m)) / t_0) * (1.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 = x_m * (c * s_m)
code = (cos((2.0d0 * x_m)) / t_0) * (1.0d0 / 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 = x_m * (c * s_m);
return (Math.cos((2.0 * x_m)) / t_0) * (1.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 = x_m * (c * s_m) return (math.cos((2.0 * x_m)) / t_0) * (1.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(x_m * Float64(c * s_m)) return Float64(Float64(cos(Float64(2.0 * x_m)) / t_0) * Float64(1.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 = x_m * (c * s_m);
tmp = (cos((2.0 * x_m)) / t_0) * (1.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[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 / t$95$0), $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}
t_0 := x\_m \cdot \left(c \cdot s\_m\right)\\
\frac{\cos \left(2 \cdot x\_m\right)}{t\_0} \cdot \frac{1}{t\_0}
\end{array}
\end{array}
Initial program 66.2%
*-un-lft-identity66.2%
add-sqr-sqrt66.2%
times-frac66.2%
sqrt-prod66.2%
sqrt-pow149.9%
metadata-eval49.9%
pow149.9%
*-commutative49.9%
associate-*r*46.4%
unpow246.4%
pow-prod-down49.9%
sqrt-prod49.9%
Applied egg-rr88.1%
associate-*l/88.2%
*-lft-identity88.2%
unpow288.2%
rem-sqrt-square88.2%
unpow288.2%
rem-sqrt-square97.8%
Simplified97.8%
div-inv97.8%
*-commutative97.8%
add-sqr-sqrt55.0%
fabs-sqr55.0%
add-sqr-sqrt63.4%
associate-*r*62.4%
add-sqr-sqrt46.5%
fabs-sqr46.5%
add-sqr-sqrt95.4%
associate-*r*97.1%
Applied egg-rr97.1%
Final simplification97.1%
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 (* x_m (* c s_m)))) (/ (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 = x_m * (c * s_m);
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 = x_m * (c * s_m)
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 = x_m * (c * s_m);
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 = x_m * (c * s_m) 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(x_m * Float64(c * s_m)) return Float64(cos(Float64(x_m * -2.0)) / Float64(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 = x_m * (c * s_m);
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[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $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}
t_0 := x\_m \cdot \left(c \cdot s\_m\right)\\
\frac{\cos \left(x\_m \cdot -2\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.2%
associate-/l/66.3%
remove-double-neg66.3%
distribute-frac-neg66.3%
distribute-neg-frac66.3%
remove-double-neg66.3%
*-commutative66.3%
associate-*r*60.9%
unpow260.9%
associate-/r*60.2%
cos-neg60.2%
*-commutative60.2%
distribute-rgt-neg-in60.2%
metadata-eval60.2%
Simplified60.2%
Taylor expanded in x around inf 60.9%
associate-/r*60.9%
unpow260.9%
unpow260.9%
swap-sqr75.6%
unpow275.6%
associate-/r*75.6%
*-commutative75.6%
unpow275.6%
rem-square-sqrt75.6%
swap-sqr88.0%
unpow288.0%
unpow288.0%
rem-sqrt-square97.5%
Simplified97.5%
unpow-prod-down75.6%
unpow275.6%
pow275.6%
sqr-abs75.6%
swap-sqr97.5%
associate-*r*95.1%
associate-*r*96.9%
Applied egg-rr96.9%
Final simplification96.9%
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 (* x_m s_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 * (x_m * s_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 * (x_m * s_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 * (x_m * s_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 * (x_m * s_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(x_m * s_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 * (x_m * s_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[(x$95$m * s$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(x\_m \cdot s\_m\right)\right)}^{-2}
\end{array}
Initial program 66.2%
Taylor expanded in x around 0 55.7%
associate-/r*55.7%
unpow255.7%
unpow255.7%
swap-sqr65.4%
unpow265.4%
associate-/r*65.5%
unpow265.5%
rem-square-sqrt65.5%
swap-sqr75.5%
unpow275.5%
unpow275.5%
rem-sqrt-square81.6%
Simplified81.6%
*-un-lft-identity81.6%
pow-flip81.6%
add-sqr-sqrt45.4%
fabs-sqr45.4%
add-sqr-sqrt81.6%
associate-*r*81.5%
metadata-eval81.5%
Applied egg-rr81.5%
*-lft-identity81.5%
associate-*l*81.6%
Simplified81.6%
Final simplification81.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 (* (/ 1.0 c) (/ (/ (/ 1.0 (* x_m s_m)) c) (* x_m s_m))))
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) * (((1.0 / (x_m * s_m)) / c) / (x_m * s_m));
}
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) * (((1.0d0 / (x_m * s_m)) / c) / (x_m * s_m))
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) * (((1.0 / (x_m * s_m)) / c) / (x_m * s_m));
}
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) * (((1.0 / (x_m * s_m)) / c) / (x_m * s_m))
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 / c) * Float64(Float64(Float64(1.0 / Float64(x_m * s_m)) / c) / Float64(x_m * s_m))) 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) * (((1.0 / (x_m * s_m)) / c) / (x_m * s_m));
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 / c), $MachinePrecision] * N[(N[(N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(x$95$m * s$95$m), $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}{c} \cdot \frac{\frac{\frac{1}{x\_m \cdot s\_m}}{c}}{x\_m \cdot s\_m}
\end{array}
Initial program 66.2%
Taylor expanded in x around 0 55.7%
associate-/r*55.7%
unpow255.7%
unpow255.7%
swap-sqr65.4%
unpow265.4%
associate-/r*65.5%
unpow265.5%
rem-square-sqrt65.5%
swap-sqr75.5%
unpow275.5%
unpow275.5%
rem-sqrt-square81.6%
Simplified81.6%
unpow-prod-down75.6%
unpow275.6%
pow275.6%
sqr-abs75.6%
swap-sqr97.5%
associate-*r*95.1%
associate-*r*96.9%
Applied egg-rr81.5%
associate-/r*81.5%
*-un-lft-identity81.5%
associate-*l*80.5%
times-frac79.1%
*-commutative79.1%
*-commutative79.1%
associate-*r*80.2%
*-commutative80.2%
associate-/r*80.2%
Applied egg-rr80.2%
Final simplification80.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 (* (* x_m s_m) (* c (* x_m s_m))))))
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 * ((x_m * s_m) * (c * (x_m * s_m))));
}
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 * ((x_m * s_m) * (c * (x_m * s_m))))
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 * ((x_m * s_m) * (c * (x_m * s_m))));
}
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 * ((x_m * s_m) * (c * (x_m * s_m))))
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(c * Float64(Float64(x_m * s_m) * Float64(c * Float64(x_m * s_m))))) 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 * ((x_m * s_m) * (c * (x_m * s_m))));
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[(c * N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(c * N[(x$95$m * s$95$m), $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}{c \cdot \left(\left(x\_m \cdot s\_m\right) \cdot \left(c \cdot \left(x\_m \cdot s\_m\right)\right)\right)}
\end{array}
Initial program 66.2%
Taylor expanded in x around 0 55.7%
associate-/r*55.7%
unpow255.7%
unpow255.7%
swap-sqr65.4%
unpow265.4%
associate-/r*65.5%
unpow265.5%
rem-square-sqrt65.5%
swap-sqr75.5%
unpow275.5%
unpow275.5%
rem-sqrt-square81.6%
Simplified81.6%
/-rgt-identity81.6%
clear-num81.6%
pow-flip81.6%
add-sqr-sqrt45.4%
fabs-sqr45.4%
add-sqr-sqrt81.6%
associate-*r*81.5%
metadata-eval81.5%
Applied egg-rr81.5%
pow-flip81.5%
metadata-eval81.5%
pow281.5%
*-commutative81.5%
*-commutative81.5%
associate-*r*80.5%
*-commutative80.5%
associate-*r*79.0%
associate-*l*80.1%
Applied egg-rr80.1%
Final simplification80.1%
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 (* x_m (* c s_m)))) (/ 1.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 = x_m * (c * s_m);
return 1.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 = x_m * (c * s_m)
code = 1.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 = x_m * (c * s_m);
return 1.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 = x_m * (c * s_m) return 1.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(x_m * Float64(c * s_m)) return Float64(1.0 / Float64(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 = x_m * (c * s_m);
tmp = 1.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[(x$95$m * N[(c * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $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}
t_0 := x\_m \cdot \left(c \cdot s\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.2%
Taylor expanded in x around 0 55.7%
associate-/r*55.7%
unpow255.7%
unpow255.7%
swap-sqr65.4%
unpow265.4%
associate-/r*65.5%
unpow265.5%
rem-square-sqrt65.5%
swap-sqr75.5%
unpow275.5%
unpow275.5%
rem-sqrt-square81.6%
Simplified81.6%
unpow-prod-down75.6%
unpow275.6%
pow275.6%
sqr-abs75.6%
swap-sqr97.5%
associate-*r*95.1%
associate-*r*96.9%
Applied egg-rr81.5%
Final simplification81.5%
herbie shell --seed 2024091
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))