
(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)
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))) (t_1 (cos (* x 2.0))))
(if (<= s_m 1.5e+197)
(/ (/ t_1 (* s_m (* c_m (* x s_m)))) (* x c_m))
(/ (/ t_1 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);
double t_1 = cos((x * 2.0));
double tmp;
if (s_m <= 1.5e+197) {
tmp = (t_1 / (s_m * (c_m * (x * s_m)))) / (x * c_m);
} else {
tmp = (t_1 / t_0) / t_0;
}
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) :: t_1
real(8) :: tmp
t_0 = x * (c_m * s_m)
t_1 = cos((x * 2.0d0))
if (s_m <= 1.5d+197) then
tmp = (t_1 / (s_m * (c_m * (x * s_m)))) / (x * c_m)
else
tmp = (t_1 / t_0) / t_0
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 = x * (c_m * s_m);
double t_1 = Math.cos((x * 2.0));
double tmp;
if (s_m <= 1.5e+197) {
tmp = (t_1 / (s_m * (c_m * (x * s_m)))) / (x * c_m);
} else {
tmp = (t_1 / t_0) / t_0;
}
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 = x * (c_m * s_m) t_1 = math.cos((x * 2.0)) tmp = 0 if s_m <= 1.5e+197: tmp = (t_1 / (s_m * (c_m * (x * s_m)))) / (x * c_m) else: tmp = (t_1 / t_0) / t_0 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(x * Float64(c_m * s_m)) t_1 = cos(Float64(x * 2.0)) tmp = 0.0 if (s_m <= 1.5e+197) tmp = Float64(Float64(t_1 / Float64(s_m * Float64(c_m * Float64(x * s_m)))) / Float64(x * c_m)); else tmp = Float64(Float64(t_1 / t_0) / t_0); 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 = x * (c_m * s_m);
t_1 = cos((x * 2.0));
tmp = 0.0;
if (s_m <= 1.5e+197)
tmp = (t_1 / (s_m * (c_m * (x * s_m)))) / (x * c_m);
else
tmp = (t_1 / t_0) / t_0;
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[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s$95$m, 1.5e+197], N[(N[(t$95$1 / N[(s$95$m * N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / 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 := x \cdot \left(c_m \cdot s_m\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;s_m \leq 1.5 \cdot 10^{+197}:\\
\;\;\;\;\frac{\frac{t_1}{s_m \cdot \left(c_m \cdot \left(x \cdot s_m\right)\right)}}{x \cdot c_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\
\end{array}
\end{array}
if s < 1.5000000000000001e197Initial program 67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.3%
times-frac67.3%
Applied egg-rr98.6%
*-un-lft-identity98.6%
associate-*r*96.8%
times-frac96.9%
*-commutative96.9%
Applied egg-rr96.9%
associate-*l/96.9%
*-lft-identity96.9%
Simplified96.9%
associate-*l/96.9%
*-un-lft-identity96.9%
associate-/l/96.9%
associate-*r*98.7%
*-commutative98.7%
associate-*l*96.4%
*-commutative96.4%
*-commutative96.4%
associate-*l*97.1%
*-commutative97.1%
Applied egg-rr97.1%
*-commutative97.1%
associate-*r*96.4%
*-commutative96.4%
associate-*r*96.9%
*-un-lft-identity96.9%
times-frac94.5%
*-commutative94.5%
associate-*r*93.4%
*-commutative93.4%
Applied egg-rr93.4%
associate-*l/93.4%
*-lft-identity93.4%
associate-/l/92.9%
*-commutative92.9%
associate-*r*94.5%
*-commutative94.5%
Simplified94.5%
if 1.5000000000000001e197 < s Initial program 61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
times-frac61.2%
Applied egg-rr99.0%
*-un-lft-identity99.0%
associate-*r*90.0%
times-frac89.9%
*-commutative89.9%
Applied egg-rr89.9%
associate-*l/89.8%
*-lft-identity89.8%
Simplified89.8%
associate-*l/89.7%
*-un-lft-identity89.7%
associate-/l/89.8%
associate-*r*98.8%
*-commutative98.8%
associate-*l*94.3%
*-commutative94.3%
*-commutative94.3%
associate-*l*95.1%
*-commutative95.1%
Applied egg-rr95.1%
Final simplification94.6%
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 (<= s_m 4.5e+197)
(/ (/ (cos (* x 2.0)) (* s_m t_0)) (* x c_m))
(* (/ 1.0 t_0) (/ (/ 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) {
double t_0 = c_m * (x * s_m);
double tmp;
if (s_m <= 4.5e+197) {
tmp = (cos((x * 2.0)) / (s_m * t_0)) / (x * c_m);
} else {
tmp = (1.0 / t_0) * ((1.0 / (x * s_m)) / c_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 (s_m <= 4.5d+197) then
tmp = (cos((x * 2.0d0)) / (s_m * t_0)) / (x * c_m)
else
tmp = (1.0d0 / t_0) * ((1.0d0 / (x * s_m)) / c_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 (s_m <= 4.5e+197) {
tmp = (Math.cos((x * 2.0)) / (s_m * t_0)) / (x * c_m);
} else {
tmp = (1.0 / t_0) * ((1.0 / (x * s_m)) / c_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 s_m <= 4.5e+197: tmp = (math.cos((x * 2.0)) / (s_m * t_0)) / (x * c_m) else: tmp = (1.0 / t_0) * ((1.0 / (x * s_m)) / c_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 (s_m <= 4.5e+197) tmp = Float64(Float64(cos(Float64(x * 2.0)) / Float64(s_m * t_0)) / Float64(x * c_m)); else tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / Float64(x * s_m)) / c_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 (s_m <= 4.5e+197)
tmp = (cos((x * 2.0)) / (s_m * t_0)) / (x * c_m);
else
tmp = (1.0 / t_0) * ((1.0 / (x * s_m)) / c_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[s$95$m, 4.5e+197], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / N[(x * s$95$m), $MachinePrecision]), $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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s_m\right)\\
\mathbf{if}\;s_m \leq 4.5 \cdot 10^{+197}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s_m \cdot t_0}}{x \cdot c_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\frac{1}{x \cdot s_m}}{c_m}\\
\end{array}
\end{array}
if s < 4.5000000000000003e197Initial program 67.3%
*-un-lft-identity67.3%
add-sqr-sqrt67.3%
times-frac67.3%
Applied egg-rr98.6%
*-un-lft-identity98.6%
associate-*r*96.8%
times-frac96.9%
*-commutative96.9%
Applied egg-rr96.9%
associate-*l/96.9%
*-lft-identity96.9%
Simplified96.9%
associate-*l/96.9%
*-un-lft-identity96.9%
associate-/l/96.9%
associate-*r*98.7%
*-commutative98.7%
associate-*l*96.4%
*-commutative96.4%
*-commutative96.4%
associate-*l*97.1%
*-commutative97.1%
Applied egg-rr97.1%
*-commutative97.1%
associate-*r*96.4%
*-commutative96.4%
associate-*r*96.9%
*-un-lft-identity96.9%
times-frac94.5%
*-commutative94.5%
associate-*r*93.4%
*-commutative93.4%
Applied egg-rr93.4%
associate-*l/93.4%
*-lft-identity93.4%
associate-/l/92.9%
*-commutative92.9%
associate-*r*94.5%
*-commutative94.5%
Simplified94.5%
if 4.5000000000000003e197 < s Initial program 61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
times-frac61.2%
Applied egg-rr99.0%
Taylor expanded in x around 0 95.3%
associate-/r*95.1%
*-commutative95.1%
*-rgt-identity95.1%
associate-*r/95.3%
associate-*l/95.4%
*-lft-identity95.4%
*-commutative95.4%
Simplified95.4%
Final simplification94.6%
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) (/ (cos (* x 2.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) * (cos((x * 2.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) * (cos((x * 2.0d0)) / 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) * (Math.cos((x * 2.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) * (math.cos((x * 2.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) * Float64(cos(Float64(x * 2.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) * (cos((x * 2.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] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / 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 \frac{\cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Initial program 66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.8%
Applied egg-rr98.7%
Final simplification98.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 (/ (/ (cos (* x 2.0)) c_m) (* (* x 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)) / c_m) / ((x * 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)) / c_m) / ((x * 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)) / c_m) / ((x * 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)) / c_m) / ((x * 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)) / c_m) / Float64(Float64(x * 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)) / c_m) / ((x * 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] / c$95$m), $MachinePrecision] / N[(N[(x * s$95$m), $MachinePrecision] * N[(c$95$m * N[(x * 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(c_m \cdot \left(x \cdot s_m\right)\right)}
\end{array}
Initial program 66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.8%
Applied egg-rr98.7%
*-commutative98.7%
associate-/r*98.8%
frac-times94.8%
div-inv94.8%
*-commutative94.8%
Applied egg-rr94.8%
Final simplification94.8%
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(cos(Float64(x * 2.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 = (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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / 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 := \left(x \cdot c_m\right) \cdot s_m\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.8%
Applied egg-rr98.7%
*-commutative98.7%
frac-2neg98.7%
frac-2neg98.7%
metadata-eval98.7%
frac-times98.2%
*-commutative98.2%
associate-*r*96.1%
distribute-rgt-neg-in96.1%
associate-*r*96.8%
distribute-rgt-neg-in96.8%
Applied egg-rr96.8%
Final simplification96.8%
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) (* 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 / (c_m * (x * s_m))) * ((1.0 / 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 / (c_m * (x * s_m))) * ((1.0d0 / 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 / (c_m * (x * s_m))) * ((1.0 / 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 / (c_m * (x * s_m))) * ((1.0 / 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(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(1.0 / 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 / (c_m * (x * s_m))) * ((1.0 / 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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$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])\\
\\
\frac{1}{c_m \cdot \left(x \cdot s_m\right)} \cdot \frac{\frac{1}{c_m}}{x \cdot s_m}
\end{array}
Initial program 66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.8%
Applied egg-rr98.7%
Taylor expanded in x around 0 82.0%
associate-*r*80.9%
Simplified80.9%
associate-/r*80.9%
div-inv80.8%
Applied egg-rr80.8%
un-div-inv80.9%
associate-/r*80.9%
associate-/l/82.1%
Applied egg-rr82.1%
Final simplification82.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 (* (/ 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(1.0 / Float64(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[(1.0 / N[(x * s$95$m), $MachinePrecision]), $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{1}{x \cdot s_m}}{c_m}
\end{array}
Initial program 66.8%
*-un-lft-identity66.8%
add-sqr-sqrt66.8%
times-frac66.8%
Applied egg-rr98.7%
Taylor expanded in x around 0 82.0%
associate-/r*82.1%
*-commutative82.1%
*-rgt-identity82.1%
associate-*r/81.7%
associate-*l/81.8%
*-lft-identity81.8%
*-commutative81.8%
Simplified81.8%
Final simplification81.8%
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 s_m) (* x (* 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 / ((c_m * s_m) * (x * (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 / ((c_m * s_m) * (x * (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 / ((c_m * s_m) * (x * (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 / ((c_m * s_m) * (x * (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(c_m * s_m) * Float64(x * 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 / ((c_m * s_m) * (x * (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[(c$95$m * s$95$m), $MachinePrecision] * N[(x * 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(c_m \cdot s_m\right) \cdot \left(x \cdot \left(c_m \cdot \left(x \cdot s_m\right)\right)\right)}
\end{array}
Initial program 66.8%
Taylor expanded in x around 0 56.8%
associate-/r*56.8%
*-commutative56.8%
unpow256.8%
unpow256.8%
swap-sqr67.1%
unpow267.1%
associate-/r*67.1%
unpow267.1%
unpow267.1%
swap-sqr82.0%
unpow282.0%
*-commutative82.0%
Simplified82.0%
unpow282.0%
associate-*r*80.9%
*-commutative80.9%
associate-*l*79.3%
Applied egg-rr79.3%
Final simplification79.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 s_m) (* x (* 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 1.0 / ((c_m * s_m) * (x * (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 = 1.0d0 / ((c_m * s_m) * (x * (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 1.0 / ((c_m * s_m) * (x * (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 1.0 / ((c_m * s_m) * (x * (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(1.0 / Float64(Float64(c_m * s_m) * Float64(x * 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 = 1.0 / ((c_m * s_m) * (x * (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[(1.0 / N[(N[(c$95$m * s$95$m), $MachinePrecision] * N[(x * N[(x * N[(c$95$m * 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(c_m \cdot s_m\right) \cdot \left(x \cdot \left(x \cdot \left(c_m \cdot s_m\right)\right)\right)}
\end{array}
Initial program 66.8%
Taylor expanded in x around 0 56.8%
associate-/r*56.8%
*-commutative56.8%
unpow256.8%
unpow256.8%
swap-sqr67.1%
unpow267.1%
associate-/r*67.1%
unpow267.1%
unpow267.1%
swap-sqr82.0%
unpow282.0%
*-commutative82.0%
Simplified82.0%
unpow282.0%
associate-*r*80.9%
*-commutative80.9%
associate-*l*79.3%
Applied egg-rr79.3%
Taylor expanded in c around 0 79.3%
associate-*r*79.4%
Simplified79.4%
Final simplification79.4%
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.8%
Taylor expanded in x around 0 56.8%
associate-/r*56.8%
*-commutative56.8%
unpow256.8%
unpow256.8%
swap-sqr67.1%
unpow267.1%
associate-/r*67.1%
unpow267.1%
unpow267.1%
swap-sqr82.0%
unpow282.0%
*-commutative82.0%
Simplified82.0%
*-commutative82.0%
*-commutative82.0%
*-commutative82.0%
unpow282.0%
Applied egg-rr82.0%
Final simplification82.0%
herbie shell --seed 2023322
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))