
(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 8 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 (cos (* 2.0 x))) (t_1 (/ t_0 x)))
(if (<= (/ t_0 (* (pow c_m 2.0) (* x (* x (pow s_m 2.0))))) INFINITY)
(* (/ 1.0 (* c_m (* x s_m))) (/ (/ t_1 s_m) c_m))
(* (* (/ 1.0 (* x c_m)) (/ 1.0 s_m)) (* t_1 (/ 1.0 (* 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 = cos((2.0 * x));
double t_1 = t_0 / x;
double tmp;
if ((t_0 / (pow(c_m, 2.0) * (x * (x * pow(s_m, 2.0))))) <= ((double) INFINITY)) {
tmp = (1.0 / (c_m * (x * s_m))) * ((t_1 / s_m) / c_m);
} else {
tmp = ((1.0 / (x * c_m)) * (1.0 / s_m)) * (t_1 * (1.0 / (c_m * s_m)));
}
return tmp;
}
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 = Math.cos((2.0 * x));
double t_1 = t_0 / x;
double tmp;
if ((t_0 / (Math.pow(c_m, 2.0) * (x * (x * Math.pow(s_m, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / (c_m * (x * s_m))) * ((t_1 / s_m) / c_m);
} else {
tmp = ((1.0 / (x * c_m)) * (1.0 / s_m)) * (t_1 * (1.0 / (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 = math.cos((2.0 * x)) t_1 = t_0 / x tmp = 0 if (t_0 / (math.pow(c_m, 2.0) * (x * (x * math.pow(s_m, 2.0))))) <= math.inf: tmp = (1.0 / (c_m * (x * s_m))) * ((t_1 / s_m) / c_m) else: tmp = ((1.0 / (x * c_m)) * (1.0 / s_m)) * (t_1 * (1.0 / (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 = cos(Float64(2.0 * x)) t_1 = Float64(t_0 / x) tmp = 0.0 if (Float64(t_0 / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s_m ^ 2.0))))) <= Inf) tmp = Float64(Float64(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(t_1 / s_m) / c_m)); else tmp = Float64(Float64(Float64(1.0 / Float64(x * c_m)) * Float64(1.0 / s_m)) * Float64(t_1 * Float64(1.0 / 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 = cos((2.0 * x));
t_1 = t_0 / x;
tmp = 0.0;
if ((t_0 / ((c_m ^ 2.0) * (x * (x * (s_m ^ 2.0))))) <= Inf)
tmp = (1.0 / (c_m * (x * s_m))) * ((t_1 / s_m) / c_m);
else
tmp = ((1.0 / (x * c_m)) * (1.0 / s_m)) * (t_1 * (1.0 / (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[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / x), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$1 / s$95$m), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[(x * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 / s$95$m), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * N[(1.0 / 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 := \cos \left(2 \cdot x\right)\\
t_1 := \frac{t\_0}{x}\\
\mathbf{if}\;\frac{t\_0}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s\_m}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{1}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \frac{\frac{t\_1}{s\_m}}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{x \cdot c\_m} \cdot \frac{1}{s\_m}\right) \cdot \left(t\_1 \cdot \frac{1}{c\_m \cdot s\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0Initial program 83.0%
*-un-lft-identity83.0%
add-sqr-sqrt83.0%
times-frac83.0%
Applied egg-rr99.7%
*-un-lft-identity99.7%
*-commutative99.7%
associate-*r*96.8%
times-frac96.3%
*-commutative96.3%
Applied egg-rr96.3%
associate-*l/96.8%
*-un-lft-identity96.8%
*-commutative96.8%
associate-/r*99.8%
Applied egg-rr99.8%
if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
Applied egg-rr84.7%
*-un-lft-identity84.7%
*-commutative84.7%
associate-*r*84.8%
times-frac84.7%
*-commutative84.7%
Applied egg-rr84.7%
inv-pow84.7%
associate-*r*90.4%
unpow-prod-down90.5%
Applied egg-rr90.5%
unpow-190.5%
unpow-190.5%
Simplified90.5%
Final simplification98.3%
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 (* (/ 1.0 (* c_m (* x s_m))) (/ (/ 1.0 c_m) (* s_m (/ x (cos (* 2.0 x)))))))
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 (1.0 / (c_m * (x * s_m))) * ((1.0 / c_m) / (s_m * (x / cos((2.0 * x)))));
}
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 = (1.0d0 / (c_m * (x * s_m))) * ((1.0d0 / c_m) / (s_m * (x / cos((2.0d0 * x)))))
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 (1.0 / (c_m * (x * s_m))) * ((1.0 / c_m) / (s_m * (x / Math.cos((2.0 * x)))));
}
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 (1.0 / (c_m * (x * s_m))) * ((1.0 / c_m) / (s_m * (x / math.cos((2.0 * x)))))
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(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(1.0 / c_m) / Float64(s_m * Float64(x / cos(Float64(2.0 * x)))))) 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 = (1.0 / (c_m * (x * s_m))) * ((1.0 / c_m) / (s_m * (x / cos((2.0 * x)))));
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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(s$95$m * N[(x / N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $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{1}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \frac{\frac{1}{c\_m}}{s\_m \cdot \frac{x}{\cos \left(2 \cdot x\right)}}
\end{array}
Initial program 69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.4%
times-frac69.4%
Applied egg-rr97.2%
*-un-lft-identity97.2%
*-commutative97.2%
associate-*r*94.8%
times-frac94.4%
*-commutative94.4%
Applied egg-rr94.4%
*-commutative94.4%
clear-num94.4%
associate-/r*94.8%
frac-times97.3%
*-un-lft-identity97.3%
Applied egg-rr97.3%
Final simplification97.3%
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 (* (/ 1.0 (* c_m (* x s_m))) (/ (/ (/ (cos (* 2.0 x)) x) s_m) c_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 (1.0 / (c_m * (x * s_m))) * (((cos((2.0 * x)) / x) / s_m) / c_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 = (1.0d0 / (c_m * (x * s_m))) * (((cos((2.0d0 * x)) / x) / s_m) / c_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 (1.0 / (c_m * (x * s_m))) * (((Math.cos((2.0 * x)) / x) / s_m) / c_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 (1.0 / (c_m * (x * s_m))) * (((math.cos((2.0 * x)) / x) / s_m) / c_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(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(Float64(cos(Float64(2.0 * x)) / x) / s_m) / c_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 = (1.0 / (c_m * (x * s_m))) * (((cos((2.0 * x)) / x) / s_m) / c_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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / s$95$m), $MachinePrecision] / c$95$m), $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{1}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{s\_m}}{c\_m}
\end{array}
Initial program 69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.4%
times-frac69.4%
Applied egg-rr97.2%
*-un-lft-identity97.2%
*-commutative97.2%
associate-*r*94.8%
times-frac94.4%
*-commutative94.4%
Applied egg-rr94.4%
associate-*l/94.8%
*-un-lft-identity94.8%
*-commutative94.8%
associate-/r*97.3%
Applied egg-rr97.3%
Final simplification97.3%
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)))) (/ (/ (cos (* 2.0 x)) 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 (cos((2.0 * x)) / 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 = (cos((2.0d0 * x)) / 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 (Math.cos((2.0 * x)) / 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 (math.cos((2.0 * x)) / 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(cos(Float64(2.0 * x)) / 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 = (cos((2.0 * x)) / 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[(N[Cos[N[(2.0 * x), $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 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 69.4%
add-cbrt-cube69.3%
add-cbrt-cube64.6%
cbrt-undiv64.6%
pow364.6%
pow364.6%
Applied egg-rr76.4%
cbrt-div76.4%
rem-cbrt-cube76.4%
rem-cbrt-cube97.2%
unpow297.2%
associate-/r*97.3%
*-commutative97.3%
Applied egg-rr97.3%
Final simplification97.3%
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 (* (/ 1.0 (* c_m (* x s_m))) (/ (/ (/ 1.0 x) s_m) c_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 (1.0 / (c_m * (x * s_m))) * (((1.0 / x) / s_m) / c_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 = (1.0d0 / (c_m * (x * s_m))) * (((1.0d0 / x) / s_m) / c_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 (1.0 / (c_m * (x * s_m))) * (((1.0 / x) / s_m) / c_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 (1.0 / (c_m * (x * s_m))) * (((1.0 / x) / s_m) / c_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(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(Float64(1.0 / x) / s_m) / c_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 = (1.0 / (c_m * (x * s_m))) * (((1.0 / x) / s_m) / c_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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / x), $MachinePrecision] / s$95$m), $MachinePrecision] / c$95$m), $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{1}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \frac{\frac{\frac{1}{x}}{s\_m}}{c\_m}
\end{array}
Initial program 69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.4%
times-frac69.4%
Applied egg-rr97.2%
Taylor expanded in x around 0 81.1%
*-commutative81.1%
associate-/l/81.1%
associate-/r*81.2%
Simplified81.2%
Final simplification81.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 (/ 1.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 1.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 = 1.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 1.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 1.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(1.0 / Float64(Float64(x * c_m) * Float64(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 = 1.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[(1.0 / N[(N[(x * c$95$m), $MachinePrecision] * N[(s$95$m * N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $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{1}{\left(x \cdot c\_m\right) \cdot \left(s\_m \cdot \left(c\_m \cdot \left(x \cdot s\_m\right)\right)\right)}
\end{array}
Initial program 69.4%
Taylor expanded in x around 0 58.3%
associate-/r*57.9%
*-commutative57.9%
unpow257.9%
unpow257.9%
swap-sqr66.2%
unpow266.2%
associate-/r*66.6%
unpow266.6%
unpow266.6%
swap-sqr81.0%
unpow281.0%
*-commutative81.0%
Simplified81.0%
*-commutative81.0%
unpow281.0%
associate-*r*80.7%
associate-*l*79.2%
Applied egg-rr79.2%
Final simplification79.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)))) (/ 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 69.4%
Taylor expanded in x around 0 58.3%
associate-/r*57.9%
*-commutative57.9%
unpow257.9%
unpow257.9%
swap-sqr66.2%
unpow266.2%
associate-/r*66.6%
unpow266.6%
unpow266.6%
swap-sqr81.0%
unpow281.0%
*-commutative81.0%
Simplified81.0%
*-commutative81.0%
unpow281.0%
Applied egg-rr81.0%
Final simplification81.0%
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 69.4%
add-cbrt-cube69.3%
add-cbrt-cube64.6%
cbrt-undiv64.6%
pow364.6%
pow364.6%
Applied egg-rr76.4%
cbrt-div76.4%
rem-cbrt-cube76.4%
rem-cbrt-cube97.2%
unpow297.2%
associate-/r*97.3%
*-commutative97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 81.1%
Final simplification81.1%
herbie shell --seed 2024079
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))