
(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 7 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}
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ (/ (/ (/ 1.0 s_m) x) c) (/ (* c (* s_m x)) (cos (* x 2.0)))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return (((1.0 / s_m) / x) / c) / ((c * (s_m * x)) / cos((x * 2.0)));
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (((1.0d0 / s_m) / x) / c) / ((c * (s_m * x)) / cos((x * 2.0d0)))
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return (((1.0 / s_m) / x) / c) / ((c * (s_m * x)) / Math.cos((x * 2.0)));
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return (((1.0 / s_m) / x) / c) / ((c * (s_m * x)) / math.cos((x * 2.0)))
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(Float64(Float64(Float64(1.0 / s_m) / x) / c) / Float64(Float64(c * Float64(s_m * x)) / cos(Float64(x * 2.0)))) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = (((1.0 / s_m) / x) / c) / ((c * (s_m * x)) / cos((x * 2.0)));
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision] / N[(N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{\frac{\frac{\frac{1}{s\_m}}{x}}{c}}{\frac{c \cdot \left(s\_m \cdot x\right)}{\cos \left(x \cdot 2\right)}}
\end{array}
Initial program 70.6%
*-un-lft-identity70.6%
add-sqr-sqrt70.6%
times-frac70.6%
sqrt-prod70.6%
sqrt-pow150.0%
metadata-eval50.0%
pow150.0%
*-commutative50.0%
associate-*r*46.2%
unpow246.2%
pow-prod-down50.0%
sqrt-prod50.0%
Applied egg-rr88.8%
associate-*l/88.8%
*-lft-identity88.8%
unpow288.8%
rem-sqrt-square88.8%
unpow288.8%
rem-sqrt-square97.1%
Simplified97.1%
div-inv97.1%
*-commutative97.1%
add-sqr-sqrt53.5%
fabs-sqr53.5%
add-sqr-sqrt64.7%
add-sqr-sqrt47.5%
fabs-sqr47.5%
add-sqr-sqrt97.1%
Applied egg-rr97.1%
clear-num97.1%
associate-*l/97.1%
*-un-lft-identity97.1%
*-commutative97.1%
associate-/r*97.1%
associate-/r*97.2%
Applied egg-rr97.2%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* c (* s_m x)))) (* (/ (cos (* x 2.0)) t_0) (/ 1.0 t_0))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return (cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (s_m * x)
code = (cos((x * 2.0d0)) / t_0) * (1.0d0 / t_0)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return (Math.cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = c * (s_m * x) return (math.cos((x * 2.0)) / t_0) * (1.0 / t_0)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(c * Float64(s_m * x)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.0 / t_0)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = c * (s_m * x);
tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0);
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s\_m \cdot x\right)\\
\frac{\cos \left(x \cdot 2\right)}{t\_0} \cdot \frac{1}{t\_0}
\end{array}
\end{array}
Initial program 70.6%
*-un-lft-identity70.6%
add-sqr-sqrt70.6%
times-frac70.6%
sqrt-prod70.6%
sqrt-pow150.0%
metadata-eval50.0%
pow150.0%
*-commutative50.0%
associate-*r*46.2%
unpow246.2%
pow-prod-down50.0%
sqrt-prod50.0%
Applied egg-rr88.8%
associate-*l/88.8%
*-lft-identity88.8%
unpow288.8%
rem-sqrt-square88.8%
unpow288.8%
rem-sqrt-square97.1%
Simplified97.1%
div-inv97.1%
*-commutative97.1%
add-sqr-sqrt53.5%
fabs-sqr53.5%
add-sqr-sqrt64.7%
add-sqr-sqrt47.5%
fabs-sqr47.5%
add-sqr-sqrt97.1%
Applied egg-rr97.1%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* c (* s_m x)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return (cos((x * 2.0)) / t_0) / t_0;
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (s_m * x)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = c * (s_m * x) return (math.cos((x * 2.0)) / t_0) / t_0
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(c * Float64(s_m * x)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = c * (s_m * x);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s\_m \cdot x\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 70.6%
*-un-lft-identity70.6%
add-sqr-sqrt70.6%
times-frac70.6%
sqrt-prod70.6%
sqrt-pow150.0%
metadata-eval50.0%
pow150.0%
*-commutative50.0%
associate-*r*46.2%
unpow246.2%
pow-prod-down50.0%
sqrt-prod50.0%
Applied egg-rr88.8%
associate-*l/88.8%
*-lft-identity88.8%
unpow288.8%
rem-sqrt-square88.8%
unpow288.8%
rem-sqrt-square97.1%
Simplified97.1%
div-inv97.1%
*-commutative97.1%
add-sqr-sqrt53.5%
fabs-sqr53.5%
add-sqr-sqrt64.7%
add-sqr-sqrt47.5%
fabs-sqr47.5%
add-sqr-sqrt97.1%
Applied egg-rr97.1%
un-div-inv97.1%
Applied egg-rr97.1%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* x (* s_m c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = x * (s_m * c);
return cos((x * 2.0)) / (t_0 * t_0);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = x * (s_m * c)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = x * (s_m * c);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = x * (s_m * c) return math.cos((x * 2.0)) / (t_0 * t_0)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(x * Float64(s_m * c)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = x * (s_m * c);
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(x * N[(s$95$m * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(s\_m \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.6%
Applied egg-rr80.1%
associate-*r/80.5%
unpow280.5%
*-rgt-identity80.5%
add-sqr-sqrt69.0%
pow269.0%
sqrt-prod59.6%
sqrt-pow159.6%
metadata-eval59.6%
inv-pow59.6%
div-inv59.6%
pow259.6%
frac-times72.2%
associate-/l/72.2%
Applied egg-rr97.2%
Final simplification97.2%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ (/ (/ (/ 1.0 s_m) x) c) (* c (* s_m x))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return (((1.0 / s_m) / x) / c) / (c * (s_m * x));
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (((1.0d0 / s_m) / x) / c) / (c * (s_m * x))
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return (((1.0 / s_m) / x) / c) / (c * (s_m * x));
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return (((1.0 / s_m) / x) / c) / (c * (s_m * x))
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(Float64(Float64(Float64(1.0 / s_m) / x) / c) / Float64(c * Float64(s_m * x))) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = (((1.0 / s_m) / x) / c) / (c * (s_m * x));
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{\frac{\frac{\frac{1}{s\_m}}{x}}{c}}{c \cdot \left(s\_m \cdot x\right)}
\end{array}
Initial program 70.6%
*-un-lft-identity70.6%
add-sqr-sqrt70.6%
times-frac70.6%
sqrt-prod70.6%
sqrt-pow150.0%
metadata-eval50.0%
pow150.0%
*-commutative50.0%
associate-*r*46.2%
unpow246.2%
pow-prod-down50.0%
sqrt-prod50.0%
Applied egg-rr88.8%
associate-*l/88.8%
*-lft-identity88.8%
unpow288.8%
rem-sqrt-square88.8%
unpow288.8%
rem-sqrt-square97.1%
Simplified97.1%
div-inv97.1%
*-commutative97.1%
add-sqr-sqrt53.5%
fabs-sqr53.5%
add-sqr-sqrt64.7%
add-sqr-sqrt47.5%
fabs-sqr47.5%
add-sqr-sqrt97.1%
Applied egg-rr97.1%
clear-num97.1%
associate-*l/97.1%
*-un-lft-identity97.1%
*-commutative97.1%
associate-/r*97.1%
associate-/r*97.2%
Applied egg-rr97.2%
Taylor expanded in x around 0 79.3%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* c (* s_m x)))) (/ 1.0 (* t_0 t_0))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return 1.0 / (t_0 * t_0);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (s_m * x)
code = 1.0d0 / (t_0 * t_0)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = c * (s_m * x);
return 1.0 / (t_0 * t_0);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = c * (s_m * x) return 1.0 / (t_0 * t_0)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(c * Float64(s_m * x)) return Float64(1.0 / Float64(t_0 * t_0)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = c * (s_m * x);
tmp = 1.0 / (t_0 * t_0);
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s\_m \cdot x\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0 59.5%
associate-/r*59.5%
unpow259.5%
unpow259.5%
swap-sqr69.8%
unpow269.8%
associate-/r*70.0%
unpow270.0%
rem-square-sqrt70.0%
swap-sqr76.0%
unpow276.0%
unpow276.0%
rem-sqrt-square79.2%
Simplified79.2%
add-sqr-sqrt50.7%
sqrt-prod79.2%
unpow279.2%
pow279.2%
unpow279.2%
sqrt-prod50.7%
add-sqr-sqrt56.8%
add-sqr-sqrt30.9%
fabs-sqr30.9%
add-sqr-sqrt60.1%
unpow260.1%
sqrt-prod37.4%
add-sqr-sqrt58.7%
add-sqr-sqrt39.4%
fabs-sqr39.4%
add-sqr-sqrt79.2%
Applied egg-rr79.2%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ 1.0 (* (* s_m c) (* x (* c (* s_m x))))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return 1.0 / ((s_m * c) * (x * (c * (s_m * x))));
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = 1.0d0 / ((s_m * c) * (x * (c * (s_m * x))))
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return 1.0 / ((s_m * c) * (x * (c * (s_m * x))));
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return 1.0 / ((s_m * c) * (x * (c * (s_m * x))))
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(1.0 / Float64(Float64(s_m * c) * Float64(x * Float64(c * Float64(s_m * x))))) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = 1.0 / ((s_m * c) * (x * (c * (s_m * x))));
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(1.0 / N[(N[(s$95$m * c), $MachinePrecision] * N[(x * N[(c * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{1}{\left(s\_m \cdot c\right) \cdot \left(x \cdot \left(c \cdot \left(s\_m \cdot x\right)\right)\right)}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0 59.5%
associate-/r*59.5%
unpow259.5%
unpow259.5%
swap-sqr69.8%
unpow269.8%
associate-/r*70.0%
unpow270.0%
rem-square-sqrt70.0%
swap-sqr76.0%
unpow276.0%
unpow276.0%
rem-sqrt-square79.2%
Simplified79.2%
add-sqr-sqrt50.7%
sqrt-prod79.2%
unpow279.2%
pow279.2%
add-sqr-sqrt79.2%
/-rgt-identity79.2%
clear-num79.2%
pow-flip79.2%
add-sqr-sqrt45.3%
fabs-sqr45.3%
add-sqr-sqrt79.2%
metadata-eval79.2%
Applied egg-rr79.2%
pow-flip79.2%
metadata-eval79.2%
pow279.2%
associate-*r*78.8%
associate-*l*78.0%
Applied egg-rr78.0%
Final simplification78.0%
herbie shell --seed 2024116
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))