
(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 7 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
(let* ((t_0 (* s_m (* x_m c_m))) (t_1 (cos (* x_m 2.0))))
(if (<= x_m 1.2e-27)
(/ (/ (* (/ 1.0 s_m) (/ t_1 x_m)) c_m) (* c_m (fabs (* x_m s_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 = s_m * (x_m * c_m);
double t_1 = cos((x_m * 2.0));
double tmp;
if (x_m <= 1.2e-27) {
tmp = (((1.0 / s_m) * (t_1 / x_m)) / c_m) / (c_m * fabs((x_m * s_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 = s_m * (x_m * c_m)
t_1 = cos((x_m * 2.0d0))
if (x_m <= 1.2d-27) then
tmp = (((1.0d0 / s_m) * (t_1 / x_m)) / c_m) / (c_m * abs((x_m * s_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 = s_m * (x_m * c_m);
double t_1 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 1.2e-27) {
tmp = (((1.0 / s_m) * (t_1 / x_m)) / c_m) / (c_m * Math.abs((x_m * s_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 = s_m * (x_m * c_m) t_1 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 1.2e-27: tmp = (((1.0 / s_m) * (t_1 / x_m)) / c_m) / (c_m * math.fabs((x_m * s_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(s_m * Float64(x_m * c_m)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 1.2e-27) tmp = Float64(Float64(Float64(Float64(1.0 / s_m) * Float64(t_1 / x_m)) / c_m) / Float64(c_m * abs(Float64(x_m * s_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 = s_m * (x_m * c_m);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 1.2e-27)
tmp = (((1.0 / s_m) * (t_1 / x_m)) / c_m) / (c_m * abs((x_m * s_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[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 1.2e-27], N[(N[(N[(N[(1.0 / s$95$m), $MachinePrecision] * N[(t$95$1 / x$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(c$95$m * N[Abs[N[(x$95$m * s$95$m), $MachinePrecision]], $MachinePrecision]), $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 := s\_m \cdot \left(x\_m \cdot c\_m\right)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;x\_m \leq 1.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{\frac{1}{s\_m} \cdot \frac{t\_1}{x\_m}}{c\_m}}{c\_m \cdot \left|x\_m \cdot s\_m\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 1.20000000000000001e-27Initial program 67.1%
*-un-lft-identity67.1%
add-sqr-sqrt67.1%
times-frac67.1%
sqrt-prod67.1%
sqrt-pow145.6%
metadata-eval45.6%
pow145.6%
*-commutative45.6%
associate-*r*42.8%
unpow242.8%
pow-prod-down45.6%
sqrt-prod45.6%
Applied egg-rr86.2%
associate-*l/86.2%
*-lft-identity86.2%
*-commutative86.2%
associate-/r*86.2%
unpow286.2%
rem-sqrt-square86.2%
unpow286.2%
rem-sqrt-square97.9%
Simplified97.9%
*-un-lft-identity97.9%
add-sqr-sqrt60.3%
fabs-sqr60.3%
add-sqr-sqrt66.9%
times-frac67.0%
*-commutative67.0%
Applied egg-rr67.0%
if 1.20000000000000001e-27 < x Initial program 54.8%
*-un-lft-identity54.8%
add-sqr-sqrt54.8%
times-frac54.8%
sqrt-prod54.8%
sqrt-pow144.2%
metadata-eval44.2%
pow144.2%
*-commutative44.2%
associate-*r*42.6%
unpow242.6%
pow-prod-down44.2%
sqrt-prod44.2%
Applied egg-rr80.9%
associate-*l/81.0%
*-lft-identity81.0%
*-commutative81.0%
associate-/r*81.1%
unpow281.1%
rem-sqrt-square81.1%
unpow281.1%
rem-sqrt-square96.7%
Simplified96.7%
div-inv96.7%
times-frac96.7%
associate-/l/96.6%
*-commutative96.6%
add-sqr-sqrt51.9%
fabs-sqr51.9%
add-sqr-sqrt74.7%
add-sqr-sqrt52.0%
fabs-sqr52.0%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
*-commutative96.6%
*-un-lft-identity96.6%
frac-times96.6%
*-commutative96.6%
un-div-inv96.7%
times-frac96.7%
*-commutative96.7%
frac-times96.6%
*-rgt-identity96.6%
associate-*l*93.1%
associate-*l*95.9%
Applied egg-rr95.9%
Final simplification74.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 (* s_m (* x_m c_m))) (t_1 (cos (* x_m 2.0))))
(if (<= x_m 1.8e-27)
(/ (* (* (/ t_1 s_m) (/ 1.0 x_m)) (/ 1.0 c_m)) (* c_m (* x_m s_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 = s_m * (x_m * c_m);
double t_1 = cos((x_m * 2.0));
double tmp;
if (x_m <= 1.8e-27) {
tmp = (((t_1 / s_m) * (1.0 / x_m)) * (1.0 / c_m)) / (c_m * (x_m * s_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 = s_m * (x_m * c_m)
t_1 = cos((x_m * 2.0d0))
if (x_m <= 1.8d-27) then
tmp = (((t_1 / s_m) * (1.0d0 / x_m)) * (1.0d0 / c_m)) / (c_m * (x_m * s_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 = s_m * (x_m * c_m);
double t_1 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 1.8e-27) {
tmp = (((t_1 / s_m) * (1.0 / x_m)) * (1.0 / c_m)) / (c_m * (x_m * s_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 = s_m * (x_m * c_m) t_1 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 1.8e-27: tmp = (((t_1 / s_m) * (1.0 / x_m)) * (1.0 / c_m)) / (c_m * (x_m * s_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(s_m * Float64(x_m * c_m)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 1.8e-27) tmp = Float64(Float64(Float64(Float64(t_1 / s_m) * Float64(1.0 / x_m)) * Float64(1.0 / c_m)) / Float64(c_m * Float64(x_m * s_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 = s_m * (x_m * c_m);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 1.8e-27)
tmp = (((t_1 / s_m) * (1.0 / x_m)) * (1.0 / c_m)) / (c_m * (x_m * s_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[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 1.8e-27], N[(N[(N[(N[(t$95$1 / s$95$m), $MachinePrecision] * N[(1.0 / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 / c$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $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 := s\_m \cdot \left(x\_m \cdot c\_m\right)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;x\_m \leq 1.8 \cdot 10^{-27}:\\
\;\;\;\;\frac{\left(\frac{t\_1}{s\_m} \cdot \frac{1}{x\_m}\right) \cdot \frac{1}{c\_m}}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 1.7999999999999999e-27Initial program 67.1%
*-un-lft-identity67.1%
add-sqr-sqrt67.1%
times-frac67.1%
sqrt-prod67.1%
sqrt-pow145.6%
metadata-eval45.6%
pow145.6%
*-commutative45.6%
associate-*r*42.8%
unpow242.8%
pow-prod-down45.6%
sqrt-prod45.6%
Applied egg-rr86.2%
associate-*l/86.2%
*-lft-identity86.2%
*-commutative86.2%
associate-/r*86.2%
unpow286.2%
rem-sqrt-square86.2%
unpow286.2%
rem-sqrt-square97.9%
Simplified97.9%
div-inv97.8%
*-commutative97.8%
add-sqr-sqrt60.2%
fabs-sqr60.2%
add-sqr-sqrt66.9%
Applied egg-rr66.9%
associate-/r*66.9%
div-inv66.9%
Applied egg-rr66.9%
pow166.9%
pow166.9%
metadata-eval66.9%
sqrt-pow160.5%
sqrt-pow166.9%
metadata-eval66.9%
pow166.9%
add-sqr-sqrt52.8%
fabs-sqr52.8%
add-sqr-sqrt97.9%
Applied egg-rr97.9%
unpow197.9%
Simplified97.9%
if 1.7999999999999999e-27 < x Initial program 54.8%
*-un-lft-identity54.8%
add-sqr-sqrt54.8%
times-frac54.8%
sqrt-prod54.8%
sqrt-pow144.2%
metadata-eval44.2%
pow144.2%
*-commutative44.2%
associate-*r*42.6%
unpow242.6%
pow-prod-down44.2%
sqrt-prod44.2%
Applied egg-rr80.9%
associate-*l/81.0%
*-lft-identity81.0%
*-commutative81.0%
associate-/r*81.1%
unpow281.1%
rem-sqrt-square81.1%
unpow281.1%
rem-sqrt-square96.7%
Simplified96.7%
div-inv96.7%
times-frac96.7%
associate-/l/96.6%
*-commutative96.6%
add-sqr-sqrt51.9%
fabs-sqr51.9%
add-sqr-sqrt74.7%
add-sqr-sqrt52.0%
fabs-sqr52.0%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
*-commutative96.6%
*-un-lft-identity96.6%
frac-times96.6%
*-commutative96.6%
un-div-inv96.7%
times-frac96.7%
*-commutative96.7%
frac-times96.6%
*-rgt-identity96.6%
associate-*l*93.1%
associate-*l*95.9%
Applied egg-rr95.9%
Final simplification97.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 (* s_m (* x_m c_m))))
(if (<= x_m 1.5e-27)
(pow (* c_m (* x_m s_m)) -2.0)
(/ (/ (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 <= 1.5e-27) {
tmp = pow((c_m * (x_m * s_m)), -2.0);
} 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 <= 1.5d-27) then
tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
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 <= 1.5e-27) {
tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
} 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 <= 1.5e-27: tmp = math.pow((c_m * (x_m * s_m)), -2.0) 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 <= 1.5e-27) tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0; 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 <= 1.5e-27)
tmp = (c_m * (x_m * s_m)) ^ -2.0;
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, 1.5e-27], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $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 1.5 \cdot 10^{-27}:\\
\;\;\;\;{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 1.5000000000000001e-27Initial program 67.1%
*-un-lft-identity67.1%
add-sqr-sqrt67.1%
times-frac67.1%
sqrt-prod67.1%
sqrt-pow145.6%
metadata-eval45.6%
pow145.6%
*-commutative45.6%
associate-*r*42.8%
unpow242.8%
pow-prod-down45.6%
sqrt-prod45.6%
Applied egg-rr86.2%
associate-*l/86.2%
*-lft-identity86.2%
*-commutative86.2%
associate-/r*86.2%
unpow286.2%
rem-sqrt-square86.2%
unpow286.2%
rem-sqrt-square97.9%
Simplified97.9%
Taylor expanded in x around 0 70.3%
associate-/r*70.3%
unpow270.3%
sqr-abs70.3%
unpow270.3%
associate-/r*70.3%
unpow270.3%
unpow270.3%
swap-sqr86.3%
unpow286.3%
unpow-186.3%
exp-to-pow54.2%
*-commutative54.2%
exp-prod54.5%
*-commutative54.5%
associate-*r*54.5%
metadata-eval54.5%
*-commutative54.5%
exp-to-pow86.9%
Simplified86.9%
if 1.5000000000000001e-27 < x Initial program 54.8%
*-un-lft-identity54.8%
add-sqr-sqrt54.8%
times-frac54.8%
sqrt-prod54.8%
sqrt-pow144.2%
metadata-eval44.2%
pow144.2%
*-commutative44.2%
associate-*r*42.6%
unpow242.6%
pow-prod-down44.2%
sqrt-prod44.2%
Applied egg-rr80.9%
associate-*l/81.0%
*-lft-identity81.0%
*-commutative81.0%
associate-/r*81.1%
unpow281.1%
rem-sqrt-square81.1%
unpow281.1%
rem-sqrt-square96.7%
Simplified96.7%
div-inv96.7%
times-frac96.7%
associate-/l/96.6%
*-commutative96.6%
add-sqr-sqrt51.9%
fabs-sqr51.9%
add-sqr-sqrt74.7%
add-sqr-sqrt52.0%
fabs-sqr52.0%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
*-commutative96.6%
*-un-lft-identity96.6%
frac-times96.6%
*-commutative96.6%
un-div-inv96.7%
times-frac96.7%
*-commutative96.7%
frac-times96.6%
*-rgt-identity96.6%
associate-*l*93.1%
associate-*l*95.9%
Applied egg-rr95.9%
Final simplification89.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)))) (/ (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(cos(Float64(x_m * -2.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 = 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[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
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{\cos \left(x\_m \cdot -2\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 64.0%
associate-/l/64.0%
remove-double-neg64.0%
distribute-frac-neg64.0%
distribute-neg-frac64.0%
remove-double-neg64.0%
*-commutative64.0%
associate-*r*60.7%
unpow260.7%
associate-/r*60.3%
cos-neg60.3%
*-commutative60.3%
distribute-rgt-neg-in60.3%
metadata-eval60.3%
Simplified60.3%
Taylor expanded in x around inf 60.7%
associate-/r*60.7%
unpow260.7%
unpow260.7%
swap-sqr76.2%
unpow276.2%
associate-/r*76.4%
*-commutative76.4%
unpow276.4%
rem-square-sqrt76.4%
swap-sqr84.5%
unpow284.5%
unpow284.5%
rem-sqrt-square97.0%
Simplified97.0%
pow178.3%
metadata-eval78.3%
sqrt-pow178.3%
pow278.3%
sqrt-pow158.7%
metadata-eval58.7%
pow158.7%
add-sqr-sqrt32.9%
fabs-sqr32.9%
add-sqr-sqrt56.1%
sqrt-pow159.2%
metadata-eval59.2%
pow159.2%
add-sqr-sqrt41.0%
fabs-sqr41.0%
add-sqr-sqrt78.3%
Applied egg-rr97.0%
Final simplification97.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 (pow (* c_m (* x_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) {
return pow((c_m * (x_m * s_m)), -2.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
code = (c_m * (x_m * s_m)) ** (-2.0d0)
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.pow((c_m * (x_m * s_m)), -2.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): return math.pow((c_m * (x_m * s_m)), -2.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) return Float64(c_m * Float64(x_m * s_m)) ^ -2.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)
tmp = (c_m * (x_m * s_m)) ^ -2.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_] := N[Power[N[(c$95$m * N[(x$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])\\
\\
{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{-2}
\end{array}
Initial program 64.0%
*-un-lft-identity64.0%
add-sqr-sqrt64.0%
times-frac63.9%
sqrt-prod64.0%
sqrt-pow145.2%
metadata-eval45.2%
pow145.2%
*-commutative45.2%
associate-*r*42.7%
unpow242.7%
pow-prod-down45.2%
sqrt-prod45.2%
Applied egg-rr84.9%
associate-*l/84.9%
*-lft-identity84.9%
*-commutative84.9%
associate-/r*84.9%
unpow284.9%
rem-sqrt-square84.9%
unpow284.9%
rem-sqrt-square97.5%
Simplified97.5%
Taylor expanded in x around 0 64.7%
associate-/r*64.7%
unpow264.7%
sqr-abs64.7%
unpow264.7%
associate-/r*64.7%
unpow264.7%
unpow264.7%
swap-sqr78.3%
unpow278.3%
unpow-178.3%
exp-to-pow46.3%
*-commutative46.3%
exp-prod46.5%
*-commutative46.5%
associate-*r*46.5%
metadata-eval46.5%
*-commutative46.5%
exp-to-pow78.7%
Simplified78.7%
Final simplification78.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 (/ 1.0 (* c_m (* x_m s_m))))) (* 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 = 1.0 / (c_m * (x_m * s_m));
return 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 = 1.0d0 / (c_m * (x_m * s_m))
code = 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 = 1.0 / (c_m * (x_m * s_m));
return 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 = 1.0 / (c_m * (x_m * s_m)) return 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(1.0 / Float64(c_m * Float64(x_m * s_m))) return 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 = 1.0 / (c_m * (x_m * s_m));
tmp = 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[(1.0 / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * 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 := \frac{1}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 64.0%
Taylor expanded in x around 0 55.1%
associate-/r*55.0%
unpow255.0%
unpow255.0%
swap-sqr64.7%
unpow264.7%
associate-/r*64.7%
unpow264.7%
rem-square-sqrt64.7%
swap-sqr71.0%
unpow271.0%
unpow271.0%
rem-sqrt-square78.3%
Simplified78.3%
pow178.3%
metadata-eval78.3%
sqrt-pow178.3%
pow278.3%
add-sqr-sqrt78.3%
inv-pow78.3%
unpow278.3%
unpow-prod-down78.7%
inv-pow78.7%
add-sqr-sqrt46.7%
fabs-sqr46.7%
add-sqr-sqrt59.3%
inv-pow59.3%
add-sqr-sqrt41.2%
fabs-sqr41.2%
add-sqr-sqrt78.7%
Applied egg-rr78.7%
Final simplification78.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)))) (/ 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 64.0%
Taylor expanded in x around 0 55.1%
associate-/r*55.0%
unpow255.0%
unpow255.0%
swap-sqr64.7%
unpow264.7%
associate-/r*64.7%
unpow264.7%
rem-square-sqrt64.7%
swap-sqr71.0%
unpow271.0%
unpow271.0%
rem-sqrt-square78.3%
Simplified78.3%
pow178.3%
metadata-eval78.3%
sqrt-pow178.3%
pow278.3%
sqrt-pow158.7%
metadata-eval58.7%
pow158.7%
add-sqr-sqrt32.9%
fabs-sqr32.9%
add-sqr-sqrt56.1%
sqrt-pow159.2%
metadata-eval59.2%
pow159.2%
add-sqr-sqrt41.0%
fabs-sqr41.0%
add-sqr-sqrt78.3%
Applied egg-rr78.3%
Final simplification78.3%
herbie shell --seed 2024067
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))