
(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 6 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 2e-46) (/ (/ (/ 1.0 (* x_m s_m)) c_m) (* (* x_m s_m) c_m)) (* (/ 1.0 (* s_m (* x_m c_m))) (/ (/ (/ (cos (* x_m 2.0)) c_m) x_m) s_m))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double tmp;
if (x_m <= 2e-46) {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (1.0 / (s_m * (x_m * c_m))) * (((cos((x_m * 2.0)) / c_m) / x_m) / s_m);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 2d-46) then
tmp = ((1.0d0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
else
tmp = (1.0d0 / (s_m * (x_m * c_m))) * (((cos((x_m * 2.0d0)) / c_m) / x_m) / s_m)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double tmp;
if (x_m <= 2e-46) {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (1.0 / (s_m * (x_m * c_m))) * (((Math.cos((x_m * 2.0)) / c_m) / x_m) / s_m);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): tmp = 0 if x_m <= 2e-46: tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m) else: tmp = (1.0 / (s_m * (x_m * c_m))) * (((math.cos((x_m * 2.0)) / c_m) / x_m) / s_m) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) tmp = 0.0 if (x_m <= 2e-46) tmp = Float64(Float64(Float64(1.0 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)); else tmp = Float64(Float64(1.0 / Float64(s_m * Float64(x_m * c_m))) * Float64(Float64(Float64(cos(Float64(x_m * 2.0)) / c_m) / x_m) / s_m)); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
tmp = 0.0;
if (x_m <= 2e-46)
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
else
tmp = (1.0 / (s_m * (x_m * c_m))) * (((cos((x_m * 2.0)) / c_m) / x_m) / s_m);
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := If[LessEqual[x$95$m, 2e-46], N[(N[(N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] / s$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2 \cdot 10^{-46}:\\
\;\;\;\;\frac{\frac{\frac{1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s\_m \cdot \left(x\_m \cdot c\_m\right)} \cdot \frac{\frac{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{x\_m}}{s\_m}\\
\end{array}
\end{array}
if x < 2.00000000000000005e-46Initial program 71.9%
associate-/r*71.9%
*-commutative71.9%
unpow271.9%
sqr-neg71.9%
unpow271.9%
cos-neg71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
metadata-eval71.9%
unpow271.9%
sqr-neg71.9%
unpow271.9%
associate-*r*66.8%
unpow266.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around 0 64.0%
associate-/r*64.0%
*-commutative64.0%
unpow264.0%
unpow264.0%
swap-sqr77.6%
unpow277.6%
associate-/r*77.6%
unpow277.6%
unpow277.6%
swap-sqr86.4%
unpow286.4%
Simplified86.4%
unpow286.4%
associate-*l*85.0%
associate-*r*82.8%
*-commutative82.8%
Applied egg-rr82.8%
associate-*r*84.2%
associate-*r*86.0%
*-commutative86.0%
pow286.0%
*-commutative86.0%
*-commutative86.0%
associate-*r*87.7%
*-un-lft-identity87.7%
pow-flip87.7%
metadata-eval87.7%
Applied egg-rr87.7%
*-lft-identity87.7%
*-commutative87.7%
associate-*r*86.4%
Simplified86.4%
associate-*r*87.7%
*-commutative87.7%
metadata-eval87.7%
pow-prod-up87.7%
unpow-prod-down87.7%
*-commutative87.7%
associate-*r*85.9%
*-commutative85.9%
associate-*l*85.1%
inv-pow85.1%
associate-*l*85.9%
*-commutative85.9%
associate-*r*87.7%
*-commutative87.7%
associate-/r*87.7%
*-commutative87.7%
associate-*r*85.9%
associate-/r*85.8%
*-commutative85.8%
associate-*r*86.4%
*-commutative86.4%
Applied egg-rr86.4%
if 2.00000000000000005e-46 < x Initial program 75.6%
unpow275.6%
Applied egg-rr75.6%
*-un-lft-identity75.6%
pow275.6%
times-frac75.4%
*-commutative75.4%
associate-*r*65.6%
pow265.6%
unpow-prod-down80.8%
times-frac80.9%
unpow-prod-down97.1%
associate-*l/97.0%
add-sqr-sqrt96.9%
associate-*l*96.9%
Applied egg-rr98.3%
*-commutative98.3%
div-inv98.3%
*-commutative98.3%
associate-*r*95.8%
associate-/r*95.8%
associate-/r*98.5%
Applied egg-rr98.5%
Final simplification89.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 (if (<= (pow s_m 2.0) 5e+222) (/ (/ (cos (* x_m 2.0)) c_m) (* c_m (* s_m (* x_m (* x_m s_m))))) (/ (/ (/ 1.0 (* x_m s_m)) c_m) (* (* x_m s_m) c_m))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double tmp;
if (pow(s_m, 2.0) <= 5e+222) {
tmp = (cos((x_m * 2.0)) / c_m) / (c_m * (s_m * (x_m * (x_m * s_m))));
} else {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_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 ** 2.0d0) <= 5d+222) then
tmp = (cos((x_m * 2.0d0)) / c_m) / (c_m * (s_m * (x_m * (x_m * s_m))))
else
tmp = ((1.0d0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_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 (Math.pow(s_m, 2.0) <= 5e+222) {
tmp = (Math.cos((x_m * 2.0)) / c_m) / (c_m * (s_m * (x_m * (x_m * s_m))));
} else {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_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 math.pow(s_m, 2.0) <= 5e+222: tmp = (math.cos((x_m * 2.0)) / c_m) / (c_m * (s_m * (x_m * (x_m * s_m)))) else: tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_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 ^ 2.0) <= 5e+222) tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / c_m) / Float64(c_m * Float64(s_m * Float64(x_m * Float64(x_m * s_m))))); else tmp = Float64(Float64(Float64(1.0 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_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 ^ 2.0) <= 5e+222)
tmp = (cos((x_m * 2.0)) / c_m) / (c_m * (s_m * (x_m * (x_m * s_m))));
else
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_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[N[Power[s$95$m, 2.0], $MachinePrecision], 5e+222], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(c$95$m * N[(s$95$m * N[(x$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;{s\_m}^{2} \leq 5 \cdot 10^{+222}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{c\_m \cdot \left(s\_m \cdot \left(x\_m \cdot \left(x\_m \cdot s\_m\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\end{array}
\end{array}
if (pow.f64 s #s(literal 2 binary64)) < 5.00000000000000023e222Initial program 74.8%
associate-/r*74.7%
*-commutative74.7%
unpow274.7%
sqr-neg74.7%
unpow274.7%
cos-neg74.7%
*-commutative74.7%
distribute-rgt-neg-in74.7%
metadata-eval74.7%
unpow274.7%
sqr-neg74.7%
unpow274.7%
associate-*r*67.1%
unpow267.1%
*-commutative67.1%
Simplified67.1%
Applied egg-rr97.0%
associate-*l/97.0%
unpow297.0%
swap-sqr79.9%
swap-sqr67.1%
unpow267.1%
associate-*r*74.8%
*-commutative74.8%
associate-*l*78.8%
*-un-lft-identity78.8%
associate-/r*78.8%
*-commutative78.8%
*-commutative78.8%
associate-*r*70.3%
pow270.3%
unpow-prod-down85.3%
Applied egg-rr85.3%
unpow285.3%
associate-*r*81.4%
Applied egg-rr81.4%
if 5.00000000000000023e222 < (pow.f64 s #s(literal 2 binary64)) Initial program 69.2%
associate-/r*69.2%
*-commutative69.2%
unpow269.2%
sqr-neg69.2%
unpow269.2%
cos-neg69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
unpow269.2%
sqr-neg69.2%
unpow269.2%
associate-*r*65.4%
unpow265.4%
*-commutative65.4%
Simplified65.4%
Taylor expanded in x around 0 65.4%
associate-/r*65.4%
*-commutative65.4%
unpow265.4%
unpow265.4%
swap-sqr88.4%
unpow288.4%
associate-/r*88.4%
unpow288.4%
unpow288.4%
swap-sqr97.5%
unpow297.5%
Simplified97.5%
unpow297.5%
associate-*l*97.6%
associate-*r*93.0%
*-commutative93.0%
Applied egg-rr93.0%
associate-*r*93.0%
associate-*r*93.1%
*-commutative93.1%
pow293.1%
*-commutative93.1%
*-commutative93.1%
associate-*r*96.7%
*-un-lft-identity96.7%
pow-flip96.7%
metadata-eval96.7%
Applied egg-rr96.7%
*-lft-identity96.7%
*-commutative96.7%
associate-*r*97.5%
Simplified97.5%
associate-*r*96.7%
*-commutative96.7%
metadata-eval96.7%
pow-prod-up96.7%
unpow-prod-down96.7%
*-commutative96.7%
associate-*r*96.6%
*-commutative96.6%
associate-*l*96.5%
inv-pow96.5%
associate-*l*96.6%
*-commutative96.6%
associate-*r*96.7%
*-commutative96.7%
associate-/r*96.7%
*-commutative96.7%
associate-*r*96.5%
associate-/r*96.5%
*-commutative96.5%
associate-*r*97.6%
*-commutative97.6%
Applied egg-rr97.6%
Final simplification86.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 (* s_m (* x_m c_m))))
(if (<= x_m 2.2e-46)
(/ (/ (/ 1.0 (* x_m s_m)) c_m) (* (* x_m s_m) c_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 = s_m * (x_m * c_m);
double tmp;
if (x_m <= 2.2e-46) {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (cos((x_m * 2.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 = s_m * (x_m * c_m)
if (x_m <= 2.2d-46) then
tmp = ((1.0d0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
else
tmp = (cos((x_m * 2.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 = s_m * (x_m * c_m);
double tmp;
if (x_m <= 2.2e-46) {
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (Math.cos((x_m * 2.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 = s_m * (x_m * c_m) tmp = 0 if x_m <= 2.2e-46: tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m) else: tmp = (math.cos((x_m * 2.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(s_m * Float64(x_m * c_m)) tmp = 0.0 if (x_m <= 2.2e-46) tmp = Float64(Float64(Float64(1.0 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)); else tmp = Float64(Float64(cos(Float64(x_m * 2.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 = s_m * (x_m * c_m);
tmp = 0.0;
if (x_m <= 2.2e-46)
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
else
tmp = (cos((x_m * 2.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[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 2.2e-46], N[(N[(N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$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 := s\_m \cdot \left(x\_m \cdot c\_m\right)\\
\mathbf{if}\;x\_m \leq 2.2 \cdot 10^{-46}:\\
\;\;\;\;\frac{\frac{\frac{1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 2.2000000000000001e-46Initial program 71.9%
associate-/r*71.9%
*-commutative71.9%
unpow271.9%
sqr-neg71.9%
unpow271.9%
cos-neg71.9%
*-commutative71.9%
distribute-rgt-neg-in71.9%
metadata-eval71.9%
unpow271.9%
sqr-neg71.9%
unpow271.9%
associate-*r*66.8%
unpow266.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around 0 64.0%
associate-/r*64.0%
*-commutative64.0%
unpow264.0%
unpow264.0%
swap-sqr77.6%
unpow277.6%
associate-/r*77.6%
unpow277.6%
unpow277.6%
swap-sqr86.4%
unpow286.4%
Simplified86.4%
unpow286.4%
associate-*l*85.0%
associate-*r*82.8%
*-commutative82.8%
Applied egg-rr82.8%
associate-*r*84.2%
associate-*r*86.0%
*-commutative86.0%
pow286.0%
*-commutative86.0%
*-commutative86.0%
associate-*r*87.7%
*-un-lft-identity87.7%
pow-flip87.7%
metadata-eval87.7%
Applied egg-rr87.7%
*-lft-identity87.7%
*-commutative87.7%
associate-*r*86.4%
Simplified86.4%
associate-*r*87.7%
*-commutative87.7%
metadata-eval87.7%
pow-prod-up87.7%
unpow-prod-down87.7%
*-commutative87.7%
associate-*r*85.9%
*-commutative85.9%
associate-*l*85.1%
inv-pow85.1%
associate-*l*85.9%
*-commutative85.9%
associate-*r*87.7%
*-commutative87.7%
associate-/r*87.7%
*-commutative87.7%
associate-*r*85.9%
associate-/r*85.8%
*-commutative85.8%
associate-*r*86.4%
*-commutative86.4%
Applied egg-rr86.4%
if 2.2000000000000001e-46 < x Initial program 75.6%
associate-/r*75.5%
*-commutative75.5%
unpow275.5%
sqr-neg75.5%
unpow275.5%
cos-neg75.5%
*-commutative75.5%
distribute-rgt-neg-in75.5%
metadata-eval75.5%
unpow275.5%
sqr-neg75.5%
unpow275.5%
associate-*r*65.7%
unpow265.7%
*-commutative65.7%
Simplified65.7%
Applied egg-rr97.0%
associate-*l/97.1%
*-un-lft-identity97.1%
unpow297.1%
associate-/r*97.0%
*-commutative97.0%
associate-*r*95.8%
*-commutative95.8%
associate-*r*98.4%
*-commutative98.4%
Applied egg-rr98.4%
Final simplification89.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 (/ (/ (/ 1.0 (* x_m s_m)) c_m) (* (* x_m s_m) c_m)))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((1.0d0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(Float64(Float64(1.0 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = ((1.0 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(N[(N[(1.0 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{\frac{\frac{1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}
\end{array}
Initial program 72.9%
associate-/r*72.9%
*-commutative72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
cos-neg72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
associate-*r*66.5%
unpow266.5%
*-commutative66.5%
Simplified66.5%
Taylor expanded in x around 0 62.9%
associate-/r*62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr73.7%
unpow273.7%
associate-/r*73.7%
unpow273.7%
unpow273.7%
swap-sqr82.9%
unpow282.9%
Simplified82.9%
unpow282.9%
associate-*l*81.6%
associate-*r*79.9%
*-commutative79.9%
Applied egg-rr79.9%
associate-*r*81.3%
associate-*r*82.6%
*-commutative82.6%
pow282.6%
*-commutative82.6%
*-commutative82.6%
associate-*r*83.9%
*-un-lft-identity83.9%
pow-flip83.9%
metadata-eval83.9%
Applied egg-rr83.9%
*-lft-identity83.9%
*-commutative83.9%
associate-*r*83.0%
Simplified83.0%
associate-*r*83.9%
*-commutative83.9%
metadata-eval83.9%
pow-prod-up83.9%
unpow-prod-down83.9%
*-commutative83.9%
associate-*r*82.5%
*-commutative82.5%
associate-*l*81.4%
inv-pow81.4%
associate-*l*82.5%
*-commutative82.5%
associate-*r*83.9%
*-commutative83.9%
associate-/r*83.9%
*-commutative83.9%
associate-*r*82.5%
associate-/r*82.5%
*-commutative82.5%
associate-*r*82.9%
*-commutative82.9%
Applied egg-rr82.9%
Final simplification82.9%
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 (* x_m (* s_m c_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 = x_m * (s_m * c_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 = x_m * (s_m * c_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 = x_m * (s_m * c_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 = x_m * (s_m * c_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(x_m * Float64(s_m * c_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 = x_m * (s_m * c_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[(x$95$m * N[(s$95$m * c$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 := x\_m \cdot \left(s\_m \cdot c\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 72.9%
associate-/r*72.9%
*-commutative72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
cos-neg72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
associate-*r*66.5%
unpow266.5%
*-commutative66.5%
Simplified66.5%
Taylor expanded in x around 0 62.9%
associate-/r*62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr73.7%
unpow273.7%
associate-/r*73.7%
unpow273.7%
unpow273.7%
swap-sqr82.9%
unpow282.9%
Simplified82.9%
Taylor expanded in c around 0 62.9%
associate-*r*62.6%
*-commutative62.6%
associate-*r*62.8%
unpow262.8%
unpow262.8%
unpow262.8%
swap-sqr71.9%
swap-sqr82.6%
unpow282.6%
*-commutative82.6%
*-commutative82.6%
associate-*l*83.9%
Simplified83.9%
unpow283.9%
Applied egg-rr83.9%
Final simplification83.9%
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) (* (* x_m s_m) c_m)))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return 1.0 / (c_m * ((x_m * s_m) * ((x_m * s_m) * c_m)));
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / (c_m * ((x_m * s_m) * ((x_m * s_m) * c_m)))
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return 1.0 / (c_m * ((x_m * s_m) * ((x_m * s_m) * c_m)));
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return 1.0 / (c_m * ((x_m * s_m) * ((x_m * s_m) * c_m)))
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(1.0 / Float64(c_m * Float64(Float64(x_m * s_m) * Float64(Float64(x_m * s_m) * c_m)))) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = 1.0 / (c_m * ((x_m * s_m) * ((x_m * s_m) * c_m)));
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(1.0 / N[(c$95$m * N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{1}{c\_m \cdot \left(\left(x\_m \cdot s\_m\right) \cdot \left(\left(x\_m \cdot s\_m\right) \cdot c\_m\right)\right)}
\end{array}
Initial program 72.9%
associate-/r*72.9%
*-commutative72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
cos-neg72.9%
*-commutative72.9%
distribute-rgt-neg-in72.9%
metadata-eval72.9%
unpow272.9%
sqr-neg72.9%
unpow272.9%
associate-*r*66.5%
unpow266.5%
*-commutative66.5%
Simplified66.5%
Taylor expanded in x around 0 62.9%
associate-/r*62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr73.7%
unpow273.7%
associate-/r*73.7%
unpow273.7%
unpow273.7%
swap-sqr82.9%
unpow282.9%
Simplified82.9%
unpow282.9%
associate-*l*81.6%
associate-*r*79.9%
*-commutative79.9%
Applied egg-rr79.9%
Taylor expanded in s around 0 81.6%
Final simplification81.6%
herbie shell --seed 2024169
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))