
(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 12 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-110) (* (/ 1.0 c_m) (/ (/ (/ 1.0 c_m) (* x_m s_m)) (* x_m s_m))) (/ (cos (* x_m -2.0)) (/ 1.0 (pow (* s_m (* x_m c_m)) -2.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 tmp;
if (x_m <= 1.3e-110) {
tmp = (1.0 / c_m) * (((1.0 / c_m) / (x_m * s_m)) / (x_m * s_m));
} else {
tmp = cos((x_m * -2.0)) / (1.0 / pow((s_m * (x_m * c_m)), -2.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) :: tmp
if (x_m <= 1.3d-110) then
tmp = (1.0d0 / c_m) * (((1.0d0 / c_m) / (x_m * s_m)) / (x_m * s_m))
else
tmp = cos((x_m * (-2.0d0))) / (1.0d0 / ((s_m * (x_m * c_m)) ** (-2.0d0)))
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-110) {
tmp = (1.0 / c_m) * (((1.0 / c_m) / (x_m * s_m)) / (x_m * s_m));
} else {
tmp = Math.cos((x_m * -2.0)) / (1.0 / Math.pow((s_m * (x_m * c_m)), -2.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): tmp = 0 if x_m <= 1.3e-110: tmp = (1.0 / c_m) * (((1.0 / c_m) / (x_m * s_m)) / (x_m * s_m)) else: tmp = math.cos((x_m * -2.0)) / (1.0 / math.pow((s_m * (x_m * c_m)), -2.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) tmp = 0.0 if (x_m <= 1.3e-110) tmp = Float64(Float64(1.0 / c_m) * Float64(Float64(Float64(1.0 / c_m) / Float64(x_m * s_m)) / Float64(x_m * s_m))); else tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(1.0 / (Float64(s_m * Float64(x_m * c_m)) ^ -2.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)
tmp = 0.0;
if (x_m <= 1.3e-110)
tmp = (1.0 / c_m) * (((1.0 / c_m) / (x_m * s_m)) / (x_m * s_m));
else
tmp = cos((x_m * -2.0)) / (1.0 / ((s_m * (x_m * c_m)) ^ -2.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_] := If[LessEqual[x$95$m, 1.3e-110], N[(N[(1.0 / c$95$m), $MachinePrecision] * N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(1.0 / N[Power[N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $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])\\
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 1.3 \cdot 10^{-110}:\\
\;\;\;\;\frac{1}{c_m} \cdot \frac{\frac{\frac{1}{c_m}}{x_m \cdot s_m}}{x_m \cdot s_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{\frac{1}{{\left(s_m \cdot \left(x_m \cdot c_m\right)\right)}^{-2}}}\\
\end{array}
\end{array}
if x < 1.29999999999999995e-110Initial program 64.9%
associate-/r*64.8%
unpow264.8%
sqr-neg64.8%
unpow264.8%
associate-/r*64.9%
cos-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
metadata-eval64.9%
associate-*r*67.8%
*-commutative67.8%
unpow267.8%
sqr-neg67.8%
associate-*l*75.6%
associate-*r*76.2%
associate-*r*73.2%
associate-*r*65.2%
unpow265.2%
Simplified56.3%
Taylor expanded in x around 0 51.4%
associate-/r*51.2%
*-commutative51.2%
unpow251.2%
unpow251.2%
swap-sqr67.9%
unpow267.9%
associate-/r*68.0%
unpow268.0%
unpow268.0%
swap-sqr82.0%
unpow282.0%
*-commutative82.0%
Simplified82.0%
*-commutative82.0%
pow282.0%
associate-*r*81.0%
associate-*l*76.5%
*-commutative76.5%
associate-*r*77.2%
*-commutative77.2%
Applied egg-rr77.2%
metadata-eval77.2%
associate-*r*78.9%
*-commutative78.9%
associate-*r*79.9%
frac-times79.9%
associate-*r/79.9%
*-commutative79.9%
associate-*r*78.2%
times-frac75.3%
associate-*r*78.2%
*-commutative78.2%
associate-*r*79.3%
associate-/r*79.3%
Applied egg-rr79.3%
if 1.29999999999999995e-110 < x Initial program 72.9%
associate-/r*71.8%
unpow271.8%
sqr-neg71.8%
unpow271.8%
associate-/r*72.9%
cos-neg72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
associate-*r*73.1%
*-commutative73.1%
unpow273.1%
sqr-neg73.1%
associate-*l*75.2%
associate-*r*80.7%
associate-*r*78.6%
associate-*r*77.4%
unpow277.4%
Simplified71.8%
Taylor expanded in x around inf 71.8%
associate-/r*70.7%
*-commutative70.7%
unpow270.7%
unpow270.7%
swap-sqr76.4%
unpow276.4%
associate-/r*77.5%
*-commutative77.5%
unpow277.5%
unpow277.5%
swap-sqr96.5%
unpow296.5%
*-commutative96.5%
Simplified96.5%
/-rgt-identity96.5%
clear-num96.5%
pow-flip96.5%
associate-*r*94.4%
*-commutative94.4%
metadata-eval94.4%
Applied egg-rr94.4%
associate-*r*98.6%
*-commutative98.6%
Simplified98.6%
Final simplification86.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 (/ (/ 1.0 s_m) c_m)))
(if (<= x_m 4e+273)
(/ (cos (* x_m -2.0)) (pow (* c_m (* x_m s_m)) 2.0))
(* (* t_0 (/ t_0 x_m)) (/ (cos (* x_m 2.0)) x_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 = (1.0 / s_m) / c_m;
double tmp;
if (x_m <= 4e+273) {
tmp = cos((x_m * -2.0)) / pow((c_m * (x_m * s_m)), 2.0);
} else {
tmp = (t_0 * (t_0 / x_m)) * (cos((x_m * 2.0)) / x_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) :: tmp
t_0 = (1.0d0 / s_m) / c_m
if (x_m <= 4d+273) then
tmp = cos((x_m * (-2.0d0))) / ((c_m * (x_m * s_m)) ** 2.0d0)
else
tmp = (t_0 * (t_0 / x_m)) * (cos((x_m * 2.0d0)) / x_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 = (1.0 / s_m) / c_m;
double tmp;
if (x_m <= 4e+273) {
tmp = Math.cos((x_m * -2.0)) / Math.pow((c_m * (x_m * s_m)), 2.0);
} else {
tmp = (t_0 * (t_0 / x_m)) * (Math.cos((x_m * 2.0)) / x_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 = (1.0 / s_m) / c_m tmp = 0 if x_m <= 4e+273: tmp = math.cos((x_m * -2.0)) / math.pow((c_m * (x_m * s_m)), 2.0) else: tmp = (t_0 * (t_0 / x_m)) * (math.cos((x_m * 2.0)) / x_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 = Float64(Float64(1.0 / s_m) / c_m) tmp = 0.0 if (x_m <= 4e+273) tmp = Float64(cos(Float64(x_m * -2.0)) / (Float64(c_m * Float64(x_m * s_m)) ^ 2.0)); else tmp = Float64(Float64(t_0 * Float64(t_0 / x_m)) * Float64(cos(Float64(x_m * 2.0)) / x_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 = (1.0 / s_m) / c_m;
tmp = 0.0;
if (x_m <= 4e+273)
tmp = cos((x_m * -2.0)) / ((c_m * (x_m * s_m)) ^ 2.0);
else
tmp = (t_0 * (t_0 / x_m)) * (cos((x_m * 2.0)) / x_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[(N[(1.0 / s$95$m), $MachinePrecision] / c$95$m), $MachinePrecision]}, If[LessEqual[x$95$m, 4e+273], 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[(t$95$0 * N[(t$95$0 / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / x$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 := \frac{\frac{1}{s_m}}{c_m}\\
\mathbf{if}\;x_m \leq 4 \cdot 10^{+273}:\\
\;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 \cdot \frac{t_0}{x_m}\right) \cdot \frac{\cos \left(x_m \cdot 2\right)}{x_m}\\
\end{array}
\end{array}
if x < 3.99999999999999978e273Initial program 68.0%
associate-/r*67.5%
unpow267.5%
sqr-neg67.5%
unpow267.5%
associate-/r*68.0%
cos-neg68.0%
*-commutative68.0%
distribute-rgt-neg-in68.0%
metadata-eval68.0%
associate-*r*70.0%
*-commutative70.0%
unpow270.0%
sqr-neg70.0%
associate-*l*75.6%
associate-*r*78.0%
associate-*r*75.2%
associate-*r*69.4%
unpow269.4%
Simplified61.9%
Taylor expanded in x around inf 61.9%
associate-/r*61.4%
*-commutative61.4%
unpow261.4%
unpow261.4%
swap-sqr78.1%
unpow278.1%
associate-/r*78.6%
*-commutative78.6%
unpow278.6%
unpow278.6%
swap-sqr96.6%
unpow296.6%
*-commutative96.6%
Simplified96.6%
if 3.99999999999999978e273 < x Initial program 57.1%
associate-/r*57.1%
unpow257.1%
sqr-neg57.1%
unpow257.1%
associate-/r*57.1%
cos-neg57.1%
*-commutative57.1%
distribute-rgt-neg-in57.1%
metadata-eval57.1%
associate-*r*57.1%
*-commutative57.1%
unpow257.1%
sqr-neg57.1%
associate-*l*71.4%
associate-*r*71.4%
associate-*r*71.4%
associate-*r*71.4%
unpow271.4%
Simplified57.1%
Taylor expanded in x around inf 57.1%
associate-/r*57.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr71.4%
unpow271.4%
associate-/r*71.4%
*-commutative71.4%
unpow271.4%
unpow271.4%
swap-sqr72.1%
unpow272.1%
*-commutative72.1%
Simplified72.1%
add-sqr-sqrt42.9%
add-sqr-sqrt72.1%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
swap-sqr0.0%
metadata-eval0.0%
metadata-eval0.0%
swap-sqr0.0%
*-commutative0.0%
*-commutative0.0%
sqrt-unprod72.1%
add-sqr-sqrt72.1%
associate-*r*85.5%
pow-prod-down71.4%
associate-/r*71.4%
*-un-lft-identity71.4%
associate-*l/71.4%
unpow271.4%
Applied egg-rr71.8%
metadata-eval71.8%
pow-prod-up71.8%
inv-pow71.8%
associate-/l/71.8%
inv-pow71.8%
associate-/l/71.8%
*-un-lft-identity71.8%
times-frac85.5%
Applied egg-rr85.5%
Final simplification96.3%
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 (/ (/ 1.0 s_m) c_m))
(t_1 (* c_m (* x_m s_m)))
(t_2 (cos (* x_m 2.0))))
(if (<= x_m 4e+273)
(* (/ 1.0 t_1) (/ t_2 t_1))
(* (* t_0 (/ t_0 x_m)) (/ t_2 x_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 = (1.0 / s_m) / c_m;
double t_1 = c_m * (x_m * s_m);
double t_2 = cos((x_m * 2.0));
double tmp;
if (x_m <= 4e+273) {
tmp = (1.0 / t_1) * (t_2 / t_1);
} else {
tmp = (t_0 * (t_0 / x_m)) * (t_2 / x_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) :: t_2
real(8) :: tmp
t_0 = (1.0d0 / s_m) / c_m
t_1 = c_m * (x_m * s_m)
t_2 = cos((x_m * 2.0d0))
if (x_m <= 4d+273) then
tmp = (1.0d0 / t_1) * (t_2 / t_1)
else
tmp = (t_0 * (t_0 / x_m)) * (t_2 / x_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 = (1.0 / s_m) / c_m;
double t_1 = c_m * (x_m * s_m);
double t_2 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 4e+273) {
tmp = (1.0 / t_1) * (t_2 / t_1);
} else {
tmp = (t_0 * (t_0 / x_m)) * (t_2 / x_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 = (1.0 / s_m) / c_m t_1 = c_m * (x_m * s_m) t_2 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 4e+273: tmp = (1.0 / t_1) * (t_2 / t_1) else: tmp = (t_0 * (t_0 / x_m)) * (t_2 / x_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 = Float64(Float64(1.0 / s_m) / c_m) t_1 = Float64(c_m * Float64(x_m * s_m)) t_2 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 4e+273) tmp = Float64(Float64(1.0 / t_1) * Float64(t_2 / t_1)); else tmp = Float64(Float64(t_0 * Float64(t_0 / x_m)) * Float64(t_2 / x_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 = (1.0 / s_m) / c_m;
t_1 = c_m * (x_m * s_m);
t_2 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 4e+273)
tmp = (1.0 / t_1) * (t_2 / t_1);
else
tmp = (t_0 * (t_0 / x_m)) * (t_2 / x_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[(N[(1.0 / s$95$m), $MachinePrecision] / c$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 4e+273], N[(N[(1.0 / t$95$1), $MachinePrecision] * N[(t$95$2 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(t$95$0 / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 / x$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 := \frac{\frac{1}{s_m}}{c_m}\\
t_1 := c_m \cdot \left(x_m \cdot s_m\right)\\
t_2 := \cos \left(x_m \cdot 2\right)\\
\mathbf{if}\;x_m \leq 4 \cdot 10^{+273}:\\
\;\;\;\;\frac{1}{t_1} \cdot \frac{t_2}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 \cdot \frac{t_0}{x_m}\right) \cdot \frac{t_2}{x_m}\\
\end{array}
\end{array}
if x < 3.99999999999999978e273Initial program 68.0%
associate-/r*67.5%
unpow267.5%
sqr-neg67.5%
unpow267.5%
associate-/r*68.0%
cos-neg68.0%
*-commutative68.0%
distribute-rgt-neg-in68.0%
metadata-eval68.0%
associate-*r*70.0%
*-commutative70.0%
unpow270.0%
sqr-neg70.0%
associate-*l*75.6%
associate-*r*78.0%
associate-*r*75.2%
associate-*r*69.4%
unpow269.4%
Simplified61.9%
*-un-lft-identity61.9%
add-sqr-sqrt61.9%
times-frac61.8%
sqrt-prod61.9%
unpow261.9%
sqrt-prod30.9%
add-sqr-sqrt44.0%
pow-prod-down44.0%
sqrt-pow142.3%
metadata-eval42.3%
pow142.3%
*-commutative42.3%
Applied egg-rr96.6%
if 3.99999999999999978e273 < x Initial program 57.1%
associate-/r*57.1%
unpow257.1%
sqr-neg57.1%
unpow257.1%
associate-/r*57.1%
cos-neg57.1%
*-commutative57.1%
distribute-rgt-neg-in57.1%
metadata-eval57.1%
associate-*r*57.1%
*-commutative57.1%
unpow257.1%
sqr-neg57.1%
associate-*l*71.4%
associate-*r*71.4%
associate-*r*71.4%
associate-*r*71.4%
unpow271.4%
Simplified57.1%
Taylor expanded in x around inf 57.1%
associate-/r*57.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr71.4%
unpow271.4%
associate-/r*71.4%
*-commutative71.4%
unpow271.4%
unpow271.4%
swap-sqr72.1%
unpow272.1%
*-commutative72.1%
Simplified72.1%
add-sqr-sqrt42.9%
add-sqr-sqrt72.1%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
swap-sqr0.0%
metadata-eval0.0%
metadata-eval0.0%
swap-sqr0.0%
*-commutative0.0%
*-commutative0.0%
sqrt-unprod72.1%
add-sqr-sqrt72.1%
associate-*r*85.5%
pow-prod-down71.4%
associate-/r*71.4%
*-un-lft-identity71.4%
associate-*l/71.4%
unpow271.4%
Applied egg-rr71.8%
metadata-eval71.8%
pow-prod-up71.8%
inv-pow71.8%
associate-/l/71.8%
inv-pow71.8%
associate-/l/71.8%
*-un-lft-identity71.8%
times-frac85.5%
Applied egg-rr85.5%
Final simplification96.3%
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))))
(if (<= x_m 3.8e+275)
(* (/ 1.0 t_0) (/ (cos (* x_m 2.0)) t_0))
(/ (cos (* x_m -2.0)) (* s_m (* (* x_m c_m) (* x_m (* c_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 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 3.8e+275) {
tmp = (1.0 / t_0) * (cos((x_m * 2.0)) / t_0);
} else {
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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) :: tmp
t_0 = c_m * (x_m * s_m)
if (x_m <= 3.8d+275) then
tmp = (1.0d0 / t_0) * (cos((x_m * 2.0d0)) / t_0)
else
tmp = cos((x_m * (-2.0d0))) / (s_m * ((x_m * c_m) * (x_m * (c_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 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 3.8e+275) {
tmp = (1.0 / t_0) * (Math.cos((x_m * 2.0)) / t_0);
} else {
tmp = Math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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 = c_m * (x_m * s_m) tmp = 0 if x_m <= 3.8e+275: tmp = (1.0 / t_0) * (math.cos((x_m * 2.0)) / t_0) else: tmp = math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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 = Float64(c_m * Float64(x_m * s_m)) tmp = 0.0 if (x_m <= 3.8e+275) tmp = Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x_m * 2.0)) / t_0)); else tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(s_m * Float64(Float64(x_m * c_m) * Float64(x_m * Float64(c_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 = c_m * (x_m * s_m);
tmp = 0.0;
if (x_m <= 3.8e+275)
tmp = (1.0 / t_0) * (cos((x_m * 2.0)) / t_0);
else
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 3.8e+275], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(x$95$m * N[(c$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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x_m \cdot s_m\right)\\
\mathbf{if}\;x_m \leq 3.8 \cdot 10^{+275}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\cos \left(x_m \cdot 2\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{s_m \cdot \left(\left(x_m \cdot c_m\right) \cdot \left(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}\\
\end{array}
\end{array}
if x < 3.80000000000000012e275Initial program 68.0%
associate-/r*67.5%
unpow267.5%
sqr-neg67.5%
unpow267.5%
associate-/r*68.0%
cos-neg68.0%
*-commutative68.0%
distribute-rgt-neg-in68.0%
metadata-eval68.0%
associate-*r*70.0%
*-commutative70.0%
unpow270.0%
sqr-neg70.0%
associate-*l*75.6%
associate-*r*78.0%
associate-*r*75.2%
associate-*r*69.4%
unpow269.4%
Simplified61.9%
*-un-lft-identity61.9%
add-sqr-sqrt61.9%
times-frac61.8%
sqrt-prod61.9%
unpow261.9%
sqrt-prod30.9%
add-sqr-sqrt44.0%
pow-prod-down44.0%
sqrt-pow142.3%
metadata-eval42.3%
pow142.3%
*-commutative42.3%
Applied egg-rr96.6%
if 3.80000000000000012e275 < x Initial program 57.1%
associate-/r*57.1%
unpow257.1%
sqr-neg57.1%
unpow257.1%
associate-/r*57.1%
cos-neg57.1%
*-commutative57.1%
distribute-rgt-neg-in57.1%
metadata-eval57.1%
associate-*r*57.1%
*-commutative57.1%
unpow257.1%
sqr-neg57.1%
associate-*l*71.4%
associate-*r*71.4%
associate-*r*71.4%
associate-*r*71.4%
unpow271.4%
Simplified57.1%
Taylor expanded in x around inf 57.1%
associate-/r*57.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr71.4%
unpow271.4%
associate-/r*71.4%
*-commutative71.4%
unpow271.4%
unpow271.4%
swap-sqr72.1%
unpow272.1%
*-commutative72.1%
Simplified72.1%
*-commutative72.1%
pow272.1%
associate-*r*72.1%
associate-*r*72.1%
*-commutative72.1%
associate-*r*85.4%
*-commutative85.4%
Applied egg-rr85.4%
Final simplification96.3%
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))))
(if (<= x_m 1.55e-29)
(/ (/ 1.0 t_0) t_0)
(/ (cos (* x_m -2.0)) (* s_m (* (* x_m c_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 * (x_m * s_m);
double tmp;
if (x_m <= 1.55e-29) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_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 * (x_m * s_m)
if (x_m <= 1.55d-29) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = cos((x_m * (-2.0d0))) / (s_m * ((x_m * c_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 * (x_m * s_m);
double tmp;
if (x_m <= 1.55e-29) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = Math.cos((x_m * -2.0)) / (s_m * ((x_m * c_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 * (x_m * s_m) tmp = 0 if x_m <= 1.55e-29: tmp = (1.0 / t_0) / t_0 else: tmp = math.cos((x_m * -2.0)) / (s_m * ((x_m * c_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 * Float64(x_m * s_m)) tmp = 0.0 if (x_m <= 1.55e-29) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(s_m * Float64(Float64(x_m * c_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 * (x_m * s_m);
tmp = 0.0;
if (x_m <= 1.55e-29)
tmp = (1.0 / t_0) / t_0;
else
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_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[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.55e-29], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c$95$m), $MachinePrecision] * t$95$0), $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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x_m \cdot s_m\right)\\
\mathbf{if}\;x_m \leq 1.55 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{s_m \cdot \left(\left(x_m \cdot c_m\right) \cdot t_0\right)}\\
\end{array}
\end{array}
if x < 1.55000000000000013e-29Initial program 67.2%
associate-/r*67.1%
unpow267.1%
sqr-neg67.1%
unpow267.1%
associate-/r*67.2%
cos-neg67.2%
*-commutative67.2%
distribute-rgt-neg-in67.2%
metadata-eval67.2%
associate-*r*69.8%
*-commutative69.8%
unpow269.8%
sqr-neg69.8%
associate-*l*76.7%
associate-*r*77.3%
associate-*r*74.6%
associate-*r*67.5%
unpow267.5%
Simplified59.6%
Taylor expanded in x around 0 55.2%
associate-/r*55.1%
*-commutative55.1%
unpow255.1%
unpow255.1%
swap-sqr69.9%
unpow269.9%
associate-/r*70.0%
unpow270.0%
unpow270.0%
swap-sqr84.0%
unpow284.0%
*-commutative84.0%
Simplified84.0%
expm1-log1p-u82.9%
expm1-udef72.0%
pow-flip72.0%
associate-*r*73.4%
*-commutative73.4%
metadata-eval73.4%
Applied egg-rr73.4%
expm1-def80.9%
expm1-log1p82.2%
associate-*r*84.7%
*-commutative84.7%
Simplified84.7%
*-commutative84.7%
associate-*r*82.2%
metadata-eval82.2%
pow-flip82.1%
unpow282.1%
associate-/r*82.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*80.6%
associate-*r*83.2%
*-commutative83.2%
associate-*l*84.1%
Applied egg-rr84.1%
if 1.55000000000000013e-29 < x Initial program 69.0%
associate-/r*67.6%
unpow267.6%
sqr-neg67.6%
unpow267.6%
associate-/r*69.0%
cos-neg69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
associate-*r*69.3%
*-commutative69.3%
unpow269.3%
sqr-neg69.3%
associate-*l*72.1%
associate-*r*79.0%
associate-*r*76.4%
associate-*r*74.9%
unpow274.9%
Simplified67.6%
Taylor expanded in x around inf 67.6%
associate-/r*66.1%
*-commutative66.1%
unpow266.1%
unpow266.1%
swap-sqr73.6%
unpow273.6%
associate-/r*75.0%
*-commutative75.0%
unpow275.0%
unpow275.0%
swap-sqr95.4%
unpow295.4%
*-commutative95.4%
Simplified95.4%
/-rgt-identity95.4%
clear-num95.4%
pow-flip95.5%
associate-*r*92.7%
*-commutative92.7%
metadata-eval92.7%
Applied egg-rr92.7%
associate-*r*98.1%
*-commutative98.1%
Simplified98.1%
pow-flip98.1%
*-commutative98.1%
associate-*r*92.7%
metadata-eval92.7%
unpow292.7%
associate-*r*92.8%
*-commutative92.8%
associate-*r*87.5%
associate-*r*92.9%
*-commutative92.9%
associate-*l*90.2%
Applied egg-rr90.2%
Final simplification85.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 (* x_m s_m))))
(if (<= x_m 8e-29)
(/ (/ 1.0 t_0) t_0)
(/ (cos (* x_m -2.0)) (* s_m (* (* x_m c_m) (* x_m (* c_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 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 8e-29) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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) :: tmp
t_0 = c_m * (x_m * s_m)
if (x_m <= 8d-29) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = cos((x_m * (-2.0d0))) / (s_m * ((x_m * c_m) * (x_m * (c_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 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 8e-29) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = Math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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 = c_m * (x_m * s_m) tmp = 0 if x_m <= 8e-29: tmp = (1.0 / t_0) / t_0 else: tmp = math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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 = Float64(c_m * Float64(x_m * s_m)) tmp = 0.0 if (x_m <= 8e-29) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(s_m * Float64(Float64(x_m * c_m) * Float64(x_m * Float64(c_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 = c_m * (x_m * s_m);
tmp = 0.0;
if (x_m <= 8e-29)
tmp = (1.0 / t_0) / t_0;
else
tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (x_m * (c_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[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 8e-29], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(x$95$m * N[(c$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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x_m \cdot s_m\right)\\
\mathbf{if}\;x_m \leq 8 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{s_m \cdot \left(\left(x_m \cdot c_m\right) \cdot \left(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}\\
\end{array}
\end{array}
if x < 7.99999999999999955e-29Initial program 67.2%
associate-/r*67.1%
unpow267.1%
sqr-neg67.1%
unpow267.1%
associate-/r*67.2%
cos-neg67.2%
*-commutative67.2%
distribute-rgt-neg-in67.2%
metadata-eval67.2%
associate-*r*69.8%
*-commutative69.8%
unpow269.8%
sqr-neg69.8%
associate-*l*76.7%
associate-*r*77.3%
associate-*r*74.6%
associate-*r*67.5%
unpow267.5%
Simplified59.6%
Taylor expanded in x around 0 55.2%
associate-/r*55.1%
*-commutative55.1%
unpow255.1%
unpow255.1%
swap-sqr69.9%
unpow269.9%
associate-/r*70.0%
unpow270.0%
unpow270.0%
swap-sqr84.0%
unpow284.0%
*-commutative84.0%
Simplified84.0%
expm1-log1p-u82.9%
expm1-udef72.0%
pow-flip72.0%
associate-*r*73.4%
*-commutative73.4%
metadata-eval73.4%
Applied egg-rr73.4%
expm1-def80.9%
expm1-log1p82.2%
associate-*r*84.7%
*-commutative84.7%
Simplified84.7%
*-commutative84.7%
associate-*r*82.2%
metadata-eval82.2%
pow-flip82.1%
unpow282.1%
associate-/r*82.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*80.6%
associate-*r*83.2%
*-commutative83.2%
associate-*l*84.1%
Applied egg-rr84.1%
if 7.99999999999999955e-29 < x Initial program 69.0%
associate-/r*67.6%
unpow267.6%
sqr-neg67.6%
unpow267.6%
associate-/r*69.0%
cos-neg69.0%
*-commutative69.0%
distribute-rgt-neg-in69.0%
metadata-eval69.0%
associate-*r*69.3%
*-commutative69.3%
unpow269.3%
sqr-neg69.3%
associate-*l*72.1%
associate-*r*79.0%
associate-*r*76.4%
associate-*r*74.9%
unpow274.9%
Simplified67.6%
Taylor expanded in x around inf 67.6%
associate-/r*66.1%
*-commutative66.1%
unpow266.1%
unpow266.1%
swap-sqr73.6%
unpow273.6%
associate-/r*75.0%
*-commutative75.0%
unpow275.0%
unpow275.0%
swap-sqr95.4%
unpow295.4%
*-commutative95.4%
Simplified95.4%
*-commutative95.4%
pow295.4%
associate-*r*95.5%
associate-*r*90.2%
*-commutative90.2%
associate-*r*87.5%
*-commutative87.5%
Applied egg-rr87.5%
Final simplification85.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 (/ (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(cos(Float64(x_m * -2.0)) / Float64(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[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(c$95$m * N[(N[(x$95$m * s$95$m), $MachinePrecision] * 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{\cos \left(x_m \cdot -2\right)}{c_m \cdot \left(\left(x_m \cdot s_m\right) \cdot \left(c_m \cdot \left(x_m \cdot s_m\right)\right)\right)}
\end{array}
Initial program 67.7%
associate-/r*67.2%
unpow267.2%
sqr-neg67.2%
unpow267.2%
associate-/r*67.7%
cos-neg67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
metadata-eval67.7%
associate-*r*69.7%
*-commutative69.7%
unpow269.7%
sqr-neg69.7%
associate-*l*75.5%
associate-*r*77.8%
associate-*r*75.1%
associate-*r*69.5%
unpow269.5%
Simplified61.7%
Taylor expanded in x around inf 61.7%
associate-/r*61.3%
*-commutative61.3%
unpow261.3%
unpow261.3%
swap-sqr77.9%
unpow277.9%
associate-/r*78.4%
*-commutative78.4%
unpow278.4%
unpow278.4%
swap-sqr96.0%
unpow296.0%
*-commutative96.0%
Simplified96.0%
/-rgt-identity96.0%
clear-num96.0%
pow-flip96.0%
associate-*r*94.8%
*-commutative94.8%
metadata-eval94.8%
Applied egg-rr94.8%
associate-*r*98.1%
*-commutative98.1%
Simplified98.1%
pow-flip98.1%
metadata-eval98.1%
*-commutative98.1%
associate-*r*94.8%
unpow294.8%
*-commutative94.8%
associate-*r*91.1%
associate-*l*90.3%
associate-*r*90.7%
*-commutative90.7%
associate-*l*88.5%
associate-*r*91.8%
*-commutative91.8%
associate-*l*92.8%
*-commutative92.8%
Applied egg-rr92.8%
Final simplification92.8%
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 (<= s_m 1.3e+179) (/ 1.0 (* (* x_m c_m) (* s_m (* c_m (* x_m s_m))))) (/ 1.0 (* (* c_m s_m) (* x_m (* x_m (* c_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 (s_m <= 1.3e+179) {
tmp = 1.0 / ((x_m * c_m) * (s_m * (c_m * (x_m * s_m))));
} else {
tmp = 1.0 / ((c_m * s_m) * (x_m * (x_m * (c_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 (s_m <= 1.3d+179) then
tmp = 1.0d0 / ((x_m * c_m) * (s_m * (c_m * (x_m * s_m))))
else
tmp = 1.0d0 / ((c_m * s_m) * (x_m * (x_m * (c_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 (s_m <= 1.3e+179) {
tmp = 1.0 / ((x_m * c_m) * (s_m * (c_m * (x_m * s_m))));
} else {
tmp = 1.0 / ((c_m * s_m) * (x_m * (x_m * (c_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 s_m <= 1.3e+179: tmp = 1.0 / ((x_m * c_m) * (s_m * (c_m * (x_m * s_m)))) else: tmp = 1.0 / ((c_m * s_m) * (x_m * (x_m * (c_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 (s_m <= 1.3e+179) tmp = Float64(1.0 / Float64(Float64(x_m * c_m) * Float64(s_m * Float64(c_m * Float64(x_m * s_m))))); else tmp = Float64(1.0 / Float64(Float64(c_m * s_m) * Float64(x_m * Float64(x_m * Float64(c_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 (s_m <= 1.3e+179)
tmp = 1.0 / ((x_m * c_m) * (s_m * (c_m * (x_m * s_m))));
else
tmp = 1.0 / ((c_m * s_m) * (x_m * (x_m * (c_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[s$95$m, 1.3e+179], N[(1.0 / N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(s$95$m * N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c$95$m * s$95$m), $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[(c$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])\\
\\
\begin{array}{l}
\mathbf{if}\;s_m \leq 1.3 \cdot 10^{+179}:\\
\;\;\;\;\frac{1}{\left(x_m \cdot c_m\right) \cdot \left(s_m \cdot \left(c_m \cdot \left(x_m \cdot s_m\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(c_m \cdot s_m\right) \cdot \left(x_m \cdot \left(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}\\
\end{array}
\end{array}
if s < 1.3000000000000001e179Initial program 68.0%
associate-/r*67.4%
unpow267.4%
sqr-neg67.4%
unpow267.4%
associate-/r*68.0%
cos-neg68.0%
*-commutative68.0%
distribute-rgt-neg-in68.0%
metadata-eval68.0%
associate-*r*70.1%
*-commutative70.1%
unpow270.1%
sqr-neg70.1%
associate-*l*76.6%
associate-*r*78.3%
associate-*r*74.9%
associate-*r*69.8%
unpow269.8%
Simplified62.3%
Taylor expanded in x around 0 56.3%
associate-/r*55.8%
*-commutative55.8%
unpow255.8%
unpow255.8%
swap-sqr65.7%
unpow265.7%
associate-/r*66.2%
unpow266.2%
unpow266.2%
swap-sqr77.0%
unpow277.0%
*-commutative77.0%
Simplified77.0%
*-commutative77.0%
pow277.0%
associate-*r*76.3%
associate-*l*74.6%
*-commutative74.6%
associate-*r*74.9%
*-commutative74.9%
Applied egg-rr74.9%
Taylor expanded in x around 0 74.6%
if 1.3000000000000001e179 < s Initial program 65.4%
associate-/r*65.4%
unpow265.4%
sqr-neg65.4%
unpow265.4%
associate-/r*65.4%
cos-neg65.4%
*-commutative65.4%
distribute-rgt-neg-in65.4%
metadata-eval65.4%
associate-*r*65.4%
*-commutative65.4%
unpow265.4%
sqr-neg65.4%
associate-*l*65.4%
associate-*r*73.0%
associate-*r*76.5%
associate-*r*66.4%
unpow266.4%
Simplified56.5%
Taylor expanded in x around 0 56.5%
associate-/r*56.5%
*-commutative56.5%
unpow256.5%
unpow256.5%
swap-sqr80.5%
unpow280.5%
associate-/r*80.6%
unpow280.6%
unpow280.6%
swap-sqr94.9%
unpow294.9%
*-commutative94.9%
Simplified94.9%
unpow294.9%
associate-*r*83.8%
*-commutative83.8%
associate-*l*83.9%
*-commutative83.9%
associate-*r*84.1%
*-commutative84.1%
Applied egg-rr84.1%
Final simplification75.5%
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))))
(if (<= x_m 5.2e+70)
(/ 1.0 (* c_m (* (* x_m s_m) (* x_m (* c_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);
double tmp;
if (x_m <= 5.2e+70) {
tmp = 1.0 / (c_m * ((x_m * s_m) * (x_m * (c_m * s_m))));
} else {
tmp = (-1.0 / 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) :: tmp
t_0 = c_m * (x_m * s_m)
if (x_m <= 5.2d+70) then
tmp = 1.0d0 / (c_m * ((x_m * s_m) * (x_m * (c_m * s_m))))
else
tmp = ((-1.0d0) / 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 tmp;
if (x_m <= 5.2e+70) {
tmp = 1.0 / (c_m * ((x_m * s_m) * (x_m * (c_m * s_m))));
} else {
tmp = (-1.0 / 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) tmp = 0 if x_m <= 5.2e+70: tmp = 1.0 / (c_m * ((x_m * s_m) * (x_m * (c_m * s_m)))) else: tmp = (-1.0 / 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)) tmp = 0.0 if (x_m <= 5.2e+70) tmp = Float64(1.0 / Float64(c_m * Float64(Float64(x_m * s_m) * Float64(x_m * Float64(c_m * s_m))))); else tmp = Float64(Float64(-1.0 / 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);
tmp = 0.0;
if (x_m <= 5.2e+70)
tmp = 1.0 / (c_m * ((x_m * s_m) * (x_m * (c_m * s_m))));
else
tmp = (-1.0 / 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]}, If[LessEqual[x$95$m, 5.2e+70], N[(1.0 / N[(c$95$m * N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / 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)\\
\mathbf{if}\;x_m \leq 5.2 \cdot 10^{+70}:\\
\;\;\;\;\frac{1}{c_m \cdot \left(\left(x_m \cdot s_m\right) \cdot \left(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{t_0}}{t_0}\\
\end{array}
\end{array}
if x < 5.2000000000000001e70Initial program 67.7%
associate-/r*67.6%
unpow267.6%
sqr-neg67.6%
unpow267.6%
associate-/r*67.7%
cos-neg67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
metadata-eval67.7%
associate-*r*70.1%
*-commutative70.1%
unpow270.1%
sqr-neg70.1%
associate-*l*76.2%
associate-*r*78.2%
associate-*r*75.7%
associate-*r*69.3%
unpow269.3%
Simplified60.9%
Taylor expanded in x around 0 56.4%
associate-/r*56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr69.7%
unpow269.7%
associate-/r*69.8%
unpow269.8%
unpow269.8%
swap-sqr83.2%
unpow283.2%
*-commutative83.2%
Simplified83.2%
unpow283.2%
*-commutative83.2%
*-commutative83.2%
associate-*r*80.6%
*-commutative80.6%
associate-*r*77.4%
*-commutative77.4%
Applied egg-rr77.4%
if 5.2000000000000001e70 < x Initial program 67.6%
associate-/r*65.6%
unpow265.6%
sqr-neg65.6%
unpow265.6%
associate-/r*67.6%
cos-neg67.6%
*-commutative67.6%
distribute-rgt-neg-in67.6%
metadata-eval67.6%
associate-*r*68.0%
*-commutative68.0%
unpow268.0%
sqr-neg68.0%
associate-*l*72.0%
associate-*r*76.0%
associate-*r*72.2%
associate-*r*70.1%
unpow270.1%
Simplified65.6%
Taylor expanded in x around 0 55.8%
associate-/r*53.7%
*-commutative53.7%
unpow253.7%
unpow253.7%
swap-sqr56.0%
unpow256.0%
associate-/r*58.1%
unpow258.1%
unpow258.1%
swap-sqr59.6%
unpow259.6%
*-commutative59.6%
Simplified59.6%
expm1-log1p-u59.6%
expm1-udef59.4%
pow-flip59.4%
associate-*r*58.6%
*-commutative58.6%
metadata-eval58.6%
Applied egg-rr58.6%
expm1-def59.0%
expm1-log1p59.0%
associate-*r*59.8%
*-commutative59.8%
Simplified59.8%
*-commutative59.8%
associate-*r*59.0%
metadata-eval59.0%
pow-flip59.0%
frac-2neg59.0%
metadata-eval59.0%
add-sqr-sqrt4.3%
associate-/r*4.3%
add-sqr-sqrt2.5%
sqrt-unprod2.5%
sqr-neg2.5%
sqrt-unprod2.5%
add-sqr-sqrt2.5%
sqrt-pow10.4%
metadata-eval0.4%
pow10.4%
Applied egg-rr63.5%
Final simplification74.8%
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)))) (if (<= x_m 5.2e+70) (/ (/ 1.0 t_0) t_0) (/ (/ -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);
double tmp;
if (x_m <= 5.2e+70) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (-1.0 / 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) :: tmp
t_0 = c_m * (x_m * s_m)
if (x_m <= 5.2d+70) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = ((-1.0d0) / 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 tmp;
if (x_m <= 5.2e+70) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (-1.0 / 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) tmp = 0 if x_m <= 5.2e+70: tmp = (1.0 / t_0) / t_0 else: tmp = (-1.0 / 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)) tmp = 0.0 if (x_m <= 5.2e+70) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(Float64(-1.0 / 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);
tmp = 0.0;
if (x_m <= 5.2e+70)
tmp = (1.0 / t_0) / t_0;
else
tmp = (-1.0 / 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]}, If[LessEqual[x$95$m, 5.2e+70], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(-1.0 / 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)\\
\mathbf{if}\;x_m \leq 5.2 \cdot 10^{+70}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{t_0}}{t_0}\\
\end{array}
\end{array}
if x < 5.2000000000000001e70Initial program 67.7%
associate-/r*67.6%
unpow267.6%
sqr-neg67.6%
unpow267.6%
associate-/r*67.7%
cos-neg67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
metadata-eval67.7%
associate-*r*70.1%
*-commutative70.1%
unpow270.1%
sqr-neg70.1%
associate-*l*76.2%
associate-*r*78.2%
associate-*r*75.7%
associate-*r*69.3%
unpow269.3%
Simplified60.9%
Taylor expanded in x around 0 56.4%
associate-/r*56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr69.7%
unpow269.7%
associate-/r*69.8%
unpow269.8%
unpow269.8%
swap-sqr83.2%
unpow283.2%
*-commutative83.2%
Simplified83.2%
expm1-log1p-u82.2%
expm1-udef72.0%
pow-flip72.0%
associate-*r*73.2%
*-commutative73.2%
metadata-eval73.2%
Applied egg-rr73.2%
expm1-def80.4%
expm1-log1p81.5%
associate-*r*83.8%
*-commutative83.8%
Simplified83.8%
*-commutative83.8%
associate-*r*81.5%
metadata-eval81.5%
pow-flip81.5%
unpow281.5%
associate-/r*81.5%
associate-*r*80.7%
*-commutative80.7%
associate-*l*80.1%
associate-*r*82.4%
*-commutative82.4%
associate-*l*83.2%
Applied egg-rr83.2%
if 5.2000000000000001e70 < x Initial program 67.6%
associate-/r*65.6%
unpow265.6%
sqr-neg65.6%
unpow265.6%
associate-/r*67.6%
cos-neg67.6%
*-commutative67.6%
distribute-rgt-neg-in67.6%
metadata-eval67.6%
associate-*r*68.0%
*-commutative68.0%
unpow268.0%
sqr-neg68.0%
associate-*l*72.0%
associate-*r*76.0%
associate-*r*72.2%
associate-*r*70.1%
unpow270.1%
Simplified65.6%
Taylor expanded in x around 0 55.8%
associate-/r*53.7%
*-commutative53.7%
unpow253.7%
unpow253.7%
swap-sqr56.0%
unpow256.0%
associate-/r*58.1%
unpow258.1%
unpow258.1%
swap-sqr59.6%
unpow259.6%
*-commutative59.6%
Simplified59.6%
expm1-log1p-u59.6%
expm1-udef59.4%
pow-flip59.4%
associate-*r*58.6%
*-commutative58.6%
metadata-eval58.6%
Applied egg-rr58.6%
expm1-def59.0%
expm1-log1p59.0%
associate-*r*59.8%
*-commutative59.8%
Simplified59.8%
*-commutative59.8%
associate-*r*59.0%
metadata-eval59.0%
pow-flip59.0%
frac-2neg59.0%
metadata-eval59.0%
add-sqr-sqrt4.3%
associate-/r*4.3%
add-sqr-sqrt2.5%
sqrt-unprod2.5%
sqr-neg2.5%
sqrt-unprod2.5%
add-sqr-sqrt2.5%
sqrt-pow10.4%
metadata-eval0.4%
pow10.4%
Applied egg-rr63.5%
Final simplification79.5%
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 (* x_m (* c_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 * (x_m * (c_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 * (x_m * (c_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 * (x_m * (c_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 * (x_m * (c_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(x_m * Float64(c_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 * (x_m * (c_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[(x$95$m * N[(c$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(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}
\end{array}
Initial program 67.7%
associate-/r*67.2%
unpow267.2%
sqr-neg67.2%
unpow267.2%
associate-/r*67.7%
cos-neg67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
metadata-eval67.7%
associate-*r*69.7%
*-commutative69.7%
unpow269.7%
sqr-neg69.7%
associate-*l*75.5%
associate-*r*77.8%
associate-*r*75.1%
associate-*r*69.5%
unpow269.5%
Simplified61.7%
Taylor expanded in x around 0 56.3%
associate-/r*55.9%
*-commutative55.9%
unpow255.9%
unpow255.9%
swap-sqr67.1%
unpow267.1%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.8%
unpow278.8%
*-commutative78.8%
Simplified78.8%
unpow278.8%
associate-*r*76.1%
*-commutative76.1%
associate-*l*73.7%
*-commutative73.7%
associate-*r*74.0%
*-commutative74.0%
Applied egg-rr74.0%
Final simplification74.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 (* (* x_m s_m) (* c_m (* x_m (* c_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 / ((x_m * s_m) * (c_m * (x_m * (c_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 / ((x_m * s_m) * (c_m * (x_m * (c_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 / ((x_m * s_m) * (c_m * (x_m * (c_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 / ((x_m * s_m) * (c_m * (x_m * (c_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(x_m * s_m) * Float64(c_m * Float64(x_m * Float64(c_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 / ((x_m * s_m) * (c_m * (x_m * (c_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[(x$95$m * s$95$m), $MachinePrecision] * N[(c$95$m * N[(x$95$m * N[(c$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(x_m \cdot s_m\right) \cdot \left(c_m \cdot \left(x_m \cdot \left(c_m \cdot s_m\right)\right)\right)}
\end{array}
Initial program 67.7%
associate-/r*67.2%
unpow267.2%
sqr-neg67.2%
unpow267.2%
associate-/r*67.7%
cos-neg67.7%
*-commutative67.7%
distribute-rgt-neg-in67.7%
metadata-eval67.7%
associate-*r*69.7%
*-commutative69.7%
unpow269.7%
sqr-neg69.7%
associate-*l*75.5%
associate-*r*77.8%
associate-*r*75.1%
associate-*r*69.5%
unpow269.5%
Simplified61.7%
Taylor expanded in x around 0 56.3%
associate-/r*55.9%
*-commutative55.9%
unpow255.9%
unpow255.9%
swap-sqr67.1%
unpow267.1%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.8%
unpow278.8%
*-commutative78.8%
Simplified78.8%
unpow278.8%
*-commutative78.8%
associate-*r*77.1%
*-commutative77.1%
associate-*r*75.2%
*-commutative75.2%
Applied egg-rr75.2%
Final simplification75.2%
herbie shell --seed 2023332
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))