
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
x_m = (fabs.f64 x) 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 3.4e-184) (/ (/ (/ 1.0 c_m) (* x_m s_m)) (* c_m (* x_m s_m))) (* (cos (* x_m 2.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 <= 3.4e-184) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = cos((x_m * 2.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 <= 3.4d-184) then
tmp = ((1.0d0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m))
else
tmp = cos((x_m * 2.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 <= 3.4e-184) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = Math.cos((x_m * 2.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 <= 3.4e-184: tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m)) else: tmp = math.cos((x_m * 2.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 <= 3.4e-184) tmp = Float64(Float64(Float64(1.0 / c_m) / Float64(x_m * s_m)) / Float64(c_m * Float64(x_m * s_m))); else tmp = Float64(cos(Float64(x_m * 2.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 <= 3.4e-184)
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
else
tmp = cos((x_m * 2.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, 3.4e-184], N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision], -2.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}
\mathbf{if}\;x\_m \leq 3.4 \cdot 10^{-184}:\\
\;\;\;\;\frac{\frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(x\_m \cdot 2\right) \cdot {\left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)}^{-2}\\
\end{array}
\end{array}
if x < 3.40000000000000004e-184Initial program 68.0%
associate-/l/68.0%
remove-double-neg68.0%
distribute-frac-neg68.0%
distribute-neg-frac68.0%
remove-double-neg68.0%
*-commutative68.0%
associate-*r*62.4%
unpow262.4%
associate-/r*62.0%
cos-neg62.0%
*-commutative62.0%
distribute-rgt-neg-in62.0%
metadata-eval62.0%
Simplified62.0%
associate-/l/62.4%
add-sqr-sqrt52.1%
sqrt-unprod53.8%
*-commutative53.8%
*-commutative53.8%
swap-sqr53.8%
metadata-eval53.8%
metadata-eval53.8%
swap-sqr53.8%
sqrt-unprod6.6%
add-sqr-sqrt62.4%
unpow262.4%
associate-*r*68.0%
*-commutative68.0%
associate-/r*68.0%
*-un-lft-identity68.0%
Applied egg-rr86.3%
associate-*l/86.4%
*-lft-identity86.4%
*-commutative86.4%
unpow286.4%
rem-sqrt-square86.4%
*-commutative86.4%
unpow286.4%
rem-sqrt-square96.6%
*-commutative96.6%
Simplified96.6%
Taylor expanded in x around 0 79.1%
associate-/r*79.1%
*-commutative79.1%
rem-square-sqrt50.3%
fabs-sqr50.3%
rem-square-sqrt56.7%
*-commutative56.7%
Simplified56.7%
add-sqr-sqrt43.8%
fabs-sqr43.8%
add-sqr-sqrt79.1%
Applied egg-rr79.1%
if 3.40000000000000004e-184 < x Initial program 69.3%
associate-/l/69.3%
remove-double-neg69.3%
distribute-frac-neg69.3%
distribute-neg-frac69.3%
remove-double-neg69.3%
*-commutative69.3%
associate-*r*62.4%
unpow262.4%
associate-/r*62.4%
cos-neg62.4%
*-commutative62.4%
distribute-rgt-neg-in62.4%
metadata-eval62.4%
Simplified62.4%
associate-/l/62.4%
add-sqr-sqrt0.0%
sqrt-unprod45.5%
*-commutative45.5%
*-commutative45.5%
swap-sqr45.5%
metadata-eval45.5%
metadata-eval45.5%
swap-sqr45.5%
sqrt-unprod59.4%
add-sqr-sqrt62.4%
unpow262.4%
associate-*r*69.3%
*-commutative69.3%
associate-/r*69.3%
*-un-lft-identity69.3%
Applied egg-rr88.6%
associate-*l/88.6%
*-lft-identity88.6%
*-commutative88.6%
unpow288.6%
rem-sqrt-square88.6%
*-commutative88.6%
unpow288.6%
rem-sqrt-square98.9%
*-commutative98.9%
Simplified98.9%
frac-2neg98.9%
distribute-frac-neg298.9%
*-commutative98.9%
distribute-neg-frac298.9%
*-commutative98.9%
*-commutative98.9%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt72.5%
distribute-rgt-neg-in72.5%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt98.9%
Applied egg-rr98.9%
Applied egg-rr97.9%
Final simplification86.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))) (t_1 (cos (* x_m 2.0))))
(if (<= c_m 1.5e-235)
(* t_1 (pow (* x_m (* c_m s_m)) -2.0))
(/ (/ 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.5e-235) {
tmp = t_1 * pow((x_m * (c_m * s_m)), -2.0);
} 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.5d-235) then
tmp = t_1 * ((x_m * (c_m * s_m)) ** (-2.0d0))
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.5e-235) {
tmp = t_1 * Math.pow((x_m * (c_m * s_m)), -2.0);
} 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.5e-235: tmp = t_1 * math.pow((x_m * (c_m * s_m)), -2.0) 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.5e-235) tmp = Float64(t_1 * (Float64(x_m * Float64(c_m * s_m)) ^ -2.0)); 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.5e-235)
tmp = t_1 * ((x_m * (c_m * s_m)) ^ -2.0);
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.5e-235], N[(t$95$1 * N[Power[N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $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.5 \cdot 10^{-235}:\\
\;\;\;\;t\_1 \cdot {\left(x\_m \cdot \left(c\_m \cdot s\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if c < 1.4999999999999999e-235Initial program 70.5%
associate-/l/70.5%
remove-double-neg70.5%
distribute-frac-neg70.5%
distribute-neg-frac70.5%
remove-double-neg70.5%
*-commutative70.5%
associate-*r*62.6%
unpow262.6%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
associate-/l/61.4%
div-inv61.4%
associate-/l*61.4%
add-sqr-sqrt29.5%
sqrt-unprod50.7%
*-commutative50.7%
*-commutative50.7%
swap-sqr50.7%
metadata-eval50.7%
metadata-eval50.7%
swap-sqr50.7%
sqrt-unprod28.6%
add-sqr-sqrt61.4%
pow-flip61.6%
metadata-eval61.6%
pow-prod-down76.3%
Applied egg-rr76.3%
associate-*r/76.3%
*-commutative76.3%
*-commutative76.3%
Simplified76.3%
unpow276.3%
*-commutative76.3%
associate-*r*73.2%
*-commutative73.2%
Applied egg-rr73.2%
Taylor expanded in x around inf 62.6%
associate-/r*61.6%
*-commutative61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr76.6%
unpow276.6%
associate-/r*77.6%
unpow277.6%
unpow277.6%
swap-sqr96.3%
associate-*l*93.9%
associate-*l*96.9%
associate-/l/97.4%
*-lft-identity97.4%
associate-*l/97.3%
*-commutative97.3%
Simplified97.1%
if 1.4999999999999999e-235 < c Initial program 65.6%
associate-/l/65.6%
remove-double-neg65.6%
distribute-frac-neg65.6%
distribute-neg-frac65.6%
remove-double-neg65.6%
*-commutative65.6%
associate-*r*62.2%
unpow262.2%
associate-/r*62.2%
cos-neg62.2%
*-commutative62.2%
distribute-rgt-neg-in62.2%
metadata-eval62.2%
Simplified62.2%
associate-/l/62.2%
add-sqr-sqrt33.0%
sqrt-unprod48.4%
*-commutative48.4%
*-commutative48.4%
swap-sqr48.4%
metadata-eval48.4%
metadata-eval48.4%
swap-sqr48.4%
sqrt-unprod25.6%
add-sqr-sqrt62.2%
unpow262.2%
associate-*r*65.6%
*-commutative65.6%
associate-/r*65.6%
*-un-lft-identity65.6%
Applied egg-rr89.3%
associate-*l/89.4%
*-lft-identity89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square98.6%
*-commutative98.6%
Simplified98.6%
frac-2neg98.6%
distribute-frac-neg298.6%
*-commutative98.6%
distribute-neg-frac298.6%
*-commutative98.6%
*-commutative98.6%
add-sqr-sqrt59.6%
fabs-sqr59.6%
add-sqr-sqrt73.7%
distribute-rgt-neg-in73.7%
add-sqr-sqrt58.6%
fabs-sqr58.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
Final simplification97.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))) (t_1 (cos (* x_m 2.0))))
(if (<= c_m 7e-236)
(* t_1 (/ (/ (/ 1.0 (* 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 <= 7e-236) {
tmp = t_1 * (((1.0 / (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 <= 7d-236) then
tmp = t_1 * (((1.0d0 / (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 <= 7e-236) {
tmp = t_1 * (((1.0 / (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 <= 7e-236: tmp = t_1 * (((1.0 / (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 <= 7e-236) tmp = Float64(t_1 * Float64(Float64(Float64(1.0 / 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 <= 7e-236)
tmp = t_1 * (((1.0 / (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, 7e-236], N[(t$95$1 * N[(N[(N[(1.0 / 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]), $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 7 \cdot 10^{-236}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{\frac{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 < 6.99999999999999988e-236Initial program 70.5%
associate-/l/70.5%
remove-double-neg70.5%
distribute-frac-neg70.5%
distribute-neg-frac70.5%
remove-double-neg70.5%
*-commutative70.5%
associate-*r*62.6%
unpow262.6%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
associate-/l/61.4%
div-inv61.4%
associate-/l*61.4%
add-sqr-sqrt29.5%
sqrt-unprod50.7%
*-commutative50.7%
*-commutative50.7%
swap-sqr50.7%
metadata-eval50.7%
metadata-eval50.7%
swap-sqr50.7%
sqrt-unprod28.6%
add-sqr-sqrt61.4%
pow-flip61.6%
metadata-eval61.6%
pow-prod-down76.3%
Applied egg-rr76.3%
associate-*r/76.3%
*-commutative76.3%
*-commutative76.3%
Simplified76.3%
unpow276.3%
*-commutative76.3%
associate-*r*73.2%
*-commutative73.2%
Applied egg-rr73.2%
Taylor expanded in x around inf 62.6%
associate-/r*61.6%
*-commutative61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr76.6%
unpow276.6%
associate-/r*77.6%
unpow277.6%
unpow277.6%
swap-sqr96.3%
associate-*l*93.9%
associate-*l*96.9%
associate-/l/97.4%
*-lft-identity97.4%
associate-*l/97.3%
*-commutative97.3%
Simplified97.1%
associate-*r*97.4%
*-commutative97.4%
metadata-eval97.4%
pow-sqr97.3%
inv-pow97.3%
inv-pow97.3%
associate-*r*94.3%
*-commutative94.3%
associate-/r*94.3%
div-inv94.4%
*-commutative94.4%
associate-*r*94.1%
*-commutative94.1%
associate-/r*93.2%
associate-/r*96.2%
associate-/l/96.1%
*-commutative96.1%
associate-/r*96.2%
*-commutative96.2%
Applied egg-rr96.2%
if 6.99999999999999988e-236 < c Initial program 65.6%
associate-/l/65.6%
remove-double-neg65.6%
distribute-frac-neg65.6%
distribute-neg-frac65.6%
remove-double-neg65.6%
*-commutative65.6%
associate-*r*62.2%
unpow262.2%
associate-/r*62.2%
cos-neg62.2%
*-commutative62.2%
distribute-rgt-neg-in62.2%
metadata-eval62.2%
Simplified62.2%
associate-/l/62.2%
add-sqr-sqrt33.0%
sqrt-unprod48.4%
*-commutative48.4%
*-commutative48.4%
swap-sqr48.4%
metadata-eval48.4%
metadata-eval48.4%
swap-sqr48.4%
sqrt-unprod25.6%
add-sqr-sqrt62.2%
unpow262.2%
associate-*r*65.6%
*-commutative65.6%
associate-/r*65.6%
*-un-lft-identity65.6%
Applied egg-rr89.3%
associate-*l/89.4%
*-lft-identity89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square98.6%
*-commutative98.6%
Simplified98.6%
frac-2neg98.6%
distribute-frac-neg298.6%
*-commutative98.6%
distribute-neg-frac298.6%
*-commutative98.6%
*-commutative98.6%
add-sqr-sqrt59.6%
fabs-sqr59.6%
add-sqr-sqrt73.7%
distribute-rgt-neg-in73.7%
add-sqr-sqrt58.6%
fabs-sqr58.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
Final simplification97.2%
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)))
(t_2 (* x_m (* c_m s_m))))
(if (<= c_m 6.2e-236) (* t_1 (/ (/ 1.0 t_2) t_2)) (/ (/ 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 t_2 = x_m * (c_m * s_m);
double tmp;
if (c_m <= 6.2e-236) {
tmp = t_1 * ((1.0 / t_2) / t_2);
} 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) :: t_2
real(8) :: tmp
t_0 = c_m * (x_m * s_m)
t_1 = cos((x_m * 2.0d0))
t_2 = x_m * (c_m * s_m)
if (c_m <= 6.2d-236) then
tmp = t_1 * ((1.0d0 / t_2) / t_2)
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 t_2 = x_m * (c_m * s_m);
double tmp;
if (c_m <= 6.2e-236) {
tmp = t_1 * ((1.0 / t_2) / t_2);
} 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)) t_2 = x_m * (c_m * s_m) tmp = 0 if c_m <= 6.2e-236: tmp = t_1 * ((1.0 / t_2) / t_2) 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)) t_2 = Float64(x_m * Float64(c_m * s_m)) tmp = 0.0 if (c_m <= 6.2e-236) tmp = Float64(t_1 * Float64(Float64(1.0 / t_2) / t_2)); 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));
t_2 = x_m * (c_m * s_m);
tmp = 0.0;
if (c_m <= 6.2e-236)
tmp = t_1 * ((1.0 / t_2) / t_2);
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]}, Block[{t$95$2 = N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c$95$m, 6.2e-236], N[(t$95$1 * N[(N[(1.0 / t$95$2), $MachinePrecision] / t$95$2), $MachinePrecision]), $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)\\
t_2 := x\_m \cdot \left(c\_m \cdot s\_m\right)\\
\mathbf{if}\;c\_m \leq 6.2 \cdot 10^{-236}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{1}{t\_2}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if c < 6.1999999999999997e-236Initial program 70.5%
associate-/l/70.5%
remove-double-neg70.5%
distribute-frac-neg70.5%
distribute-neg-frac70.5%
remove-double-neg70.5%
*-commutative70.5%
associate-*r*62.6%
unpow262.6%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
associate-/l/61.4%
div-inv61.4%
associate-/l*61.4%
add-sqr-sqrt29.5%
sqrt-unprod50.7%
*-commutative50.7%
*-commutative50.7%
swap-sqr50.7%
metadata-eval50.7%
metadata-eval50.7%
swap-sqr50.7%
sqrt-unprod28.6%
add-sqr-sqrt61.4%
pow-flip61.6%
metadata-eval61.6%
pow-prod-down76.3%
Applied egg-rr76.3%
associate-*r/76.3%
*-commutative76.3%
*-commutative76.3%
Simplified76.3%
unpow276.3%
*-commutative76.3%
associate-*r*73.2%
*-commutative73.2%
Applied egg-rr73.2%
Taylor expanded in x around inf 62.6%
associate-/r*61.6%
*-commutative61.6%
*-commutative61.6%
unpow261.6%
unpow261.6%
swap-sqr76.6%
unpow276.6%
associate-/r*77.6%
unpow277.6%
unpow277.6%
swap-sqr96.3%
associate-*l*93.9%
associate-*l*96.9%
associate-/l/97.4%
*-lft-identity97.4%
associate-*l/97.3%
*-commutative97.3%
Simplified97.1%
associate-*r*97.4%
*-commutative97.4%
metadata-eval97.4%
pow-sqr97.3%
inv-pow97.3%
inv-pow97.3%
frac-times96.9%
metadata-eval96.9%
associate-/r*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*r*94.8%
*-commutative94.8%
associate-*r*97.1%
Applied egg-rr97.1%
if 6.1999999999999997e-236 < c Initial program 65.6%
associate-/l/65.6%
remove-double-neg65.6%
distribute-frac-neg65.6%
distribute-neg-frac65.6%
remove-double-neg65.6%
*-commutative65.6%
associate-*r*62.2%
unpow262.2%
associate-/r*62.2%
cos-neg62.2%
*-commutative62.2%
distribute-rgt-neg-in62.2%
metadata-eval62.2%
Simplified62.2%
associate-/l/62.2%
add-sqr-sqrt33.0%
sqrt-unprod48.4%
*-commutative48.4%
*-commutative48.4%
swap-sqr48.4%
metadata-eval48.4%
metadata-eval48.4%
swap-sqr48.4%
sqrt-unprod25.6%
add-sqr-sqrt62.2%
unpow262.2%
associate-*r*65.6%
*-commutative65.6%
associate-/r*65.6%
*-un-lft-identity65.6%
Applied egg-rr89.3%
associate-*l/89.4%
*-lft-identity89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square89.4%
*-commutative89.4%
unpow289.4%
rem-sqrt-square98.6%
*-commutative98.6%
Simplified98.6%
frac-2neg98.6%
distribute-frac-neg298.6%
*-commutative98.6%
distribute-neg-frac298.6%
*-commutative98.6%
*-commutative98.6%
add-sqr-sqrt59.6%
fabs-sqr59.6%
add-sqr-sqrt73.7%
distribute-rgt-neg-in73.7%
add-sqr-sqrt58.6%
fabs-sqr58.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
Final simplification97.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)))) (/ (/ (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 68.5%
associate-/l/68.5%
remove-double-neg68.5%
distribute-frac-neg68.5%
distribute-neg-frac68.5%
remove-double-neg68.5%
*-commutative68.5%
associate-*r*62.4%
unpow262.4%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
associate-/l/62.4%
add-sqr-sqrt31.5%
sqrt-unprod50.5%
*-commutative50.5%
*-commutative50.5%
swap-sqr50.5%
metadata-eval50.5%
metadata-eval50.5%
swap-sqr50.5%
sqrt-unprod27.4%
add-sqr-sqrt62.4%
unpow262.4%
associate-*r*68.5%
*-commutative68.5%
associate-/r*68.5%
*-un-lft-identity68.5%
Applied egg-rr87.2%
associate-*l/87.3%
*-lft-identity87.3%
*-commutative87.3%
unpow287.3%
rem-sqrt-square87.3%
*-commutative87.3%
unpow287.3%
rem-sqrt-square97.5%
*-commutative97.5%
Simplified97.5%
frac-2neg97.5%
distribute-frac-neg297.5%
*-commutative97.5%
distribute-neg-frac297.5%
*-commutative97.5%
*-commutative97.5%
add-sqr-sqrt56.2%
fabs-sqr56.2%
add-sqr-sqrt67.8%
distribute-rgt-neg-in67.8%
add-sqr-sqrt52.2%
fabs-sqr52.2%
add-sqr-sqrt97.5%
Applied egg-rr97.5%
Final simplification97.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 (if (<= x_m 3.6e+77) (/ (/ (/ 1.0 c_m) (* x_m s_m)) (* c_m (* x_m s_m))) (- (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 <= 3.6e+77) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = -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 <= 3.6d+77) then
tmp = ((1.0d0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m))
else
tmp = -((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 <= 3.6e+77) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = -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 <= 3.6e+77: tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m)) else: tmp = -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 <= 3.6e+77) tmp = Float64(Float64(Float64(1.0 / c_m) / Float64(x_m * s_m)) / Float64(c_m * Float64(x_m * s_m))); else tmp = Float64(-(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 <= 3.6e+77)
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
else
tmp = -((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, 3.6e+77], N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Power[N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision], -2.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}
\mathbf{if}\;x\_m \leq 3.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{\frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;-{\left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)}^{-2}\\
\end{array}
\end{array}
if x < 3.5999999999999998e77Initial program 68.6%
associate-/l/68.6%
remove-double-neg68.6%
distribute-frac-neg68.6%
distribute-neg-frac68.6%
remove-double-neg68.6%
*-commutative68.6%
associate-*r*63.9%
unpow263.9%
associate-/r*63.6%
cos-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
metadata-eval63.6%
Simplified63.6%
associate-/l/63.9%
add-sqr-sqrt39.2%
sqrt-unprod57.4%
*-commutative57.4%
*-commutative57.4%
swap-sqr57.4%
metadata-eval57.4%
metadata-eval57.4%
swap-sqr57.4%
sqrt-unprod21.4%
add-sqr-sqrt63.9%
unpow263.9%
associate-*r*68.6%
*-commutative68.6%
associate-/r*68.6%
*-un-lft-identity68.6%
Applied egg-rr86.0%
associate-*l/86.1%
*-lft-identity86.1%
*-commutative86.1%
unpow286.1%
rem-sqrt-square86.1%
*-commutative86.1%
unpow286.1%
rem-sqrt-square97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around 0 81.2%
associate-/r*81.3%
*-commutative81.3%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt56.7%
*-commutative56.7%
Simplified56.7%
add-sqr-sqrt43.3%
fabs-sqr43.3%
add-sqr-sqrt81.3%
Applied egg-rr81.3%
if 3.5999999999999998e77 < x Initial program 68.3%
associate-/l/68.3%
remove-double-neg68.3%
distribute-frac-neg68.3%
distribute-neg-frac68.3%
remove-double-neg68.3%
*-commutative68.3%
associate-*r*56.3%
unpow256.3%
associate-/r*56.3%
cos-neg56.3%
*-commutative56.3%
distribute-rgt-neg-in56.3%
metadata-eval56.3%
Simplified56.3%
Taylor expanded in x around 0 46.9%
associate-/r*42.9%
*-commutative42.9%
*-commutative42.9%
unpow242.9%
unpow242.9%
swap-sqr51.8%
unpow251.8%
associate-/r*55.8%
unpow255.8%
rem-square-sqrt55.8%
swap-sqr66.1%
unpow266.1%
unpow266.1%
rem-sqrt-square66.7%
*-commutative66.7%
Simplified66.7%
unpow-prod-down55.8%
pow255.8%
pow255.8%
sqr-abs55.8%
swap-sqr66.7%
Applied egg-rr66.7%
Applied egg-rr72.4%
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 (if (<= x_m 3.6e+77) (/ (/ (/ 1.0 c_m) (* x_m s_m)) (* c_m (* x_m s_m))) (- (pow (* x_m (* c_m s_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 <= 3.6e+77) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = -pow((x_m * (c_m * s_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 <= 3.6d+77) then
tmp = ((1.0d0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m))
else
tmp = -((x_m * (c_m * s_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 <= 3.6e+77) {
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
} else {
tmp = -Math.pow((x_m * (c_m * s_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 <= 3.6e+77: tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m)) else: tmp = -math.pow((x_m * (c_m * s_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 <= 3.6e+77) tmp = Float64(Float64(Float64(1.0 / c_m) / Float64(x_m * s_m)) / Float64(c_m * Float64(x_m * s_m))); else tmp = Float64(-(Float64(x_m * Float64(c_m * s_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 <= 3.6e+77)
tmp = ((1.0 / c_m) / (x_m * s_m)) / (c_m * (x_m * s_m));
else
tmp = -((x_m * (c_m * s_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, 3.6e+77], N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Power[N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.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}
\mathbf{if}\;x\_m \leq 3.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{\frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;-{\left(x\_m \cdot \left(c\_m \cdot s\_m\right)\right)}^{-2}\\
\end{array}
\end{array}
if x < 3.5999999999999998e77Initial program 68.6%
associate-/l/68.6%
remove-double-neg68.6%
distribute-frac-neg68.6%
distribute-neg-frac68.6%
remove-double-neg68.6%
*-commutative68.6%
associate-*r*63.9%
unpow263.9%
associate-/r*63.6%
cos-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
metadata-eval63.6%
Simplified63.6%
associate-/l/63.9%
add-sqr-sqrt39.2%
sqrt-unprod57.4%
*-commutative57.4%
*-commutative57.4%
swap-sqr57.4%
metadata-eval57.4%
metadata-eval57.4%
swap-sqr57.4%
sqrt-unprod21.4%
add-sqr-sqrt63.9%
unpow263.9%
associate-*r*68.6%
*-commutative68.6%
associate-/r*68.6%
*-un-lft-identity68.6%
Applied egg-rr86.0%
associate-*l/86.1%
*-lft-identity86.1%
*-commutative86.1%
unpow286.1%
rem-sqrt-square86.1%
*-commutative86.1%
unpow286.1%
rem-sqrt-square97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around 0 81.2%
associate-/r*81.3%
*-commutative81.3%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt56.7%
*-commutative56.7%
Simplified56.7%
add-sqr-sqrt43.3%
fabs-sqr43.3%
add-sqr-sqrt81.3%
Applied egg-rr81.3%
if 3.5999999999999998e77 < x Initial program 68.3%
associate-/l/68.3%
remove-double-neg68.3%
distribute-frac-neg68.3%
distribute-neg-frac68.3%
remove-double-neg68.3%
*-commutative68.3%
associate-*r*56.3%
unpow256.3%
associate-/r*56.3%
cos-neg56.3%
*-commutative56.3%
distribute-rgt-neg-in56.3%
metadata-eval56.3%
Simplified56.3%
Taylor expanded in x around 0 46.9%
associate-/r*42.9%
*-commutative42.9%
*-commutative42.9%
unpow242.9%
unpow242.9%
swap-sqr51.8%
unpow251.8%
associate-/r*55.8%
unpow255.8%
rem-square-sqrt55.8%
swap-sqr66.1%
unpow266.1%
unpow266.1%
rem-sqrt-square66.7%
*-commutative66.7%
Simplified66.7%
unpow-prod-down55.8%
pow255.8%
pow255.8%
sqr-abs55.8%
swap-sqr66.7%
Applied egg-rr66.7%
inv-pow66.7%
swap-sqr55.8%
unpow-prod-down51.8%
*-commutative51.8%
associate-*r*51.4%
associate-*r*46.9%
unpow246.9%
unpow-prod-down50.9%
inv-pow50.9%
frac-2neg50.9%
metadata-eval50.9%
div-inv50.9%
associate-*l*61.2%
distribute-lft-neg-in61.2%
Applied egg-rr72.4%
neg-mul-172.4%
*-commutative72.4%
associate-*l*72.2%
Simplified72.2%
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) (* 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 ((1.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 = ((1.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 ((1.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 ((1.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(Float64(1.0 / c_m) / 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 = ((1.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[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x$95$m * s$95$m), $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{\frac{1}{c\_m}}{x\_m \cdot s\_m}}{c\_m \cdot \left(x\_m \cdot s\_m\right)}
\end{array}
Initial program 68.5%
associate-/l/68.5%
remove-double-neg68.5%
distribute-frac-neg68.5%
distribute-neg-frac68.5%
remove-double-neg68.5%
*-commutative68.5%
associate-*r*62.4%
unpow262.4%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
associate-/l/62.4%
add-sqr-sqrt31.5%
sqrt-unprod50.5%
*-commutative50.5%
*-commutative50.5%
swap-sqr50.5%
metadata-eval50.5%
metadata-eval50.5%
swap-sqr50.5%
sqrt-unprod27.4%
add-sqr-sqrt62.4%
unpow262.4%
associate-*r*68.5%
*-commutative68.5%
associate-/r*68.5%
*-un-lft-identity68.5%
Applied egg-rr87.2%
associate-*l/87.3%
*-lft-identity87.3%
*-commutative87.3%
unpow287.3%
rem-sqrt-square87.3%
*-commutative87.3%
unpow287.3%
rem-sqrt-square97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 78.4%
associate-/r*78.4%
*-commutative78.4%
rem-square-sqrt44.6%
fabs-sqr44.6%
rem-square-sqrt58.3%
*-commutative58.3%
Simplified58.3%
add-sqr-sqrt40.7%
fabs-sqr40.7%
add-sqr-sqrt78.4%
Applied egg-rr78.4%
Final simplification78.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 68.5%
associate-/l/68.5%
remove-double-neg68.5%
distribute-frac-neg68.5%
distribute-neg-frac68.5%
remove-double-neg68.5%
*-commutative68.5%
associate-*r*62.4%
unpow262.4%
associate-/r*62.1%
cos-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
Taylor expanded in x around 0 54.7%
associate-/r*53.7%
*-commutative53.7%
*-commutative53.7%
unpow253.7%
unpow253.7%
swap-sqr64.7%
unpow264.7%
associate-/r*65.6%
unpow265.6%
rem-square-sqrt65.6%
swap-sqr72.1%
unpow272.1%
unpow272.1%
rem-sqrt-square78.4%
*-commutative78.4%
Simplified78.4%
unpow-prod-down65.6%
pow265.6%
pow265.6%
sqr-abs65.6%
swap-sqr78.4%
Applied egg-rr78.4%
herbie shell --seed 2024147
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))