
(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}
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (cos((x * 2.0)) / t_0) / t_0;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = x * (c * s)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (c * s) return (math.cos((x * 2.0)) / t_0) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = (cos((x * 2.0)) / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Applied egg-rr96.9%
associate-*l/96.9%
*-commutative96.9%
unpow296.9%
frac-times97.2%
associate-*l/97.2%
div-inv97.3%
*-commutative97.3%
*-commutative97.3%
associate-*l*96.0%
*-commutative96.0%
*-commutative96.0%
associate-*l*98.3%
*-commutative98.3%
Applied egg-rr98.3%
(FPCore (x c s) :precision binary64 (if (<= x 1.3e-8) (pow (* c (* x s)) -2.0) (/ (/ (cos (* x 2.0)) x) (* (* c s) (* s (* x c))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 1.3e-8) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = (cos((x * 2.0)) / x) / ((c * s) * (s * (x * c)));
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 1.3d-8) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = (cos((x * 2.0d0)) / x) / ((c * s) * (s * (x * c)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 1.3e-8) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = (Math.cos((x * 2.0)) / x) / ((c * s) * (s * (x * c)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 1.3e-8: tmp = math.pow((c * (x * s)), -2.0) else: tmp = (math.cos((x * 2.0)) / x) / ((c * s) * (s * (x * c))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 1.3e-8) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(x * 2.0)) / x) / Float64(Float64(c * s) * Float64(s * Float64(x * c)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 1.3e-8) tmp = (c * (x * s)) ^ -2.0; else tmp = (cos((x * 2.0)) / x) / ((c * s) * (s * (x * c))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 1.3e-8], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / N[(N[(c * s), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(c \cdot s\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 1.3000000000000001e-8Initial program 61.5%
associate-/r*60.8%
cos-neg60.8%
distribute-rgt-neg-out60.8%
distribute-rgt-neg-out60.8%
*-commutative60.8%
distribute-rgt-neg-in60.8%
metadata-eval60.8%
*-commutative60.8%
associate-*l*57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in x around 0 52.5%
associate-/r*52.1%
*-commutative52.1%
unpow252.1%
unpow252.1%
swap-sqr66.0%
unpow266.0%
associate-/r*66.4%
unpow266.4%
unpow266.4%
swap-sqr82.4%
unpow282.4%
Simplified82.4%
Taylor expanded in c around 0 52.5%
associate-*r*54.1%
unpow254.1%
unpow254.1%
swap-sqr68.7%
unpow268.7%
swap-sqr82.8%
*-commutative82.8%
*-commutative82.8%
associate-/l/82.8%
*-lft-identity82.8%
associate-*l/82.7%
unpow-182.7%
unpow-182.7%
pow-sqr82.8%
metadata-eval82.8%
*-commutative82.8%
associate-*r*82.7%
Simplified82.7%
if 1.3000000000000001e-8 < x Initial program 62.2%
associate-/r*61.1%
cos-neg61.1%
distribute-rgt-neg-out61.1%
distribute-rgt-neg-out61.1%
*-commutative61.1%
distribute-rgt-neg-in61.1%
metadata-eval61.1%
*-commutative61.1%
associate-*l*54.6%
unpow254.6%
Simplified54.6%
Applied egg-rr97.6%
unpow297.6%
associate-*r*90.4%
associate-*r*90.3%
*-commutative90.3%
associate-*l*91.8%
*-commutative91.8%
Applied egg-rr91.8%
*-commutative91.8%
associate-*l/91.8%
*-un-lft-identity91.8%
associate-*l*91.8%
*-commutative91.8%
associate-*r*99.0%
associate-/l/99.6%
associate-/r*99.6%
associate-/l/90.6%
*-commutative90.6%
*-commutative90.6%
associate-*l*83.3%
*-commutative83.3%
Applied egg-rr83.3%
Final simplification82.8%
(FPCore (x c s) :precision binary64 (/ (/ (cos (* x 2.0)) c) (* (* x (* c s)) (* x s))))
double code(double x, double c, double s) {
return (cos((x * 2.0)) / c) / ((x * (c * s)) * (x * s));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (cos((x * 2.0d0)) / c) / ((x * (c * s)) * (x * s))
end function
public static double code(double x, double c, double s) {
return (Math.cos((x * 2.0)) / c) / ((x * (c * s)) * (x * s));
}
def code(x, c, s): return (math.cos((x * 2.0)) / c) / ((x * (c * s)) * (x * s))
function code(x, c, s) return Float64(Float64(cos(Float64(x * 2.0)) / c) / Float64(Float64(x * Float64(c * s)) * Float64(x * s))) end
function tmp = code(x, c, s) tmp = (cos((x * 2.0)) / c) / ((x * (c * s)) * (x * s)); end
code[x_, c_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c), $MachinePrecision] / N[(N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot s\right)}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Applied egg-rr96.9%
associate-*l/96.9%
unpow296.9%
*-un-lft-identity96.9%
associate-/r*97.3%
associate-/r*97.3%
associate-/l/92.6%
*-commutative92.6%
*-commutative92.6%
associate-*l*91.3%
*-commutative91.3%
Applied egg-rr91.3%
(FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (c * (x * s)) ** (-2.0d0)
end function
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
def code(x, c, s): return math.pow((c * (x * s)), -2.0)
function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
function tmp = code(x, c, s) tmp = (c * (x * s)) ^ -2.0; end
code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
Simplified76.5%
Taylor expanded in c around 0 51.3%
associate-*r*52.6%
unpow252.6%
unpow252.6%
swap-sqr65.3%
unpow265.3%
swap-sqr76.8%
*-commutative76.8%
*-commutative76.8%
associate-/l/76.8%
*-lft-identity76.8%
associate-*l/76.8%
unpow-176.8%
unpow-176.8%
pow-sqr76.8%
metadata-eval76.8%
*-commutative76.8%
associate-*r*76.7%
Simplified76.7%
Final simplification76.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (/ 1.0 (* c (* x s))))) (* t_0 t_0)))
double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (x * s));
return t_0 * t_0;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = 1.0d0 / (c * (x * s))
code = t_0 * t_0
end function
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (x * s));
return t_0 * t_0;
}
def code(x, c, s): t_0 = 1.0 / (c * (x * s)) return t_0 * t_0
function code(x, c, s) t_0 = Float64(1.0 / Float64(c * Float64(x * s))) return Float64(t_0 * t_0) end
function tmp = code(x, c, s) t_0 = 1.0 / (c * (x * s)); tmp = t_0 * t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Applied egg-rr97.2%
Taylor expanded in x around 0 76.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ (/ 1.0 t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (1.0 / t_0) / t_0;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = x * (c * s)
code = (1.0d0 / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (1.0 / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (c * s) return (1.0 / t_0) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(Float64(1.0 / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = (1.0 / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Applied egg-rr96.9%
associate-*l/96.9%
*-commutative96.9%
unpow296.9%
frac-times97.2%
associate-*l/97.2%
div-inv97.3%
*-commutative97.3%
*-commutative97.3%
associate-*l*96.0%
*-commutative96.0%
*-commutative96.0%
associate-*l*98.3%
*-commutative98.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 75.9%
associate-*r*76.8%
remove-double-neg76.8%
distribute-lft-neg-in76.8%
*-commutative76.8%
distribute-rgt-neg-out76.8%
remove-double-neg76.8%
Simplified76.8%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = x * (c * s)
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = x * (c * s) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
Simplified76.5%
unpow276.5%
*-commutative76.5%
*-commutative76.5%
associate-*l*75.9%
*-commutative75.9%
associate-*l*76.8%
*-commutative76.8%
Applied egg-rr76.8%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* x c) (* s (* x (* c s))))))
double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (x * (c * s))));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((x * c) * (s * (x * (c * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (x * (c * s))));
}
def code(x, c, s): return 1.0 / ((x * c) * (s * (x * (c * s))))
function code(x, c, s) return Float64(1.0 / Float64(Float64(x * c) * Float64(s * Float64(x * Float64(c * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / ((x * c) * (s * (x * (c * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
Simplified76.5%
unpow276.5%
associate-*r*74.9%
associate-*l*72.8%
*-commutative72.8%
associate-*l*73.4%
*-commutative73.4%
Applied egg-rr73.4%
Final simplification73.4%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* x c) (* s (* c (* x s))))))
double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (c * (x * s))));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((x * c) * (s * (c * (x * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (c * (x * s))));
}
def code(x, c, s): return 1.0 / ((x * c) * (s * (c * (x * s))))
function code(x, c, s) return Float64(1.0 / Float64(Float64(x * c) * Float64(s * Float64(c * Float64(x * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / ((x * c) * (s * (c * (x * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 61.7%
associate-/r*60.9%
cos-neg60.9%
distribute-rgt-neg-out60.9%
distribute-rgt-neg-out60.9%
*-commutative60.9%
distribute-rgt-neg-in60.9%
metadata-eval60.9%
*-commutative60.9%
associate-*l*56.5%
unpow256.5%
Simplified56.5%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
Simplified76.5%
unpow276.5%
associate-*r*74.9%
associate-*l*72.8%
*-commutative72.8%
associate-*l*73.4%
*-commutative73.4%
Applied egg-rr73.4%
Taylor expanded in x around 0 72.8%
Final simplification72.8%
herbie shell --seed 2024132
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))