
(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 11 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)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(if (<= x_m 1.3e-6)
(/ (cos (* x_m -2.0)) (pow (* c_m (* x_m s_m)) 2.0))
(*
(/ (cos (* x_m 2.0)) (* x_m c_m))
(/ (* (/ 1.0 s_m) (/ (/ 1.0 c_m) x_m)) s_m))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double tmp;
if (x_m <= 1.3e-6) {
tmp = cos((x_m * -2.0)) / pow((c_m * (x_m * s_m)), 2.0);
} else {
tmp = (cos((x_m * 2.0)) / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 1.3d-6) then
tmp = cos((x_m * (-2.0d0))) / ((c_m * (x_m * s_m)) ** 2.0d0)
else
tmp = (cos((x_m * 2.0d0)) / (x_m * c_m)) * (((1.0d0 / s_m) * ((1.0d0 / c_m) / x_m)) / s_m)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double tmp;
if (x_m <= 1.3e-6) {
tmp = Math.cos((x_m * -2.0)) / Math.pow((c_m * (x_m * s_m)), 2.0);
} else {
tmp = (Math.cos((x_m * 2.0)) / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): tmp = 0 if x_m <= 1.3e-6: tmp = math.cos((x_m * -2.0)) / math.pow((c_m * (x_m * s_m)), 2.0) else: tmp = (math.cos((x_m * 2.0)) / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) tmp = 0.0 if (x_m <= 1.3e-6) tmp = Float64(cos(Float64(x_m * -2.0)) / (Float64(c_m * Float64(x_m * s_m)) ^ 2.0)); else tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / Float64(x_m * c_m)) * Float64(Float64(Float64(1.0 / s_m) * Float64(Float64(1.0 / c_m) / x_m)) / s_m)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
tmp = 0.0;
if (x_m <= 1.3e-6)
tmp = cos((x_m * -2.0)) / ((c_m * (x_m * s_m)) ^ 2.0);
else
tmp = (cos((x_m * 2.0)) / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := If[LessEqual[x$95$m, 1.3e-6], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s$95$m), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision] / s$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.3 \cdot 10^{-6}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot -2\right)}{{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot 2\right)}{x\_m \cdot c\_m} \cdot \frac{\frac{1}{s\_m} \cdot \frac{\frac{1}{c\_m}}{x\_m}}{s\_m}\\
\end{array}
\end{array}
if x < 1.30000000000000005e-6Initial program 69.1%
associate-/r*68.6%
cos-neg68.6%
distribute-rgt-neg-out68.6%
distribute-rgt-neg-out68.6%
*-commutative68.6%
distribute-rgt-neg-in68.6%
metadata-eval68.6%
*-commutative68.6%
associate-*l*64.3%
unpow264.3%
Simplified64.3%
Taylor expanded in x around inf 64.8%
associate-/r*64.3%
*-commutative64.3%
unpow264.3%
unpow264.3%
swap-sqr78.4%
unpow278.4%
associate-/r*78.9%
*-commutative78.9%
unpow278.9%
unpow278.9%
swap-sqr97.8%
unpow297.8%
*-commutative97.8%
Simplified97.8%
if 1.30000000000000005e-6 < x Initial program 75.1%
associate-/l/75.2%
remove-double-neg75.2%
distribute-frac-neg75.2%
distribute-neg-frac75.2%
remove-double-neg75.2%
*-commutative75.2%
associate-*r*69.2%
unpow269.2%
associate-/r*69.2%
cos-neg69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
Simplified69.2%
associate-/l/69.2%
*-un-lft-identity69.2%
add-sqr-sqrt69.1%
times-frac69.1%
pow-prod-down69.2%
sqrt-pow155.6%
metadata-eval55.6%
pow155.6%
*-commutative55.6%
add-sqr-sqrt0.0%
sqrt-unprod26.0%
*-commutative26.0%
*-commutative26.0%
swap-sqr26.0%
metadata-eval26.0%
metadata-eval26.0%
swap-sqr26.0%
sqrt-unprod56.0%
add-sqr-sqrt55.6%
Applied egg-rr82.7%
div-inv82.7%
frac-times82.6%
*-un-lft-identity82.6%
pow282.6%
frac-times82.6%
unpow-prod-down95.9%
*-commutative95.9%
unpow295.9%
frac-times96.0%
div-inv95.9%
div-inv95.9%
associate-*r*94.2%
times-frac88.7%
*-commutative88.7%
Applied egg-rr88.7%
*-un-lft-identity88.7%
*-commutative88.7%
times-frac92.2%
Applied egg-rr92.2%
Final simplification96.7%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (cos (* x_m 2.0))) (t_1 (* c_m (* x_m s_m))))
(if (<= x_m 1.35e-6)
(/ (/ t_0 t_1) t_1)
(* (/ t_0 (* x_m c_m)) (/ (* (/ 1.0 s_m) (/ (/ 1.0 c_m) x_m)) s_m)))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = cos((x_m * 2.0));
double t_1 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 1.35e-6) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = (t_0 / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x_m * 2.0d0))
t_1 = c_m * (x_m * s_m)
if (x_m <= 1.35d-6) then
tmp = (t_0 / t_1) / t_1
else
tmp = (t_0 / (x_m * c_m)) * (((1.0d0 / s_m) * ((1.0d0 / c_m) / x_m)) / s_m)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = Math.cos((x_m * 2.0));
double t_1 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 1.35e-6) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = (t_0 / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = math.cos((x_m * 2.0)) t_1 = c_m * (x_m * s_m) tmp = 0 if x_m <= 1.35e-6: tmp = (t_0 / t_1) / t_1 else: tmp = (t_0 / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = cos(Float64(x_m * 2.0)) t_1 = Float64(c_m * Float64(x_m * s_m)) tmp = 0.0 if (x_m <= 1.35e-6) tmp = Float64(Float64(t_0 / t_1) / t_1); else tmp = Float64(Float64(t_0 / Float64(x_m * c_m)) * Float64(Float64(Float64(1.0 / s_m) * Float64(Float64(1.0 / c_m) / x_m)) / s_m)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = cos((x_m * 2.0));
t_1 = c_m * (x_m * s_m);
tmp = 0.0;
if (x_m <= 1.35e-6)
tmp = (t_0 / t_1) / t_1;
else
tmp = (t_0 / (x_m * c_m)) * (((1.0 / s_m) * ((1.0 / c_m) / x_m)) / s_m);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.35e-6], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(t$95$0 / N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s$95$m), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision] / s$95$m), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(x\_m \cdot 2\right)\\
t_1 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\mathbf{if}\;x\_m \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x\_m \cdot c\_m} \cdot \frac{\frac{1}{s\_m} \cdot \frac{\frac{1}{c\_m}}{x\_m}}{s\_m}\\
\end{array}
\end{array}
if x < 1.34999999999999999e-6Initial program 69.1%
*-un-lft-identity69.1%
add-sqr-sqrt69.0%
times-frac69.0%
Applied egg-rr97.8%
*-commutative97.8%
div-inv97.8%
div-inv97.8%
div-inv97.8%
*-commutative97.8%
Applied egg-rr97.8%
if 1.34999999999999999e-6 < x Initial program 75.1%
associate-/l/75.2%
remove-double-neg75.2%
distribute-frac-neg75.2%
distribute-neg-frac75.2%
remove-double-neg75.2%
*-commutative75.2%
associate-*r*69.2%
unpow269.2%
associate-/r*69.2%
cos-neg69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
Simplified69.2%
associate-/l/69.2%
*-un-lft-identity69.2%
add-sqr-sqrt69.1%
times-frac69.1%
pow-prod-down69.2%
sqrt-pow155.6%
metadata-eval55.6%
pow155.6%
*-commutative55.6%
add-sqr-sqrt0.0%
sqrt-unprod26.0%
*-commutative26.0%
*-commutative26.0%
swap-sqr26.0%
metadata-eval26.0%
metadata-eval26.0%
swap-sqr26.0%
sqrt-unprod56.0%
add-sqr-sqrt55.6%
Applied egg-rr82.7%
div-inv82.7%
frac-times82.6%
*-un-lft-identity82.6%
pow282.6%
frac-times82.6%
unpow-prod-down95.9%
*-commutative95.9%
unpow295.9%
frac-times96.0%
div-inv95.9%
div-inv95.9%
associate-*r*94.2%
times-frac88.7%
*-commutative88.7%
Applied egg-rr88.7%
*-un-lft-identity88.7%
*-commutative88.7%
times-frac92.2%
Applied egg-rr92.2%
Final simplification96.7%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (/ c_m (cos (* x_m 2.0)))))
(if (<= c_m 2.15e-280)
(/ (/ 1.0 (* x_m (* c_m s_m))) (* x_m (* s_m t_0)))
(/ (/ (/ 1.0 c_m) (* x_m s_m)) (* (* x_m s_m) t_0)))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m / cos((x_m * 2.0));
double tmp;
if (c_m <= 2.15e-280) {
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * t_0));
} else {
tmp = ((1.0 / c_m) / (x_m * s_m)) / ((x_m * s_m) * t_0);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m / cos((x_m * 2.0d0))
if (c_m <= 2.15d-280) then
tmp = (1.0d0 / (x_m * (c_m * s_m))) / (x_m * (s_m * t_0))
else
tmp = ((1.0d0 / c_m) / (x_m * s_m)) / ((x_m * s_m) * t_0)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m / Math.cos((x_m * 2.0));
double tmp;
if (c_m <= 2.15e-280) {
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * t_0));
} else {
tmp = ((1.0 / c_m) / (x_m * s_m)) / ((x_m * s_m) * t_0);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m / math.cos((x_m * 2.0)) tmp = 0 if c_m <= 2.15e-280: tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * t_0)) else: tmp = ((1.0 / c_m) / (x_m * s_m)) / ((x_m * s_m) * t_0) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m / cos(Float64(x_m * 2.0))) tmp = 0.0 if (c_m <= 2.15e-280) tmp = Float64(Float64(1.0 / Float64(x_m * Float64(c_m * s_m))) / Float64(x_m * Float64(s_m * t_0))); else tmp = Float64(Float64(Float64(1.0 / c_m) / Float64(x_m * s_m)) / Float64(Float64(x_m * s_m) * t_0)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = c_m / cos((x_m * 2.0));
tmp = 0.0;
if (c_m <= 2.15e-280)
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * t_0));
else
tmp = ((1.0 / c_m) / (x_m * s_m)) / ((x_m * s_m) * t_0);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m / N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c$95$m, 2.15e-280], N[(N[(1.0 / N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x$95$m * N[(s$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \frac{c\_m}{\cos \left(x\_m \cdot 2\right)}\\
\mathbf{if}\;c\_m \leq 2.15 \cdot 10^{-280}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot \left(c\_m \cdot s\_m\right)}}{x\_m \cdot \left(s\_m \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}}{\left(x\_m \cdot s\_m\right) \cdot t\_0}\\
\end{array}
\end{array}
if c < 2.1499999999999999e-280Initial program 69.8%
associate-/l/69.8%
remove-double-neg69.8%
distribute-frac-neg69.8%
distribute-neg-frac69.8%
remove-double-neg69.8%
*-commutative69.8%
associate-*r*67.3%
unpow267.3%
associate-/r*66.5%
cos-neg66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
metadata-eval66.5%
Simplified66.5%
associate-/l/67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.2%
times-frac67.3%
pow-prod-down67.3%
sqrt-pow147.8%
metadata-eval47.8%
pow147.8%
*-commutative47.8%
add-sqr-sqrt22.2%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
metadata-eval33.7%
metadata-eval33.7%
swap-sqr33.7%
sqrt-unprod26.7%
add-sqr-sqrt47.8%
Applied egg-rr79.7%
div-inv78.9%
frac-times78.7%
*-un-lft-identity78.7%
pow278.7%
frac-times79.5%
unpow-prod-down96.0%
*-commutative96.0%
unpow296.0%
frac-times96.0%
div-inv96.0%
div-inv96.0%
*-commutative96.0%
associate-*r*91.7%
times-frac84.8%
Applied egg-rr84.8%
associate-/l/84.8%
*-commutative84.8%
associate-/l/84.8%
associate-/l/84.8%
Simplified84.8%
clear-num84.8%
frac-times91.7%
div-inv91.7%
*-un-lft-identity91.7%
associate-/l/91.7%
frac-times91.7%
metadata-eval91.7%
*-commutative91.7%
*-commutative91.7%
associate-*r*95.2%
*-commutative95.2%
*-un-lft-identity95.2%
times-frac95.3%
/-rgt-identity95.3%
Applied egg-rr95.3%
if 2.1499999999999999e-280 < c Initial program 70.7%
*-un-lft-identity70.7%
add-sqr-sqrt70.7%
times-frac70.7%
Applied egg-rr98.9%
clear-num98.9%
un-div-inv98.9%
associate-/r*98.9%
*-commutative98.9%
*-un-lft-identity98.9%
times-frac98.9%
/-rgt-identity98.9%
*-commutative98.9%
Applied egg-rr98.9%
Final simplification97.1%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (cos (* x_m 2.0))) (t_1 (* c_m (* x_m s_m))))
(if (<= c_m 1.45e-280)
(/ (/ 1.0 (* x_m (* c_m s_m))) (* x_m (* s_m (/ c_m t_0))))
(* (/ 1.0 t_1) (/ t_0 t_1)))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = cos((x_m * 2.0));
double t_1 = c_m * (x_m * s_m);
double tmp;
if (c_m <= 1.45e-280) {
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * (c_m / t_0)));
} else {
tmp = (1.0 / t_1) * (t_0 / t_1);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x_m * 2.0d0))
t_1 = c_m * (x_m * s_m)
if (c_m <= 1.45d-280) then
tmp = (1.0d0 / (x_m * (c_m * s_m))) / (x_m * (s_m * (c_m / t_0)))
else
tmp = (1.0d0 / t_1) * (t_0 / t_1)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = Math.cos((x_m * 2.0));
double t_1 = c_m * (x_m * s_m);
double tmp;
if (c_m <= 1.45e-280) {
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * (c_m / t_0)));
} else {
tmp = (1.0 / t_1) * (t_0 / t_1);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = math.cos((x_m * 2.0)) t_1 = c_m * (x_m * s_m) tmp = 0 if c_m <= 1.45e-280: tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * (c_m / t_0))) else: tmp = (1.0 / t_1) * (t_0 / t_1) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = cos(Float64(x_m * 2.0)) t_1 = Float64(c_m * Float64(x_m * s_m)) tmp = 0.0 if (c_m <= 1.45e-280) tmp = Float64(Float64(1.0 / Float64(x_m * Float64(c_m * s_m))) / Float64(x_m * Float64(s_m * Float64(c_m / t_0)))); else tmp = Float64(Float64(1.0 / t_1) * Float64(t_0 / t_1)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = cos((x_m * 2.0));
t_1 = c_m * (x_m * s_m);
tmp = 0.0;
if (c_m <= 1.45e-280)
tmp = (1.0 / (x_m * (c_m * s_m))) / (x_m * (s_m * (c_m / t_0)));
else
tmp = (1.0 / t_1) * (t_0 / t_1);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c$95$m, 1.45e-280], N[(N[(1.0 / N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x$95$m * N[(s$95$m * N[(c$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$1), $MachinePrecision] * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(x\_m \cdot 2\right)\\
t_1 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\mathbf{if}\;c\_m \leq 1.45 \cdot 10^{-280}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot \left(c\_m \cdot s\_m\right)}}{x\_m \cdot \left(s\_m \cdot \frac{c\_m}{t\_0}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1} \cdot \frac{t\_0}{t\_1}\\
\end{array}
\end{array}
if c < 1.45e-280Initial program 69.8%
associate-/l/69.8%
remove-double-neg69.8%
distribute-frac-neg69.8%
distribute-neg-frac69.8%
remove-double-neg69.8%
*-commutative69.8%
associate-*r*67.3%
unpow267.3%
associate-/r*66.5%
cos-neg66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
metadata-eval66.5%
Simplified66.5%
associate-/l/67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.2%
times-frac67.3%
pow-prod-down67.3%
sqrt-pow147.8%
metadata-eval47.8%
pow147.8%
*-commutative47.8%
add-sqr-sqrt22.2%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
metadata-eval33.7%
metadata-eval33.7%
swap-sqr33.7%
sqrt-unprod26.7%
add-sqr-sqrt47.8%
Applied egg-rr79.7%
div-inv78.9%
frac-times78.7%
*-un-lft-identity78.7%
pow278.7%
frac-times79.5%
unpow-prod-down96.0%
*-commutative96.0%
unpow296.0%
frac-times96.0%
div-inv96.0%
div-inv96.0%
*-commutative96.0%
associate-*r*91.7%
times-frac84.8%
Applied egg-rr84.8%
associate-/l/84.8%
*-commutative84.8%
associate-/l/84.8%
associate-/l/84.8%
Simplified84.8%
clear-num84.8%
frac-times91.7%
div-inv91.7%
*-un-lft-identity91.7%
associate-/l/91.7%
frac-times91.7%
metadata-eval91.7%
*-commutative91.7%
*-commutative91.7%
associate-*r*95.2%
*-commutative95.2%
*-un-lft-identity95.2%
times-frac95.3%
/-rgt-identity95.3%
Applied egg-rr95.3%
if 1.45e-280 < c Initial program 70.7%
*-un-lft-identity70.7%
add-sqr-sqrt70.7%
times-frac70.7%
Applied egg-rr98.9%
Final simplification97.1%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x_m s_m))) (t_1 (cos (* x_m 2.0))))
(if (<= c_m 2.3e-280)
(/ (/ (/ t_1 (* x_m (* c_m s_m))) (* c_m s_m)) x_m)
(* (/ 1.0 t_0) (/ t_1 t_0)))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double t_1 = cos((x_m * 2.0));
double tmp;
if (c_m <= 2.3e-280) {
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
} else {
tmp = (1.0 / t_0) * (t_1 / t_0);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c_m * (x_m * s_m)
t_1 = cos((x_m * 2.0d0))
if (c_m <= 2.3d-280) then
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m
else
tmp = (1.0d0 / t_0) * (t_1 / t_0)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double t_1 = Math.cos((x_m * 2.0));
double tmp;
if (c_m <= 2.3e-280) {
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
} else {
tmp = (1.0 / t_0) * (t_1 / t_0);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) t_1 = math.cos((x_m * 2.0)) tmp = 0 if c_m <= 2.3e-280: tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m else: tmp = (1.0 / t_0) * (t_1 / t_0) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (c_m <= 2.3e-280) tmp = Float64(Float64(Float64(t_1 / Float64(x_m * Float64(c_m * s_m))) / Float64(c_m * s_m)) / x_m); else tmp = Float64(Float64(1.0 / t_0) * Float64(t_1 / t_0)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (c_m <= 2.3e-280)
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
else
tmp = (1.0 / t_0) * (t_1 / t_0);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c$95$m, 2.3e-280], N[(N[(N[(t$95$1 / N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;c\_m \leq 2.3 \cdot 10^{-280}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m \cdot \left(c\_m \cdot s\_m\right)}}{c\_m \cdot s\_m}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{t\_1}{t\_0}\\
\end{array}
\end{array}
if c < 2.3e-280Initial program 69.8%
associate-/l/69.8%
remove-double-neg69.8%
distribute-frac-neg69.8%
distribute-neg-frac69.8%
remove-double-neg69.8%
*-commutative69.8%
associate-*r*67.3%
unpow267.3%
associate-/r*66.5%
cos-neg66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
metadata-eval66.5%
Simplified66.5%
associate-/l/67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.2%
times-frac67.3%
pow-prod-down67.3%
sqrt-pow147.8%
metadata-eval47.8%
pow147.8%
*-commutative47.8%
add-sqr-sqrt22.2%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
metadata-eval33.7%
metadata-eval33.7%
swap-sqr33.7%
sqrt-unprod26.7%
add-sqr-sqrt47.8%
Applied egg-rr79.7%
div-inv78.9%
frac-times78.7%
*-un-lft-identity78.7%
pow278.7%
frac-times79.5%
unpow-prod-down96.0%
*-commutative96.0%
unpow296.0%
frac-times96.0%
div-inv96.0%
div-inv96.0%
*-commutative96.0%
associate-*r*91.7%
times-frac84.8%
Applied egg-rr84.8%
associate-/l/84.8%
*-commutative84.8%
associate-/l/84.8%
associate-/l/84.8%
Simplified84.8%
associate-*r/88.8%
associate-/r*88.8%
frac-times88.8%
associate-/l/88.8%
div-inv88.8%
associate-/r*88.8%
*-commutative88.8%
associate-*r*92.4%
*-commutative92.4%
Applied egg-rr92.4%
if 2.3e-280 < c Initial program 70.7%
*-un-lft-identity70.7%
add-sqr-sqrt70.7%
times-frac70.7%
Applied egg-rr98.9%
Final simplification95.6%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x_m s_m))) (t_1 (cos (* x_m 2.0))))
(if (<= c_m 1.12e-281)
(/ (/ (/ t_1 (* x_m (* c_m s_m))) (* c_m s_m)) x_m)
(/ (/ t_1 t_0) t_0))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double t_1 = cos((x_m * 2.0));
double tmp;
if (c_m <= 1.12e-281) {
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
} else {
tmp = (t_1 / t_0) / t_0;
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c_m * (x_m * s_m)
t_1 = cos((x_m * 2.0d0))
if (c_m <= 1.12d-281) then
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m
else
tmp = (t_1 / t_0) / t_0
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double t_1 = Math.cos((x_m * 2.0));
double tmp;
if (c_m <= 1.12e-281) {
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
} else {
tmp = (t_1 / t_0) / t_0;
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) t_1 = math.cos((x_m * 2.0)) tmp = 0 if c_m <= 1.12e-281: tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m else: tmp = (t_1 / t_0) / t_0 return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (c_m <= 1.12e-281) tmp = Float64(Float64(Float64(t_1 / Float64(x_m * Float64(c_m * s_m))) / Float64(c_m * s_m)) / x_m); else tmp = Float64(Float64(t_1 / t_0) / t_0); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (c_m <= 1.12e-281)
tmp = ((t_1 / (x_m * (c_m * s_m))) / (c_m * s_m)) / x_m;
else
tmp = (t_1 / t_0) / t_0;
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c$95$m, 1.12e-281], N[(N[(N[(t$95$1 / N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;c\_m \leq 1.12 \cdot 10^{-281}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m \cdot \left(c\_m \cdot s\_m\right)}}{c\_m \cdot s\_m}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if c < 1.12e-281Initial program 69.8%
associate-/l/69.8%
remove-double-neg69.8%
distribute-frac-neg69.8%
distribute-neg-frac69.8%
remove-double-neg69.8%
*-commutative69.8%
associate-*r*67.3%
unpow267.3%
associate-/r*66.5%
cos-neg66.5%
*-commutative66.5%
distribute-rgt-neg-in66.5%
metadata-eval66.5%
Simplified66.5%
associate-/l/67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.2%
times-frac67.3%
pow-prod-down67.3%
sqrt-pow147.8%
metadata-eval47.8%
pow147.8%
*-commutative47.8%
add-sqr-sqrt22.2%
sqrt-unprod33.7%
*-commutative33.7%
*-commutative33.7%
swap-sqr33.7%
metadata-eval33.7%
metadata-eval33.7%
swap-sqr33.7%
sqrt-unprod26.7%
add-sqr-sqrt47.8%
Applied egg-rr79.7%
div-inv78.9%
frac-times78.7%
*-un-lft-identity78.7%
pow278.7%
frac-times79.5%
unpow-prod-down96.0%
*-commutative96.0%
unpow296.0%
frac-times96.0%
div-inv96.0%
div-inv96.0%
*-commutative96.0%
associate-*r*91.7%
times-frac84.8%
Applied egg-rr84.8%
associate-/l/84.8%
*-commutative84.8%
associate-/l/84.8%
associate-/l/84.8%
Simplified84.8%
associate-*r/88.8%
associate-/r*88.8%
frac-times88.8%
associate-/l/88.8%
div-inv88.8%
associate-/r*88.8%
*-commutative88.8%
associate-*r*92.4%
*-commutative92.4%
Applied egg-rr92.4%
if 1.12e-281 < c Initial program 70.7%
*-un-lft-identity70.7%
add-sqr-sqrt70.7%
times-frac70.7%
Applied egg-rr98.9%
*-commutative98.9%
div-inv98.9%
div-inv98.9%
div-inv98.9%
*-commutative98.9%
Applied egg-rr98.9%
Final simplification95.6%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (let* ((t_0 (* c_m (* x_m s_m)))) (/ (/ (cos (* x_m 2.0)) t_0) t_0)))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return (cos((x_m * 2.0)) / t_0) / t_0;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c_m * (x_m * s_m)
code = (cos((x_m * 2.0d0)) / t_0) / t_0
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return (Math.cos((x_m * 2.0)) / t_0) / t_0;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) return (math.cos((x_m * 2.0)) / t_0) / t_0
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) return Float64(Float64(cos(Float64(x_m * 2.0)) / t_0) / t_0) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
tmp = (cos((x_m * 2.0)) / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * s$95$m), $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|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 70.3%
*-un-lft-identity70.3%
add-sqr-sqrt70.2%
times-frac70.2%
Applied egg-rr97.4%
*-commutative97.4%
div-inv97.4%
div-inv97.4%
div-inv97.4%
*-commutative97.4%
Applied egg-rr97.4%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (/ (/ (cos (* x_m 2.0)) c_m) (* (* x_m s_m) (* c_m (* x_m s_m)))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * (c_m * (x_m * s_m)));
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (cos((x_m * 2.0d0)) / c_m) / ((x_m * s_m) * (c_m * (x_m * s_m)))
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return (Math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * (c_m * (x_m * s_m)));
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return (math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * (c_m * (x_m * s_m)))
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(Float64(cos(Float64(x_m * 2.0)) / c_m) / Float64(Float64(x_m * s_m) * Float64(c_m * Float64(x_m * s_m)))) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * (c_m * (x_m * s_m)));
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot \left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}
\end{array}
Initial program 70.3%
*-un-lft-identity70.3%
add-sqr-sqrt70.2%
times-frac70.2%
Applied egg-rr97.4%
*-commutative97.4%
associate-/r*97.4%
frac-times94.0%
div-inv94.0%
*-commutative94.0%
Applied egg-rr94.0%
Final simplification94.0%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (* (/ 1.0 (* c_m (* x_m s_m))) (/ (/ (/ 1.0 s_m) x_m) c_m)))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return (1.0 / (c_m * (x_m * s_m))) * (((1.0 / s_m) / x_m) / c_m);
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (1.0d0 / (c_m * (x_m * s_m))) * (((1.0d0 / s_m) / x_m) / c_m)
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return (1.0 / (c_m * (x_m * s_m))) * (((1.0 / s_m) / x_m) / c_m);
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return (1.0 / (c_m * (x_m * s_m))) * (((1.0 / s_m) / x_m) / c_m)
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(Float64(1.0 / Float64(c_m * Float64(x_m * s_m))) * Float64(Float64(Float64(1.0 / s_m) / x_m) / c_m)) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = (1.0 / (c_m * (x_m * s_m))) * (((1.0 / s_m) / x_m) / c_m);
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(N[(1.0 / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{1}{c\_m \cdot \left(x\_m \cdot s\_m\right)} \cdot \frac{\frac{\frac{1}{s\_m}}{x\_m}}{c\_m}
\end{array}
Initial program 70.3%
*-un-lft-identity70.3%
add-sqr-sqrt70.2%
times-frac70.2%
Applied egg-rr97.4%
Taylor expanded in x around 0 80.4%
*-commutative80.4%
associate-/l/80.4%
associate-/l/80.4%
Simplified80.4%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (let* ((t_0 (* c_m (* x_m s_m)))) (/ 1.0 (* t_0 t_0))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return 1.0 / (t_0 * t_0);
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c_m * (x_m * s_m)
code = 1.0d0 / (t_0 * t_0)
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return 1.0 / (t_0 * t_0);
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) return 1.0 / (t_0 * t_0)
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) return Float64(1.0 / Float64(t_0 * t_0)) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
tmp = 1.0 / (t_0 * t_0);
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * 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|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.3%
Taylor expanded in x around 0 60.1%
associate-/r*59.7%
*-commutative59.7%
unpow259.7%
unpow259.7%
swap-sqr69.1%
unpow269.1%
associate-/r*69.5%
unpow269.5%
unpow269.5%
swap-sqr80.4%
unpow280.4%
*-commutative80.4%
Simplified80.4%
*-commutative80.4%
*-commutative80.4%
*-commutative80.4%
unpow280.4%
Applied egg-rr80.4%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (/ 1.0 (* (* c_m s_m) (* x_m (* c_m (* x_m s_m))))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return 1.0 / ((c_m * s_m) * (x_m * (c_m * (x_m * s_m))));
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / ((c_m * s_m) * (x_m * (c_m * (x_m * s_m))))
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return 1.0 / ((c_m * s_m) * (x_m * (c_m * (x_m * s_m))));
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return 1.0 / ((c_m * s_m) * (x_m * (c_m * (x_m * s_m))))
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(1.0 / Float64(Float64(c_m * s_m) * Float64(x_m * Float64(c_m * Float64(x_m * s_m))))) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = 1.0 / ((c_m * s_m) * (x_m * (c_m * (x_m * s_m))));
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(1.0 / N[(N[(c$95$m * s$95$m), $MachinePrecision] * N[(x$95$m * N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{1}{\left(c\_m \cdot s\_m\right) \cdot \left(x\_m \cdot \left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)\right)}
\end{array}
Initial program 70.3%
Taylor expanded in x around 0 60.1%
associate-/r*59.7%
*-commutative59.7%
unpow259.7%
unpow259.7%
swap-sqr69.1%
unpow269.1%
associate-/r*69.5%
unpow269.5%
unpow269.5%
swap-sqr80.4%
unpow280.4%
*-commutative80.4%
Simplified80.4%
unpow280.4%
associate-*r*79.2%
*-commutative79.2%
associate-*l*75.7%
Applied egg-rr75.7%
herbie shell --seed 2024121
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))