
(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 9 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 (* (/ 1.0 (* c_m (* x s_m))) (* (/ (cos (* x 2.0)) c_m) (/ 1.0 (* 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))) * ((cos((x * 2.0)) / c_m) * (1.0 / (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))) * ((cos((x * 2.0d0)) / c_m) * (1.0d0 / (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))) * ((Math.cos((x * 2.0)) / c_m) * (1.0 / (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))) * ((math.cos((x * 2.0)) / c_m) * (1.0 / (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(cos(Float64(x * 2.0)) / c_m) * Float64(1.0 / 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))) * ((cos((x * 2.0)) / c_m) * (1.0 / (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[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] * N[(1.0 / 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{1}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \left(\frac{\cos \left(x \cdot 2\right)}{c\_m} \cdot \frac{1}{x \cdot s\_m}\right)
\end{array}
Initial program 70.4%
*-un-lft-identity70.4%
add-sqr-sqrt70.3%
times-frac70.3%
Applied egg-rr97.5%
associate-/r*97.6%
div-inv97.5%
*-commutative97.5%
Applied egg-rr97.5%
Final simplification97.5%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x s_m))))
(if (<= x 2.8e-7)
(* (/ 1.0 t_0) (/ (/ 1.0 c_m) (* x s_m)))
(/ (/ (cos (* x 2.0)) (* c_m t_0)) (* x s_m)))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 2.8e-7) {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
} else {
tmp = (cos((x * 2.0)) / (c_m * t_0)) / (x * s_m);
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s_m)
if (x <= 2.8d-7) then
tmp = (1.0d0 / t_0) * ((1.0d0 / c_m) / (x * s_m))
else
tmp = (cos((x * 2.0d0)) / (c_m * t_0)) / (x * s_m)
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 2.8e-7) {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
} else {
tmp = (Math.cos((x * 2.0)) / (c_m * t_0)) / (x * s_m);
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) tmp = 0 if x <= 2.8e-7: tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m)) else: tmp = (math.cos((x * 2.0)) / (c_m * t_0)) / (x * s_m) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) tmp = 0.0 if (x <= 2.8e-7) tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / c_m) / Float64(x * s_m))); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / Float64(c_m * t_0)) / Float64(x * s_m)); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = 0.0;
if (x <= 2.8e-7)
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
else
tmp = (cos((x * 2.0)) / (c_m * t_0)) / (x * s_m);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.8e-7], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(c$95$m * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * s$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}\;x \leq 2.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{\frac{1}{c\_m}}{x \cdot s\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m \cdot t\_0}}{x \cdot s\_m}\\
\end{array}
\end{array}
if x < 2.80000000000000019e-7Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
Applied egg-rr97.7%
Taylor expanded in x around 0 84.6%
associate-/r*84.6%
Simplified84.6%
if 2.80000000000000019e-7 < x Initial program 67.7%
Applied egg-rr84.4%
associate-*r/84.5%
Simplified84.5%
associate-/l*84.4%
sqr-pow84.4%
associate-/l*88.6%
metadata-eval88.6%
inv-pow88.6%
associate-/r*88.7%
*-commutative88.7%
associate-*l*88.7%
metadata-eval88.7%
inv-pow88.7%
div-inv88.7%
*-commutative88.7%
frac-times87.5%
associate-*l*82.4%
pow282.4%
unpow-prod-down97.8%
Applied egg-rr97.0%
associate-*l/94.4%
associate-/l/94.5%
*-commutative94.5%
frac-times94.0%
*-un-lft-identity94.0%
Applied egg-rr94.0%
Final simplification86.9%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x s_m))))
(if (<= x 3.2e-7)
(* (/ 1.0 t_0) (/ (/ 1.0 c_m) (* x s_m)))
(/ (/ (/ (cos (* x 2.0)) t_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) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 3.2e-7) {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
} else {
tmp = ((cos((x * 2.0)) / t_0) / (c_m * x)) / s_m;
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s_m)
if (x <= 3.2d-7) then
tmp = (1.0d0 / t_0) * ((1.0d0 / c_m) / (x * s_m))
else
tmp = ((cos((x * 2.0d0)) / t_0) / (c_m * x)) / s_m
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = c_m * (x * s_m);
double tmp;
if (x <= 3.2e-7) {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
} else {
tmp = ((Math.cos((x * 2.0)) / t_0) / (c_m * x)) / s_m;
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = c_m * (x * s_m) tmp = 0 if x <= 3.2e-7: tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m)) else: tmp = ((math.cos((x * 2.0)) / t_0) / (c_m * x)) / s_m return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(c_m * Float64(x * s_m)) tmp = 0.0 if (x <= 3.2e-7) tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / c_m) / Float64(x * s_m))); else tmp = Float64(Float64(Float64(cos(Float64(x * 2.0)) / t_0) / Float64(c_m * x)) / s_m); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = c_m * (x * s_m);
tmp = 0.0;
if (x <= 3.2e-7)
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s_m));
else
tmp = ((cos((x * 2.0)) / t_0) / (c_m * x)) / s_m;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.2e-7], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / N[(c$95$m * x), $MachinePrecision]), $MachinePrecision] / s$95$m), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\mathbf{if}\;x \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{\frac{1}{c\_m}}{x \cdot s\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{c\_m \cdot x}}{s\_m}\\
\end{array}
\end{array}
if x < 3.2000000000000001e-7Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
Applied egg-rr97.7%
Taylor expanded in x around 0 84.6%
associate-/r*84.6%
Simplified84.6%
if 3.2000000000000001e-7 < x Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.6%
times-frac67.6%
Applied egg-rr97.0%
associate-*l/97.1%
*-un-lft-identity97.1%
associate-*r*95.6%
associate-/r*92.5%
*-commutative92.5%
Applied egg-rr92.5%
Final simplification86.5%
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 (* x 2.0)) (* c_m (* x s_m))))) (if (<= x 2.3e-7) (/ (/ t_0 (* x s_m)) c_m) (/ (/ t_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) {
double t_0 = cos((x * 2.0)) / (c_m * (x * s_m));
double tmp;
if (x <= 2.3e-7) {
tmp = (t_0 / (x * s_m)) / c_m;
} else {
tmp = (t_0 / (c_m * x)) / s_m;
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = cos((x * 2.0d0)) / (c_m * (x * s_m))
if (x <= 2.3d-7) then
tmp = (t_0 / (x * s_m)) / c_m
else
tmp = (t_0 / (c_m * x)) / s_m
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = Math.cos((x * 2.0)) / (c_m * (x * s_m));
double tmp;
if (x <= 2.3e-7) {
tmp = (t_0 / (x * s_m)) / c_m;
} else {
tmp = (t_0 / (c_m * x)) / s_m;
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = math.cos((x * 2.0)) / (c_m * (x * s_m)) tmp = 0 if x <= 2.3e-7: tmp = (t_0 / (x * s_m)) / c_m else: tmp = (t_0 / (c_m * x)) / s_m return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(cos(Float64(x * 2.0)) / Float64(c_m * Float64(x * s_m))) tmp = 0.0 if (x <= 2.3e-7) tmp = Float64(Float64(t_0 / Float64(x * s_m)) / c_m); else tmp = Float64(Float64(t_0 / Float64(c_m * x)) / s_m); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = cos((x * 2.0)) / (c_m * (x * s_m));
tmp = 0.0;
if (x <= 2.3e-7)
tmp = (t_0 / (x * s_m)) / c_m;
else
tmp = (t_0 / (c_m * x)) / s_m;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e-7], N[(N[(t$95$0 / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(t$95$0 / N[(c$95$m * x), $MachinePrecision]), $MachinePrecision] / s$95$m), $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 := \frac{\cos \left(x \cdot 2\right)}{c\_m \cdot \left(x \cdot s\_m\right)}\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{t\_0}{x \cdot s\_m}}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{c\_m \cdot x}}{s\_m}\\
\end{array}
\end{array}
if x < 2.29999999999999995e-7Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
Applied egg-rr97.7%
associate-*l/97.7%
*-un-lft-identity97.7%
*-commutative97.7%
associate-/r*94.8%
*-commutative94.8%
Applied egg-rr94.8%
if 2.29999999999999995e-7 < x Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.6%
times-frac67.6%
Applied egg-rr97.0%
associate-*l/97.1%
*-un-lft-identity97.1%
associate-*r*95.6%
associate-/r*92.5%
*-commutative92.5%
Applied egg-rr92.5%
Final simplification94.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)))) (* (/ 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 70.4%
*-un-lft-identity70.4%
add-sqr-sqrt70.3%
times-frac70.3%
Applied egg-rr97.5%
Final simplification97.5%
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 70.4%
*-un-lft-identity70.4%
add-sqr-sqrt70.3%
times-frac70.3%
Applied egg-rr97.5%
Taylor expanded in x around 0 80.6%
associate-/r*80.7%
Simplified80.7%
Final simplification80.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 (/ 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 70.4%
Taylor expanded in x around 0 58.2%
associate-/r*58.2%
*-commutative58.2%
unpow258.2%
unpow258.2%
swap-sqr69.3%
unpow269.3%
associate-/r*69.3%
unpow269.3%
unpow269.3%
swap-sqr80.5%
unpow280.5%
*-commutative80.5%
Simplified80.5%
unpow280.5%
associate-*r*79.1%
*-commutative79.1%
associate-*l*78.0%
Applied egg-rr78.0%
Final simplification78.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(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 70.4%
Taylor expanded in x around 0 58.2%
associate-/r*58.2%
*-commutative58.2%
unpow258.2%
unpow258.2%
swap-sqr69.3%
unpow269.3%
associate-/r*69.3%
unpow269.3%
unpow269.3%
swap-sqr80.5%
unpow280.5%
*-commutative80.5%
Simplified80.5%
*-commutative80.5%
*-commutative80.5%
*-commutative80.5%
unpow280.5%
Applied egg-rr80.5%
Final simplification80.5%
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 70.4%
Taylor expanded in x around 0 58.2%
associate-/r*58.2%
*-commutative58.2%
unpow258.2%
unpow258.2%
swap-sqr69.3%
unpow269.3%
associate-/r*69.3%
unpow269.3%
unpow269.3%
swap-sqr80.5%
unpow280.5%
*-commutative80.5%
Simplified80.5%
unpow280.5%
associate-*r*79.1%
*-commutative79.1%
associate-*l*78.0%
Applied egg-rr78.0%
associate-/r*78.0%
div-inv77.8%
associate-*r*76.8%
Applied egg-rr76.8%
frac-times77.0%
associate-*l*78.0%
associate-*r*79.1%
associate-*r*80.5%
*-commutative80.5%
frac-times80.6%
*-commutative80.6%
associate-/l/80.7%
un-div-inv80.7%
associate-/l/80.6%
*-commutative80.6%
Applied egg-rr80.6%
Final simplification80.6%
herbie shell --seed 2024071
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))