
(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 10 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) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ (* (/ (/ 1.0 c_m) (* x s)) (cos (* x 2.0))) (* c_m (* x s))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return (((1.0 / c_m) / (x * s)) * cos((x * 2.0))) / (c_m * (x * s));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = (((1.0d0 / c_m) / (x * s)) * cos((x * 2.0d0))) / (c_m * (x * s))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return (((1.0 / c_m) / (x * s)) * Math.cos((x * 2.0))) / (c_m * (x * s));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return (((1.0 / c_m) / (x * s)) * math.cos((x * 2.0))) / (c_m * (x * s))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(Float64(Float64(1.0 / c_m) / Float64(x * s)) * cos(Float64(x * 2.0))) / Float64(c_m * Float64(x * s))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = (((1.0 / c_m) / (x * s)) * cos((x * 2.0))) / (c_m * (x * s));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{\frac{1}{c_m}}{x \cdot s} \cdot \cos \left(x \cdot 2\right)}{c_m \cdot \left(x \cdot s\right)}
\end{array}
Initial program 57.5%
associate-/r*57.0%
*-commutative57.0%
associate-*r*52.8%
unpow252.8%
associate-/r*53.2%
add-sqr-sqrt28.0%
sqrt-unprod44.9%
swap-sqr44.9%
metadata-eval44.9%
metadata-eval44.9%
swap-sqr44.9%
*-commutative44.9%
*-commutative44.9%
sqrt-unprod22.6%
add-sqr-sqrt53.2%
clear-num53.2%
inv-pow53.2%
Applied egg-rr96.5%
unpow-196.5%
*-commutative96.5%
associate-/r/96.4%
pow-flip96.5%
*-commutative96.5%
metadata-eval96.5%
*-commutative96.5%
Applied egg-rr96.5%
metadata-eval96.5%
pow-div96.4%
inv-pow96.4%
pow196.4%
associate-*l/96.4%
associate-/r*96.5%
Applied egg-rr96.5%
Final simplification96.5%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (if (<= x 5e-29) (pow (/ (/ 1.0 c_m) (* x s)) 2.0) (/ (/ (cos (* x 2.0)) c_m) (* s (* (* x s) (* c_m x))))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double tmp;
if (x <= 5e-29) {
tmp = pow(((1.0 / c_m) / (x * s)), 2.0);
} else {
tmp = (cos((x * 2.0)) / c_m) / (s * ((x * s) * (c_m * x)));
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 5d-29) then
tmp = ((1.0d0 / c_m) / (x * s)) ** 2.0d0
else
tmp = (cos((x * 2.0d0)) / c_m) / (s * ((x * s) * (c_m * x)))
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double tmp;
if (x <= 5e-29) {
tmp = Math.pow(((1.0 / c_m) / (x * s)), 2.0);
} else {
tmp = (Math.cos((x * 2.0)) / c_m) / (s * ((x * s) * (c_m * x)));
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): tmp = 0 if x <= 5e-29: tmp = math.pow(((1.0 / c_m) / (x * s)), 2.0) else: tmp = (math.cos((x * 2.0)) / c_m) / (s * ((x * s) * (c_m * x))) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) tmp = 0.0 if (x <= 5e-29) tmp = Float64(Float64(1.0 / c_m) / Float64(x * s)) ^ 2.0; else tmp = Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(s * Float64(Float64(x * s) * Float64(c_m * x)))); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
tmp = 0.0;
if (x <= 5e-29)
tmp = ((1.0 / c_m) / (x * s)) ^ 2.0;
else
tmp = (cos((x * 2.0)) / c_m) / (s * ((x * s) * (c_m * x)));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := If[LessEqual[x, 5e-29], N[Power[N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(s * N[(N[(x * s), $MachinePrecision] * N[(c$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-29}:\\
\;\;\;\;{\left(\frac{\frac{1}{c_m}}{x \cdot s}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{c_m}}{s \cdot \left(\left(x \cdot s\right) \cdot \left(c_m \cdot x\right)\right)}\\
\end{array}
\end{array}
if x < 4.99999999999999986e-29Initial program 57.0%
Taylor expanded in x around 0 49.6%
associate-/r*49.5%
*-commutative49.5%
unpow249.5%
unpow249.5%
swap-sqr65.6%
unpow265.6%
associate-/r*65.6%
unpow265.6%
unpow265.6%
swap-sqr85.0%
unpow285.0%
*-commutative85.0%
Simplified85.0%
add-sqr-sqrt84.9%
sqrt-div84.9%
metadata-eval84.9%
*-commutative84.9%
unpow284.9%
sqrt-prod57.5%
add-sqr-sqrt55.5%
sqrt-div55.5%
metadata-eval55.5%
*-commutative55.5%
unpow255.5%
sqrt-prod42.3%
add-sqr-sqrt84.9%
Applied egg-rr84.9%
pow284.9%
associate-/r*84.9%
Applied egg-rr84.9%
if 4.99999999999999986e-29 < x Initial program 58.7%
associate-/r*57.2%
*-commutative57.2%
associate-*r*53.9%
unpow253.9%
associate-/r*55.4%
add-sqr-sqrt52.6%
sqrt-unprod39.7%
swap-sqr39.7%
metadata-eval39.7%
metadata-eval39.7%
swap-sqr39.7%
*-commutative39.7%
*-commutative39.7%
sqrt-unprod0.0%
add-sqr-sqrt55.4%
clear-num55.3%
inv-pow55.3%
Applied egg-rr97.0%
unpow-197.0%
*-commutative97.0%
associate-/r/96.9%
pow-flip97.0%
*-commutative97.0%
metadata-eval97.0%
*-commutative97.0%
Applied egg-rr97.0%
associate-*r*99.7%
pow-prod-down69.7%
*-commutative69.7%
pow-prod-down99.7%
metadata-eval99.7%
pow-flip99.6%
pow-prod-down70.8%
associate-*l/70.8%
*-un-lft-identity70.8%
*-commutative70.8%
pow-prod-down99.6%
associate-*r*97.0%
pow297.0%
associate-*l*94.4%
*-commutative94.4%
associate-*r*93.1%
associate-/r*93.0%
*-commutative93.0%
Applied egg-rr93.0%
Final simplification87.2%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (if (<= x 1.75e-22) (pow (/ (/ 1.0 c_m) (* x s)) 2.0) (/ (/ (cos (* x 2.0)) (* c_m s)) (* (* x s) (* c_m x)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double tmp;
if (x <= 1.75e-22) {
tmp = pow(((1.0 / c_m) / (x * s)), 2.0);
} else {
tmp = (cos((x * 2.0)) / (c_m * s)) / ((x * s) * (c_m * x));
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 1.75d-22) then
tmp = ((1.0d0 / c_m) / (x * s)) ** 2.0d0
else
tmp = (cos((x * 2.0d0)) / (c_m * s)) / ((x * s) * (c_m * x))
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double tmp;
if (x <= 1.75e-22) {
tmp = Math.pow(((1.0 / c_m) / (x * s)), 2.0);
} else {
tmp = (Math.cos((x * 2.0)) / (c_m * s)) / ((x * s) * (c_m * x));
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): tmp = 0 if x <= 1.75e-22: tmp = math.pow(((1.0 / c_m) / (x * s)), 2.0) else: tmp = (math.cos((x * 2.0)) / (c_m * s)) / ((x * s) * (c_m * x)) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) tmp = 0.0 if (x <= 1.75e-22) tmp = Float64(Float64(1.0 / c_m) / Float64(x * s)) ^ 2.0; else tmp = Float64(Float64(cos(Float64(x * 2.0)) / Float64(c_m * s)) / Float64(Float64(x * s) * Float64(c_m * x))); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
tmp = 0.0;
if (x <= 1.75e-22)
tmp = ((1.0 / c_m) / (x * s)) ^ 2.0;
else
tmp = (cos((x * 2.0)) / (c_m * s)) / ((x * s) * (c_m * x));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := If[LessEqual[x, 1.75e-22], N[Power[N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(c$95$m * s), $MachinePrecision]), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{-22}:\\
\;\;\;\;{\left(\frac{\frac{1}{c_m}}{x \cdot s}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{c_m \cdot s}}{\left(x \cdot s\right) \cdot \left(c_m \cdot x\right)}\\
\end{array}
\end{array}
if x < 1.75000000000000003e-22Initial program 57.1%
Taylor expanded in x around 0 49.8%
associate-/r*49.8%
*-commutative49.8%
unpow249.8%
unpow249.8%
swap-sqr65.6%
unpow265.6%
associate-/r*65.6%
unpow265.6%
unpow265.6%
swap-sqr85.2%
unpow285.2%
*-commutative85.2%
Simplified85.2%
add-sqr-sqrt85.1%
sqrt-div85.1%
metadata-eval85.1%
*-commutative85.1%
unpow285.1%
sqrt-prod57.1%
add-sqr-sqrt55.1%
sqrt-div55.1%
metadata-eval55.1%
*-commutative55.1%
unpow255.1%
sqrt-prod42.1%
add-sqr-sqrt85.1%
Applied egg-rr85.1%
pow285.1%
associate-/r*85.2%
Applied egg-rr85.2%
if 1.75000000000000003e-22 < x Initial program 58.4%
associate-/r*56.7%
*-commutative56.7%
associate-*r*53.3%
unpow253.3%
associate-/r*54.9%
add-sqr-sqrt52.0%
sqrt-unprod38.6%
swap-sqr38.6%
metadata-eval38.6%
metadata-eval38.6%
swap-sqr38.6%
*-commutative38.6%
*-commutative38.6%
sqrt-unprod0.0%
add-sqr-sqrt54.9%
clear-num54.9%
inv-pow54.9%
Applied egg-rr96.9%
unpow-196.9%
*-commutative96.9%
associate-/r/96.9%
pow-flip96.9%
*-commutative96.9%
metadata-eval96.9%
*-commutative96.9%
Applied egg-rr96.9%
associate-*r*99.7%
pow-prod-down69.9%
*-commutative69.9%
pow-prod-down99.7%
metadata-eval99.7%
pow-flip99.6%
pow-prod-down71.0%
associate-/r/71.0%
clear-num71.0%
*-commutative71.0%
pow-prod-down99.7%
associate-*r*96.9%
pow296.9%
associate-*l*94.2%
*-commutative94.2%
associate-*r*92.8%
associate-*l*90.1%
Applied egg-rr90.1%
Final simplification86.5%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (* (/ (/ 1.0 c_m) (* x s)) (/ (cos (* x 2.0)) (* c_m (* x s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return ((1.0 / c_m) / (x * s)) * (cos((x * 2.0)) / (c_m * (x * s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = ((1.0d0 / c_m) / (x * s)) * (cos((x * 2.0d0)) / (c_m * (x * s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return ((1.0 / c_m) / (x * s)) * (Math.cos((x * 2.0)) / (c_m * (x * s)));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return ((1.0 / c_m) / (x * s)) * (math.cos((x * 2.0)) / (c_m * (x * s)))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(Float64(1.0 / c_m) / Float64(x * s)) * Float64(cos(Float64(x * 2.0)) / Float64(c_m * Float64(x * s)))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = ((1.0 / c_m) / (x * s)) * (cos((x * 2.0)) / (c_m * (x * s)));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{1}{c_m}}{x \cdot s} \cdot \frac{\cos \left(x \cdot 2\right)}{c_m \cdot \left(x \cdot s\right)}
\end{array}
Initial program 57.5%
associate-/r*57.0%
*-commutative57.0%
associate-*r*52.8%
unpow252.8%
associate-/r*53.2%
add-sqr-sqrt28.0%
sqrt-unprod44.9%
swap-sqr44.9%
metadata-eval44.9%
metadata-eval44.9%
swap-sqr44.9%
*-commutative44.9%
*-commutative44.9%
sqrt-unprod22.6%
add-sqr-sqrt53.2%
clear-num53.2%
inv-pow53.2%
Applied egg-rr96.5%
unpow296.5%
*-commutative96.5%
associate-*r*93.6%
associate-*l*90.1%
Applied egg-rr90.1%
unpow-190.1%
*-commutative90.1%
clear-num90.1%
*-un-lft-identity90.1%
associate-*l*90.7%
associate-*r*92.4%
*-commutative92.4%
associate-*l*96.5%
times-frac96.4%
associate-/r*96.4%
Applied egg-rr96.4%
Final simplification96.4%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* c_m (* x s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c_m * (x * s)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = c_m * (x * s) return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(c_m * Float64(x * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = c_m * (x * s);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $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|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 57.5%
associate-/r*57.0%
*-commutative57.0%
associate-*r*52.8%
unpow252.8%
associate-/r*53.2%
add-sqr-sqrt28.0%
sqrt-unprod44.9%
swap-sqr44.9%
metadata-eval44.9%
metadata-eval44.9%
swap-sqr44.9%
*-commutative44.9%
*-commutative44.9%
sqrt-unprod22.6%
add-sqr-sqrt53.2%
clear-num53.2%
inv-pow53.2%
Applied egg-rr96.5%
unpow-196.5%
clear-num96.5%
unpow296.5%
associate-/r*96.4%
*-commutative96.4%
Applied egg-rr96.4%
Final simplification96.4%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (/ 1.0 (* c_m (* x s))))) (* t_0 t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = 1.0 / (c_m * (x * s));
return t_0 * t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = 1.0d0 / (c_m * (x * s))
code = t_0 * t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = 1.0 / (c_m * (x * s));
return t_0 * t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = 1.0 / (c_m * (x * s)) return t_0 * t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(1.0 / Float64(c_m * Float64(x * s))) return Float64(t_0 * t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = 1.0 / (c_m * (x * s));
tmp = t_0 * t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c_m \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 48.5%
associate-/r*48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr61.1%
unpow261.1%
associate-/r*61.5%
unpow261.5%
unpow261.5%
swap-sqr78.6%
unpow278.6%
*-commutative78.6%
Simplified78.6%
add-sqr-sqrt78.5%
sqrt-div78.6%
metadata-eval78.6%
*-commutative78.6%
unpow278.6%
sqrt-prod50.0%
add-sqr-sqrt57.3%
sqrt-div57.3%
metadata-eval57.3%
*-commutative57.3%
unpow257.3%
sqrt-prod39.8%
add-sqr-sqrt78.6%
Applied egg-rr78.6%
Final simplification78.6%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (* (/ (/ 1.0 c_m) (* x s)) (/ 1.0 (* c_m (* x s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return ((1.0 / c_m) / (x * s)) * (1.0 / (c_m * (x * s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = ((1.0d0 / c_m) / (x * s)) * (1.0d0 / (c_m * (x * s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return ((1.0 / c_m) / (x * s)) * (1.0 / (c_m * (x * s)));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return ((1.0 / c_m) / (x * s)) * (1.0 / (c_m * (x * s)))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(Float64(1.0 / c_m) / Float64(x * s)) * Float64(1.0 / Float64(c_m * Float64(x * s)))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = ((1.0 / c_m) / (x * s)) * (1.0 / (c_m * (x * s)));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{1}{c_m}}{x \cdot s} \cdot \frac{1}{c_m \cdot \left(x \cdot s\right)}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 48.5%
associate-/r*48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr61.1%
unpow261.1%
associate-/r*61.5%
unpow261.5%
unpow261.5%
swap-sqr78.6%
unpow278.6%
*-commutative78.6%
Simplified78.6%
add-sqr-sqrt78.5%
sqrt-div78.6%
metadata-eval78.6%
*-commutative78.6%
unpow278.6%
sqrt-prod50.0%
add-sqr-sqrt57.3%
sqrt-div57.3%
metadata-eval57.3%
*-commutative57.3%
unpow257.3%
sqrt-prod39.8%
add-sqr-sqrt78.6%
Applied egg-rr78.6%
Taylor expanded in c around 0 78.6%
associate-/r*78.6%
Simplified78.6%
Final simplification78.6%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ (/ -1.0 c_m) (* (* x s) (* c_m (* x (- s))))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return (-1.0 / c_m) / ((x * s) * (c_m * (x * -s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = ((-1.0d0) / c_m) / ((x * s) * (c_m * (x * -s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return (-1.0 / c_m) / ((x * s) * (c_m * (x * -s)));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return (-1.0 / c_m) / ((x * s) * (c_m * (x * -s)))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(-1.0 / c_m) / Float64(Float64(x * s) * Float64(c_m * Float64(x * Float64(-s))))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = (-1.0 / c_m) / ((x * s) * (c_m * (x * -s)));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(-1.0 / c$95$m), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c$95$m * N[(x * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{-1}{c_m}}{\left(x \cdot s\right) \cdot \left(c_m \cdot \left(x \cdot \left(-s\right)\right)\right)}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 48.5%
associate-/r*48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr61.1%
unpow261.1%
associate-/r*61.5%
unpow261.5%
unpow261.5%
swap-sqr78.6%
unpow278.6%
*-commutative78.6%
Simplified78.6%
add-sqr-sqrt78.5%
sqrt-div78.6%
metadata-eval78.6%
*-commutative78.6%
unpow278.6%
sqrt-prod50.0%
add-sqr-sqrt57.3%
sqrt-div57.3%
metadata-eval57.3%
*-commutative57.3%
unpow257.3%
sqrt-prod39.8%
add-sqr-sqrt78.6%
Applied egg-rr78.6%
pow278.6%
associate-/r*78.6%
Applied egg-rr78.6%
unpow278.6%
associate-/r*78.6%
frac-2neg78.6%
metadata-eval78.6%
frac-times76.1%
neg-mul-176.1%
distribute-neg-frac76.1%
metadata-eval76.1%
distribute-rgt-neg-in76.1%
*-commutative76.1%
distribute-rgt-neg-in76.1%
Applied egg-rr76.1%
Final simplification76.1%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ (/ 1.0 c_m) (* (* x s) (* s (* c_m x)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return (1.0 / c_m) / ((x * s) * (s * (c_m * x)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = (1.0d0 / c_m) / ((x * s) * (s * (c_m * x)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return (1.0 / c_m) / ((x * s) * (s * (c_m * x)));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return (1.0 / c_m) / ((x * s) * (s * (c_m * x)))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(1.0 / c_m) / Float64(Float64(x * s) * Float64(s * Float64(c_m * x)))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = (1.0 / c_m) / ((x * s) * (s * (c_m * x)));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(s * N[(c$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{1}{c_m}}{\left(x \cdot s\right) \cdot \left(s \cdot \left(c_m \cdot x\right)\right)}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 48.5%
associate-/r*48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr61.1%
unpow261.1%
associate-/r*61.5%
unpow261.5%
unpow261.5%
swap-sqr78.6%
unpow278.6%
*-commutative78.6%
Simplified78.6%
add-sqr-sqrt78.5%
sqrt-div78.6%
metadata-eval78.6%
*-commutative78.6%
unpow278.6%
sqrt-prod50.0%
add-sqr-sqrt57.3%
sqrt-div57.3%
metadata-eval57.3%
*-commutative57.3%
unpow257.3%
sqrt-prod39.8%
add-sqr-sqrt78.6%
Applied egg-rr78.6%
pow278.6%
associate-/r*78.6%
Applied egg-rr78.6%
unpow278.6%
associate-/r*78.6%
frac-times76.1%
associate-/r/76.1%
clear-num76.1%
associate-*r*75.0%
*-commutative75.0%
Applied egg-rr75.0%
Final simplification75.0%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* s (* c_m x)))) (/ (/ 1.0 t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = s * (c_m * x);
return (1.0 / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = s * (c_m * x)
code = (1.0d0 / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = s * (c_m * x);
return (1.0 / t_0) / t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = s * (c_m * x) return (1.0 / t_0) / t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(s * Float64(c_m * x)) return Float64(Float64(1.0 / t_0) / t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = s * (c_m * x);
tmp = (1.0 / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(s * N[(c$95$m * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(c_m \cdot x\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 48.5%
associate-/r*48.0%
*-commutative48.0%
unpow248.0%
unpow248.0%
swap-sqr61.1%
unpow261.1%
associate-/r*61.5%
unpow261.5%
unpow261.5%
swap-sqr78.6%
unpow278.6%
*-commutative78.6%
Simplified78.6%
add-sqr-sqrt78.5%
sqrt-div78.6%
metadata-eval78.6%
*-commutative78.6%
unpow278.6%
sqrt-prod50.0%
add-sqr-sqrt57.3%
sqrt-div57.3%
metadata-eval57.3%
*-commutative57.3%
unpow257.3%
sqrt-prod39.8%
add-sqr-sqrt78.6%
Applied egg-rr78.6%
pow278.6%
associate-/r*78.6%
Applied egg-rr78.6%
unpow278.6%
associate-/r*78.6%
un-div-inv78.6%
*-commutative78.6%
associate-/r*77.0%
associate-/r*76.8%
associate-/r*76.8%
*-commutative76.8%
associate-*r*77.5%
associate-*r*79.0%
*-commutative79.0%
Applied egg-rr79.0%
Final simplification79.0%
herbie shell --seed 2024011
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))