
(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}
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* (* x c_m) s_m))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (x * c_m) * s_m;
return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = (x * c_m) * s_m
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = (x * c_m) * s_m;
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = (x * c_m) * s_m return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(x * c_m) * s_m) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = (x * c_m) * s_m;
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(x \cdot c\_m\right) \cdot s\_m\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 66.6%
associate-/r*66.4%
*-commutative66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
cos-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
associate-*r*58.6%
unpow258.6%
*-commutative58.6%
Simplified58.6%
Applied egg-rr98.5%
associate-*l/98.5%
*-un-lft-identity98.5%
*-commutative98.5%
associate-*r*97.1%
associate-*r*98.2%
Applied egg-rr98.2%
Final simplification98.2%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x s_m))))
(if (<= x 4e-49)
(/ (/ 1.0 t_0) t_0)
(/ (/ (cos (* x 2.0)) s_m) (* (* x c_m) (* x (* c_m s_m)))))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 4e-49) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s_m)
if (x <= 4d-49) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = (cos((x * 2.0d0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)))
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 4e-49) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (Math.cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) tmp = 0 if x <= 4e-49: tmp = (1.0 / t_0) / t_0 else: tmp = (math.cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m))) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) tmp = 0.0 if (x <= 4e-49) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / s_m) / Float64(Float64(x * c_m) * Float64(x * Float64(c_m * s_m)))); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = 0.0;
if (x <= 4e-49)
tmp = (1.0 / t_0) / t_0;
else
tmp = (cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4e-49], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s$95$m), $MachinePrecision] / N[(N[(x * c$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\mathbf{if}\;x \leq 4 \cdot 10^{-49}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s\_m}}{\left(x \cdot c\_m\right) \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)}\\
\end{array}
\end{array}
if x < 3.99999999999999975e-49Initial program 68.9%
associate-/r*68.6%
*-commutative68.6%
unpow268.6%
sqr-neg68.6%
unpow268.6%
cos-neg68.6%
*-commutative68.6%
distribute-rgt-neg-in68.6%
metadata-eval68.6%
unpow268.6%
sqr-neg68.6%
unpow268.6%
associate-*r*60.3%
unpow260.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in x around 0 55.9%
associate-/r*55.9%
*-commutative55.9%
unpow255.9%
unpow255.9%
swap-sqr71.0%
unpow271.0%
associate-/r*71.1%
unpow271.1%
unpow271.1%
swap-sqr85.2%
unpow285.2%
Simplified85.2%
pow-flip85.3%
associate-*r*86.0%
metadata-eval86.0%
Applied egg-rr86.0%
metadata-eval86.0%
pow-flip85.8%
pow285.8%
associate-/r*86.0%
associate-*r*84.8%
associate-*r*85.4%
Applied egg-rr85.4%
if 3.99999999999999975e-49 < x Initial program 61.9%
associate-/r*61.9%
*-commutative61.9%
unpow261.9%
sqr-neg61.9%
unpow261.9%
cos-neg61.9%
*-commutative61.9%
distribute-rgt-neg-in61.9%
metadata-eval61.9%
unpow261.9%
sqr-neg61.9%
unpow261.9%
associate-*r*55.2%
unpow255.2%
*-commutative55.2%
Simplified55.2%
Applied egg-rr99.5%
*-un-lft-identity99.5%
associate-*r*99.6%
times-frac99.5%
*-commutative99.5%
Applied egg-rr99.5%
add-cube-cbrt99.3%
pow399.3%
associate-*r*99.4%
Applied egg-rr99.4%
rem-cube-cbrt99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
frac-times96.1%
*-un-lft-identity96.1%
associate-*r*96.1%
*-commutative96.1%
associate-*r*93.9%
Applied egg-rr93.9%
Final simplification88.2%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x s_m))))
(if (<= x 1.04e-82)
(/ (/ 1.0 t_0) t_0)
(/ (/ (cos (* x 2.0)) c_m) (* (* (* x c_m) s_m) (* x s_m))))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 1.04e-82) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s_m)
if (x <= 1.04d-82) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = (cos((x * 2.0d0)) / c_m) / (((x * c_m) * s_m) * (x * s_m))
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 1.04e-82) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (Math.cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) tmp = 0 if x <= 1.04e-82: tmp = (1.0 / t_0) / t_0 else: tmp = (math.cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m)) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) tmp = 0.0 if (x <= 1.04e-82) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(Float64(x * c_m) * s_m) * Float64(x * s_m))); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = 0.0;
if (x <= 1.04e-82)
tmp = (1.0 / t_0) / t_0;
else
tmp = (cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.04e-82], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision] * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\mathbf{if}\;x \leq 1.04 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(\left(x \cdot c\_m\right) \cdot s\_m\right) \cdot \left(x \cdot s\_m\right)}\\
\end{array}
\end{array}
if x < 1.04000000000000004e-82Initial program 68.2%
associate-/r*67.8%
*-commutative67.8%
unpow267.8%
sqr-neg67.8%
unpow267.8%
cos-neg67.8%
*-commutative67.8%
distribute-rgt-neg-in67.8%
metadata-eval67.8%
unpow267.8%
sqr-neg67.8%
unpow267.8%
associate-*r*59.4%
unpow259.4%
*-commutative59.4%
Simplified59.4%
Taylor expanded in x around 0 54.9%
associate-/r*54.8%
*-commutative54.8%
unpow254.8%
unpow254.8%
swap-sqr70.3%
unpow270.3%
associate-/r*70.4%
unpow270.4%
unpow270.4%
swap-sqr84.8%
unpow284.8%
Simplified84.8%
pow-flip85.0%
associate-*r*85.6%
metadata-eval85.6%
Applied egg-rr85.6%
metadata-eval85.6%
pow-flip85.5%
pow285.5%
associate-/r*85.7%
associate-*r*84.5%
associate-*r*85.0%
Applied egg-rr85.0%
if 1.04000000000000004e-82 < x Initial program 63.6%
associate-/r*63.7%
*-commutative63.7%
unpow263.7%
sqr-neg63.7%
unpow263.7%
cos-neg63.7%
*-commutative63.7%
distribute-rgt-neg-in63.7%
metadata-eval63.7%
unpow263.7%
sqr-neg63.7%
unpow263.7%
associate-*r*57.2%
unpow257.2%
*-commutative57.2%
Simplified57.2%
Applied egg-rr99.5%
associate-/r*99.6%
frac-times96.2%
metadata-eval96.2%
times-frac96.2%
*-un-lft-identity96.2%
*-un-lft-identity96.2%
*-commutative96.2%
associate-*r*96.2%
Applied egg-rr96.2%
Final simplification88.9%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ (/ (cos (* x 2.0)) (* (* x c_m) s_m)) (* c_m (* x s_m))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return (cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (cos((x * 2.0d0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return (Math.cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return (math.cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * c_m) * s_m)) / Float64(c_m * Float64(x * s_m))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = (cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\_m\right) \cdot s\_m}}{c\_m \cdot \left(x \cdot s\_m\right)}
\end{array}
Initial program 66.6%
associate-/r*66.4%
*-commutative66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
cos-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
associate-*r*58.6%
unpow258.6%
*-commutative58.6%
Simplified58.6%
Applied egg-rr98.5%
associate-*l/98.5%
*-un-lft-identity98.5%
*-commutative98.5%
associate-*r*97.1%
associate-*r*98.2%
Applied egg-rr98.2%
Taylor expanded in c around 0 97.1%
Final simplification97.1%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ (/ (cos (* x 2.0)) c_m) (* (* x s_m) (* x (* c_m s_m)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return (cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (cos((x * 2.0d0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return (Math.cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return (math.cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(x * s_m) * Float64(x * Float64(c_m * s_m)))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = (cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\_m\right) \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)}
\end{array}
Initial program 66.6%
associate-/r*66.4%
*-commutative66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
cos-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
associate-*r*58.6%
unpow258.6%
*-commutative58.6%
Simplified58.6%
Applied egg-rr98.5%
*-un-lft-identity98.5%
associate-*r*97.1%
times-frac97.0%
*-commutative97.0%
Applied egg-rr97.0%
add-cube-cbrt96.7%
pow396.7%
associate-*r*97.8%
Applied egg-rr97.8%
*-commutative97.8%
frac-times97.8%
*-un-lft-identity97.8%
rem-cube-cbrt98.1%
associate-*r*97.1%
associate-/r*97.0%
frac-times92.4%
div-inv92.4%
associate-*r*93.8%
*-commutative93.8%
associate-*r*92.1%
Applied egg-rr92.1%
Final simplification92.1%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* c_m (* x s_m)))) (/ (/ 1.0 t_0) t_0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
return (1.0 / t_0) / t_0;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c_m * (x * s_m)
code = (1.0d0 / t_0) / t_0
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
return (1.0 / t_0) / t_0;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) return (1.0 / t_0) / t_0
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) return Float64(Float64(1.0 / t_0) / t_0) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = (1.0 / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 66.6%
associate-/r*66.4%
*-commutative66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
cos-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
associate-*r*58.6%
unpow258.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in x around 0 54.0%
associate-/r*53.9%
*-commutative53.9%
unpow253.9%
unpow253.9%
swap-sqr66.9%
unpow266.9%
associate-/r*67.0%
unpow267.0%
unpow267.0%
swap-sqr81.6%
unpow281.6%
Simplified81.6%
pow-flip81.7%
associate-*r*82.2%
metadata-eval82.2%
Applied egg-rr82.2%
metadata-eval82.2%
pow-flip82.0%
pow282.0%
associate-/r*82.2%
associate-*r*81.4%
associate-*r*81.7%
Applied egg-rr81.7%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* c_m (* x s_m)))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c_m * (x * s_m)
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) return 1.0 / (t_0 * t_0)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.6%
associate-/r*66.4%
*-commutative66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
cos-neg66.4%
*-commutative66.4%
distribute-rgt-neg-in66.4%
metadata-eval66.4%
unpow266.4%
sqr-neg66.4%
unpow266.4%
associate-*r*58.6%
unpow258.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in x around 0 54.0%
associate-/r*53.9%
*-commutative53.9%
unpow253.9%
unpow253.9%
swap-sqr66.9%
unpow266.9%
associate-/r*67.0%
unpow267.0%
unpow267.0%
swap-sqr81.6%
unpow281.6%
Simplified81.6%
unpow281.6%
associate-*r*81.2%
associate-*r*82.0%
Applied egg-rr82.0%
Taylor expanded in c around 0 81.2%
Taylor expanded in c around 0 81.6%
Final simplification81.6%
herbie shell --seed 2024185
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))