
(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 11 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}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* 2.0 x))))
(if (<= (pow s 2.0) 1e+110)
(* (/ 1.0 (* c (* s x))) (/ (/ (/ t_0 x) s) c))
(* (/ 1.0 (/ (* s c) (/ 1.0 x))) (/ t_0 (* x (* s c)))))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((2.0 * x));
double tmp;
if (pow(s, 2.0) <= 1e+110) {
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
} else {
tmp = (1.0 / ((s * c) / (1.0 / x))) * (t_0 / (x * (s * c)));
}
return tmp;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = cos((2.0d0 * x))
if ((s ** 2.0d0) <= 1d+110) then
tmp = (1.0d0 / (c * (s * x))) * (((t_0 / x) / s) / c)
else
tmp = (1.0d0 / ((s * c) / (1.0d0 / x))) * (t_0 / (x * (s * c)))
end if
code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((2.0 * x));
double tmp;
if (Math.pow(s, 2.0) <= 1e+110) {
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
} else {
tmp = (1.0 / ((s * c) / (1.0 / x))) * (t_0 / (x * (s * c)));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((2.0 * x)) tmp = 0 if math.pow(s, 2.0) <= 1e+110: tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c) else: tmp = (1.0 / ((s * c) / (1.0 / x))) * (t_0 / (x * (s * c))) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(2.0 * x)) tmp = 0.0 if ((s ^ 2.0) <= 1e+110) tmp = Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(t_0 / x) / s) / c)); else tmp = Float64(Float64(1.0 / Float64(Float64(s * c) / Float64(1.0 / x))) * Float64(t_0 / Float64(x * Float64(s * c)))); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((2.0 * x));
tmp = 0.0;
if ((s ^ 2.0) <= 1e+110)
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
else
tmp = (1.0 / ((s * c) / (1.0 / x))) * (t_0 / (x * (s * c)));
end
tmp_2 = tmp;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[s, 2.0], $MachinePrecision], 1e+110], N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(t$95$0 / x), $MachinePrecision] / s), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(s * c), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;{s}^{2} \leq 10^{+110}:\\
\;\;\;\;\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{t_0}{x}}{s}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{s \cdot c}{\frac{1}{x}}} \cdot \frac{t_0}{x \cdot \left(s \cdot c\right)}\\
\end{array}
\end{array}
if (pow.f64 s 2) < 1e110Initial program 65.2%
Applied egg-rr97.2%
Taylor expanded in x around inf 97.2%
associate-/r*97.2%
*-commutative97.2%
*-commutative97.2%
*-rgt-identity97.2%
associate-*r/96.4%
associate-*l/96.3%
associate-*r/96.3%
*-rgt-identity96.3%
*-commutative96.3%
Simplified96.3%
*-un-lft-identity96.3%
times-frac96.4%
Applied egg-rr96.4%
associate-*l/96.5%
*-lft-identity96.5%
Simplified96.5%
if 1e110 < (pow.f64 s 2) Initial program 70.1%
Applied egg-rr96.4%
/-rgt-identity96.4%
*-commutative96.4%
associate-*r*95.6%
associate-/l*95.6%
Applied egg-rr95.6%
Taylor expanded in x around inf 95.6%
*-commutative95.6%
associate-*r*98.8%
Simplified98.8%
Final simplification97.5%
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* 2.0 x))) (t_1 (* x (* s c))))
(if (<= (pow s 2.0) 2e+43)
(* (/ 1.0 (* c (* s x))) (/ (/ (/ t_0 x) s) c))
(* t_0 (/ 1.0 (* t_1 t_1))))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((2.0 * x));
double t_1 = x * (s * c);
double tmp;
if (pow(s, 2.0) <= 2e+43) {
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
} else {
tmp = t_0 * (1.0 / (t_1 * t_1));
}
return tmp;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((2.0d0 * x))
t_1 = x * (s * c)
if ((s ** 2.0d0) <= 2d+43) then
tmp = (1.0d0 / (c * (s * x))) * (((t_0 / x) / s) / c)
else
tmp = t_0 * (1.0d0 / (t_1 * t_1))
end if
code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((2.0 * x));
double t_1 = x * (s * c);
double tmp;
if (Math.pow(s, 2.0) <= 2e+43) {
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
} else {
tmp = t_0 * (1.0 / (t_1 * t_1));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((2.0 * x)) t_1 = x * (s * c) tmp = 0 if math.pow(s, 2.0) <= 2e+43: tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c) else: tmp = t_0 * (1.0 / (t_1 * t_1)) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(2.0 * x)) t_1 = Float64(x * Float64(s * c)) tmp = 0.0 if ((s ^ 2.0) <= 2e+43) tmp = Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(t_0 / x) / s) / c)); else tmp = Float64(t_0 * Float64(1.0 / Float64(t_1 * t_1))); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((2.0 * x));
t_1 = x * (s * c);
tmp = 0.0;
if ((s ^ 2.0) <= 2e+43)
tmp = (1.0 / (c * (s * x))) * (((t_0 / x) / s) / c);
else
tmp = t_0 * (1.0 / (t_1 * t_1));
end
tmp_2 = tmp;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[s, 2.0], $MachinePrecision], 2e+43], N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(t$95$0 / x), $MachinePrecision] / s), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
t_1 := x \cdot \left(s \cdot c\right)\\
\mathbf{if}\;{s}^{2} \leq 2 \cdot 10^{+43}:\\
\;\;\;\;\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{t_0}{x}}{s}}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1 \cdot t_1}\\
\end{array}
\end{array}
if (pow.f64 s 2) < 2.00000000000000003e43Initial program 63.6%
Applied egg-rr97.0%
Taylor expanded in x around inf 97.0%
associate-/r*97.0%
*-commutative97.0%
*-commutative97.0%
*-rgt-identity97.0%
associate-*r/96.1%
associate-*l/96.0%
associate-*r/96.0%
*-rgt-identity96.0%
*-commutative96.0%
Simplified96.0%
*-un-lft-identity96.0%
times-frac96.1%
Applied egg-rr96.1%
associate-*l/96.2%
*-lft-identity96.2%
Simplified96.2%
if 2.00000000000000003e43 < (pow.f64 s 2) Initial program 71.4%
*-un-lft-identity71.4%
associate-*r*70.8%
times-frac70.8%
*-commutative70.8%
associate-*r*68.5%
pow-prod-down83.1%
Applied egg-rr83.1%
Applied egg-rr83.8%
expm1-def95.6%
expm1-log1p96.8%
*-commutative96.8%
associate-*r*98.9%
Simplified98.9%
add-sqr-sqrt98.9%
pow298.9%
sqrt-pow198.9%
metadata-eval98.9%
unpow-198.9%
associate-/l/98.8%
clear-num98.8%
pow298.8%
frac-2neg98.8%
metadata-eval98.8%
frac-2neg98.8%
metadata-eval98.8%
frac-times98.0%
metadata-eval98.0%
associate-/r/98.1%
/-rgt-identity98.1%
distribute-rgt-neg-in98.1%
associate-/r/98.1%
/-rgt-identity98.1%
Applied egg-rr98.1%
Final simplification97.1%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (cos (* 2.0 x)) (/ (/ (/ 1.0 c) (* s x)) (* c (* s x)))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((2.0 * x)) * (((1.0 / c) / (s * x)) / (c * (s * x)));
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
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)) * (((1.0d0 / c) / (s * x)) / (c * (s * x)))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) * (((1.0 / c) / (s * x)) / (c * (s * x)));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((2.0 * x)) * (((1.0 / c) / (s * x)) / (c * (s * x)))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(2.0 * x)) * Float64(Float64(Float64(1.0 / c) / Float64(s * x)) / Float64(c * Float64(s * x)))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((2.0 * x)) * (((1.0 / c) / (s * x)) / (c * (s * x)));
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\cos \left(2 \cdot x\right) \cdot \frac{\frac{\frac{1}{c}}{s \cdot x}}{c \cdot \left(s \cdot x\right)}
\end{array}
Initial program 67.3%
*-un-lft-identity67.3%
associate-*r*67.5%
times-frac67.7%
*-commutative67.7%
associate-*r*65.3%
pow-prod-down82.6%
Applied egg-rr82.6%
Applied egg-rr73.0%
expm1-def87.4%
expm1-log1p96.9%
*-commutative96.9%
associate-*r*96.8%
Simplified96.8%
metadata-eval96.8%
pow-prod-up96.7%
pow-prod-down96.2%
associate-*l*94.3%
*-commutative94.3%
associate-*r*91.7%
inv-pow91.7%
associate-*r*94.3%
*-commutative94.3%
associate-*l*96.2%
associate-/r*96.8%
metadata-eval96.8%
associate-*l*94.6%
*-commutative94.6%
frac-times94.0%
associate-*l/94.6%
*-un-lft-identity94.6%
associate-*l*96.9%
Applied egg-rr96.9%
Final simplification96.9%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (/ 1.0 (* c (* s x))) (/ (/ (/ (cos (* 2.0 x)) x) s) c)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((cos((2.0 * x)) / x) / s) / c);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (1.0d0 / (c * (s * x))) * (((cos((2.0d0 * x)) / x) / s) / c)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((Math.cos((2.0 * x)) / x) / s) / c);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (s * x))) * (((math.cos((2.0 * x)) / x) / s) / c)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(cos(Float64(2.0 * x)) / x) / s) / c)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (s * x))) * (((cos((2.0 * x)) / x) / s) / c);
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / s), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{s}}{c}
\end{array}
Initial program 67.3%
Applied egg-rr96.8%
Taylor expanded in x around inf 96.8%
associate-/r*96.9%
*-commutative96.9%
*-commutative96.9%
*-rgt-identity96.9%
associate-*r/96.4%
associate-*l/96.4%
associate-*r/96.4%
*-rgt-identity96.4%
*-commutative96.4%
Simplified96.4%
*-un-lft-identity96.4%
times-frac96.4%
Applied egg-rr96.4%
associate-*l/96.5%
*-lft-identity96.5%
Simplified96.5%
Final simplification96.5%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* s x)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (cos((2.0 * x)) / t_0) / t_0;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (s * x)
code = (cos((2.0d0 * x)) / t_0) / t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (Math.cos((2.0 * x)) / t_0) / t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (s * x) return (math.cos((2.0 * x)) / t_0) / t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (s * x);
tmp = (cos((2.0 * x)) / t_0) / t_0;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 67.3%
*-un-lft-identity67.3%
associate-*r*67.5%
times-frac67.7%
*-commutative67.7%
associate-*r*65.3%
pow-prod-down82.6%
Applied egg-rr82.6%
clear-num82.6%
frac-times82.2%
*-un-lft-identity82.2%
/-rgt-identity82.2%
associate-*l*75.1%
unpow275.1%
swap-sqr96.2%
associate-*r*94.3%
*-commutative94.3%
associate-*r*96.5%
*-commutative96.5%
associate-/r*96.9%
*-commutative96.9%
Applied egg-rr96.9%
Final simplification96.9%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (/ 1.0 (* c (* s x))))) (* t_0 t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (s * x));
return t_0 * t_0;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = 1.0d0 / (c * (s * x))
code = t_0 * t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (s * x));
return t_0 * t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = 1.0 / (c * (s * x)) return t_0 * t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(1.0 / Float64(c * Float64(s * x))) return Float64(t_0 * t_0) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = 1.0 / (c * (s * x));
tmp = t_0 * t_0;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(s \cdot x\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 67.3%
Applied egg-rr96.8%
Taylor expanded in x around 0 78.1%
Final simplification78.1%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (/ 1.0 (* c (* s x))) (/ (/ (/ 1.0 s) x) c)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (1.0d0 / (c * (s * x))) * (((1.0d0 / s) / x) / c)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(1.0 / s) / x) / c)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{s}}{x}}{c}
\end{array}
Initial program 67.3%
Applied egg-rr96.8%
Taylor expanded in x around 0 78.1%
associate-/r*78.1%
*-commutative78.1%
*-lft-identity78.1%
associate-*l/77.6%
associate-*r/77.6%
*-rgt-identity77.6%
associate-/l/77.6%
Simplified77.6%
Final simplification77.6%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (/ 1.0 (* c (* s x))) (/ (/ (/ 1.0 x) s) c)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (1.0d0 / (c * (s * x))) * (((1.0d0 / x) / s) / c)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(1.0 / x) / s) / c)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / x), $MachinePrecision] / s), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{x}}{s}}{c}
\end{array}
Initial program 67.3%
Applied egg-rr96.8%
Taylor expanded in x around inf 96.8%
associate-/r*96.9%
*-commutative96.9%
*-commutative96.9%
*-rgt-identity96.9%
associate-*r/96.4%
associate-*l/96.4%
associate-*r/96.4%
*-rgt-identity96.4%
*-commutative96.4%
Simplified96.4%
*-un-lft-identity96.4%
times-frac96.4%
Applied egg-rr96.4%
associate-*l/96.5%
*-lft-identity96.5%
Simplified96.5%
Taylor expanded in x around 0 77.6%
Final simplification77.6%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (* s c) (* x (* c (* s x))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((s * c) * (x * (c * (s * x))));
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((s * c) * (x * (c * (s * x))))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((s * c) * (x * (c * (s * x))));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((s * c) * (x * (c * (s * x))))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(s * c) * Float64(x * Float64(c * Float64(s * x))))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((s * c) * (x * (c * (s * x))));
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(s * c), $MachinePrecision] * N[(x * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}
\end{array}
Initial program 67.3%
Taylor expanded in x around 0 54.0%
unpow254.0%
*-commutative54.0%
unpow254.0%
unpow254.0%
swap-sqr66.0%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
unpow278.0%
associate-*r*77.6%
*-commutative77.6%
associate-*l*76.7%
Applied egg-rr76.7%
Final simplification76.7%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (* s c) (* x (* x (* s c))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((s * c) * (x * (x * (s * c))));
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((s * c) * (x * (x * (s * c))))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((s * c) * (x * (x * (s * c))));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((s * c) * (x * (x * (s * c))))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(s * c) * Float64(x * Float64(x * Float64(s * c))))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((s * c) * (x * (x * (s * c))));
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(s * c), $MachinePrecision] * N[(x * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}
\end{array}
Initial program 67.3%
Taylor expanded in x around 0 54.0%
unpow254.0%
*-commutative54.0%
unpow254.0%
unpow254.0%
swap-sqr66.0%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
unpow278.0%
associate-*r*77.6%
*-commutative77.6%
associate-*l*76.7%
Applied egg-rr76.7%
Taylor expanded in c around 0 76.7%
associate-*r*77.6%
Simplified77.6%
Final simplification77.6%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* s x)))) (/ 1.0 (* t_0 t_0))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (s * x);
return 1.0 / (t_0 * t_0);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (s * x)
code = 1.0d0 / (t_0 * t_0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (s * x);
return 1.0 / (t_0 * t_0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (s * x) return 1.0 / (t_0 * t_0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(1.0 / Float64(t_0 * t_0)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (s * x);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 67.3%
Taylor expanded in x around 0 54.0%
unpow254.0%
*-commutative54.0%
unpow254.0%
unpow254.0%
swap-sqr66.0%
swap-sqr78.0%
unpow278.0%
*-commutative78.0%
Simplified78.0%
*-commutative78.0%
unpow278.0%
Applied egg-rr78.0%
Final simplification78.0%
herbie shell --seed 2023320
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))