
(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 12 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 (* s c)))) (/ (* (/ 1.0 t_0) (cos (* x 2.0))) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
return ((1.0 / t_0) * cos((x * 2.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 * (s * c)
code = ((1.0d0 / t_0) * cos((x * 2.0d0))) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return ((1.0 / t_0) * Math.cos((x * 2.0))) / t_0;
}
def code(x, c, s): t_0 = x * (s * c) return ((1.0 / t_0) * math.cos((x * 2.0))) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(Float64(Float64(1.0 / t_0) * cos(Float64(x * 2.0))) / t_0) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = ((1.0 / t_0) * cos((x * 2.0))) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\frac{1}{t_0} \cdot \cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Initial program 68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
associate-*r*60.2%
add-sqr-sqrt60.2%
unpow260.2%
pow-prod-down65.7%
pow-prod-down85.1%
sqrt-pow198.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
unpow298.2%
swap-sqr78.0%
swap-sqr60.2%
unpow260.2%
unpow260.2%
associate-/l/59.8%
associate-/r*60.3%
div-inv60.3%
add-sqr-sqrt60.2%
times-frac65.7%
*-commutative65.7%
pow-prod-down65.7%
sqrt-pow150.9%
metadata-eval50.9%
pow150.9%
Applied egg-rr98.1%
*-commutative98.1%
associate-/l/98.2%
associate-*r*97.0%
associate-/l/97.0%
*-commutative97.0%
associate-*r*97.9%
associate-*r/97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))) (t_1 (cos (* x 2.0))))
(if (<= s 6e+160)
(/ t_1 (* (* x c) (* s t_0)))
(/ t_1 (* (* x s) (* c t_0))))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = cos((x * 2.0));
double tmp;
if (s <= 6e+160) {
tmp = t_1 / ((x * c) * (s * t_0));
} else {
tmp = t_1 / ((x * s) * (c * t_0));
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c * (x * s)
t_1 = cos((x * 2.0d0))
if (s <= 6d+160) then
tmp = t_1 / ((x * c) * (s * t_0))
else
tmp = t_1 / ((x * s) * (c * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = Math.cos((x * 2.0));
double tmp;
if (s <= 6e+160) {
tmp = t_1 / ((x * c) * (s * t_0));
} else {
tmp = t_1 / ((x * s) * (c * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = c * (x * s) t_1 = math.cos((x * 2.0)) tmp = 0 if s <= 6e+160: tmp = t_1 / ((x * c) * (s * t_0)) else: tmp = t_1 / ((x * s) * (c * t_0)) return tmp
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) t_1 = cos(Float64(x * 2.0)) tmp = 0.0 if (s <= 6e+160) tmp = Float64(t_1 / Float64(Float64(x * c) * Float64(s * t_0))); else tmp = Float64(t_1 / Float64(Float64(x * s) * Float64(c * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = c * (x * s); t_1 = cos((x * 2.0)); tmp = 0.0; if (s <= 6e+160) tmp = t_1 / ((x * c) * (s * t_0)); else tmp = t_1 / ((x * s) * (c * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s, 6e+160], N[(t$95$1 / N[(N[(x * c), $MachinePrecision] * N[(s * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(N[(x * s), $MachinePrecision] * N[(c * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;s \leq 6 \cdot 10^{+160}:\\
\;\;\;\;\frac{t_1}{\left(x \cdot c\right) \cdot \left(s \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\left(x \cdot s\right) \cdot \left(c \cdot t_0\right)}\\
\end{array}
\end{array}
if s < 5.9999999999999997e160Initial program 70.3%
*-commutative70.3%
associate-*r*62.8%
unpow262.8%
*-commutative62.8%
associate-*r*61.5%
add-sqr-sqrt61.5%
unpow261.5%
pow-prod-down66.3%
pow-prod-down85.1%
sqrt-pow198.1%
metadata-eval98.1%
pow198.1%
Applied egg-rr98.1%
unpow298.1%
*-commutative98.1%
associate-*r*95.3%
associate-*l*93.9%
Applied egg-rr93.9%
if 5.9999999999999997e160 < s Initial program 56.8%
*-commutative56.8%
associate-*r*48.3%
unpow248.3%
*-commutative48.3%
associate-*r*48.3%
add-sqr-sqrt48.3%
unpow248.3%
pow-prod-down60.8%
pow-prod-down84.5%
sqrt-pow199.6%
metadata-eval99.6%
pow199.6%
Applied egg-rr99.6%
unpow299.6%
associate-*l*99.7%
*-commutative99.7%
associate-*r*99.8%
associate-*l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification94.5%
(FPCore (x c s) :precision binary64 (if (<= x 2.3e-16) (pow (* c (* x s)) -2.0) (/ (/ (cos (* x 2.0)) s) (* (* x (* s c)) (* x c)))))
double code(double x, double c, double s) {
double tmp;
if (x <= 2.3e-16) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = (cos((x * 2.0)) / s) / ((x * (s * c)) * (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 <= 2.3d-16) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = (cos((x * 2.0d0)) / s) / ((x * (s * c)) * (x * c))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 2.3e-16) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = (Math.cos((x * 2.0)) / s) / ((x * (s * c)) * (x * c));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 2.3e-16: tmp = math.pow((c * (x * s)), -2.0) else: tmp = (math.cos((x * 2.0)) / s) / ((x * (s * c)) * (x * c)) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 2.3e-16) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(x * 2.0)) / s) / Float64(Float64(x * Float64(s * c)) * Float64(x * c))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 2.3e-16) tmp = (c * (x * s)) ^ -2.0; else tmp = (cos((x * 2.0)) / s) / ((x * (s * c)) * (x * c)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 2.3e-16], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s), $MachinePrecision] / N[(N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3 \cdot 10^{-16}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot c\right)}\\
\end{array}
\end{array}
if x < 2.2999999999999999e-16Initial program 68.4%
*-commutative68.4%
cos-neg68.4%
*-commutative68.4%
distribute-rgt-neg-in68.4%
metadata-eval68.4%
*-commutative68.4%
*-commutative68.4%
associate-*r*59.6%
unpow259.6%
*-commutative59.6%
unpow259.6%
associate-*r*65.1%
associate-*r*59.6%
unpow259.6%
Simplified59.6%
Taylor expanded in x around 0 54.7%
associate-/r*54.6%
*-commutative54.6%
unpow254.6%
unpow254.6%
swap-sqr72.1%
unpow272.1%
associate-/r*72.2%
unpow272.2%
unpow272.2%
swap-sqr84.8%
unpow284.8%
*-commutative84.8%
Simplified84.8%
*-commutative84.8%
associate-*l*86.1%
pow-flip86.1%
associate-*l*84.8%
metadata-eval84.8%
Applied egg-rr84.8%
if 2.2999999999999999e-16 < x Initial program 70.5%
*-commutative70.5%
associate-*r*66.2%
unpow266.2%
*-commutative66.2%
associate-*r*66.2%
add-sqr-sqrt66.1%
unpow266.1%
pow-prod-down72.1%
pow-prod-down91.8%
sqrt-pow197.3%
metadata-eval97.3%
pow197.3%
Applied egg-rr97.3%
unpow297.3%
swap-sqr83.2%
swap-sqr66.2%
unpow266.2%
unpow266.2%
associate-/l/64.7%
associate-/r*65.6%
div-inv65.6%
add-sqr-sqrt65.5%
times-frac72.0%
*-commutative72.0%
pow-prod-down72.0%
sqrt-pow159.5%
metadata-eval59.5%
pow159.5%
Applied egg-rr97.1%
*-commutative97.1%
associate-/l/97.2%
associate-*r*95.9%
frac-times94.6%
*-un-lft-identity94.6%
*-commutative94.6%
associate-*l*94.6%
Applied egg-rr94.6%
Final simplification87.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (* (/ 1.0 t_0) (/ (cos (* x 2.0)) t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (1.0 / t_0) * (cos((x * 2.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 = c * (x * s)
code = (1.0d0 / t_0) * (cos((x * 2.0d0)) / t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (1.0 / t_0) * (Math.cos((x * 2.0)) / t_0);
}
def code(x, c, s): t_0 = c * (x * s) return (1.0 / t_0) * (math.cos((x * 2.0)) / t_0)
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.0)) / t_0)) end
function tmp = code(x, c, s) t_0 = c * (x * s); tmp = (1.0 / t_0) * (cos((x * 2.0)) / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $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}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Initial program 68.9%
*-commutative68.9%
cos-neg68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
unpow261.4%
associate-*r*66.6%
associate-*r*61.4%
unpow261.4%
Simplified61.4%
*-un-lft-identity61.4%
metadata-eval61.4%
add-sqr-sqrt61.4%
times-frac61.4%
metadata-eval61.4%
sqrt-prod61.3%
unpow261.3%
sqrt-prod28.3%
add-sqr-sqrt43.0%
pow-prod-down43.1%
sqrt-pow144.7%
metadata-eval44.7%
pow144.7%
*-commutative44.7%
Applied egg-rr97.9%
Final simplification97.9%
(FPCore (x c s) :precision binary64 (* (/ (/ (cos (* x 2.0)) s) (* x c)) (/ (/ 1.0 s) (* x c))))
double code(double x, double c, double s) {
return ((cos((x * 2.0)) / s) / (x * c)) * ((1.0 / s) / (x * c));
}
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)) / s) / (x * c)) * ((1.0d0 / s) / (x * c))
end function
public static double code(double x, double c, double s) {
return ((Math.cos((x * 2.0)) / s) / (x * c)) * ((1.0 / s) / (x * c));
}
def code(x, c, s): return ((math.cos((x * 2.0)) / s) / (x * c)) * ((1.0 / s) / (x * c))
function code(x, c, s) return Float64(Float64(Float64(cos(Float64(x * 2.0)) / s) / Float64(x * c)) * Float64(Float64(1.0 / s) / Float64(x * c))) end
function tmp = code(x, c, s) tmp = ((cos((x * 2.0)) / s) / (x * c)) * ((1.0 / s) / (x * c)); end
code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{x \cdot c} \cdot \frac{\frac{1}{s}}{x \cdot c}
\end{array}
Initial program 68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
associate-*r*60.2%
add-sqr-sqrt60.2%
unpow260.2%
pow-prod-down65.7%
pow-prod-down85.1%
sqrt-pow198.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
unpow298.2%
swap-sqr78.0%
swap-sqr60.2%
unpow260.2%
unpow260.2%
associate-/l/59.8%
associate-/r*60.3%
div-inv60.3%
add-sqr-sqrt60.2%
times-frac65.7%
*-commutative65.7%
pow-prod-down65.7%
sqrt-pow150.9%
metadata-eval50.9%
pow150.9%
Applied egg-rr98.1%
Final simplification98.1%
(FPCore (x c s) :precision binary64 (/ (cos (* x 2.0)) (* (* x s) (* c (* c (* x s))))))
double code(double x, double c, double s) {
return cos((x * 2.0)) / ((x * s) * (c * (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 = cos((x * 2.0d0)) / ((x * s) * (c * (c * (x * s))))
end function
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) / ((x * s) * (c * (c * (x * s))));
}
def code(x, c, s): return math.cos((x * 2.0)) / ((x * s) * (c * (c * (x * s))))
function code(x, c, s) return Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * s) * Float64(c * Float64(c * Float64(x * s))))) end
function tmp = code(x, c, s) tmp = cos((x * 2.0)) / ((x * s) * (c * (c * (x * s)))); end
code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot s\right) \cdot \left(c \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
associate-*r*60.2%
add-sqr-sqrt60.2%
unpow260.2%
pow-prod-down65.7%
pow-prod-down85.1%
sqrt-pow198.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
unpow298.2%
associate-*l*97.0%
*-commutative97.0%
associate-*r*94.5%
associate-*l*94.8%
*-commutative94.8%
Applied egg-rr94.8%
Final simplification94.8%
(FPCore (x c s) :precision binary64 (/ (/ (/ (cos (* x 2.0)) s) (* x c)) (* x (* s c))))
double code(double x, double c, double s) {
return ((cos((x * 2.0)) / s) / (x * c)) / (x * (s * c));
}
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)) / s) / (x * c)) / (x * (s * c))
end function
public static double code(double x, double c, double s) {
return ((Math.cos((x * 2.0)) / s) / (x * c)) / (x * (s * c));
}
def code(x, c, s): return ((math.cos((x * 2.0)) / s) / (x * c)) / (x * (s * c))
function code(x, c, s) return Float64(Float64(Float64(cos(Float64(x * 2.0)) / s) / Float64(x * c)) / Float64(x * Float64(s * c))) end
function tmp = code(x, c, s) tmp = ((cos((x * 2.0)) / s) / (x * c)) / (x * (s * c)); end
code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{x \cdot c}}{x \cdot \left(s \cdot c\right)}
\end{array}
Initial program 68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
associate-*r*60.2%
add-sqr-sqrt60.2%
unpow260.2%
pow-prod-down65.7%
pow-prod-down85.1%
sqrt-pow198.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
unpow298.2%
swap-sqr78.0%
swap-sqr60.2%
unpow260.2%
unpow260.2%
associate-/l/59.8%
associate-/r*60.3%
div-inv60.3%
add-sqr-sqrt60.2%
times-frac65.7%
*-commutative65.7%
pow-prod-down65.7%
sqrt-pow150.9%
metadata-eval50.9%
pow150.9%
Applied egg-rr98.1%
associate-/l/98.2%
associate-*r*97.0%
un-div-inv97.0%
*-commutative97.0%
associate-*l*97.5%
Applied egg-rr97.5%
Final simplification97.5%
(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 68.9%
*-commutative68.9%
cos-neg68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
unpow261.4%
associate-*r*66.6%
associate-*r*61.4%
unpow261.4%
Simplified61.4%
Taylor expanded in x around 0 53.2%
associate-/r*53.2%
*-commutative53.2%
unpow253.2%
unpow253.2%
swap-sqr67.2%
unpow267.2%
associate-/r*67.2%
unpow267.2%
unpow267.2%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
associate-*l*79.2%
pow-flip79.2%
associate-*l*78.4%
metadata-eval78.4%
Applied egg-rr78.4%
Final simplification78.4%
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* (* c (* x s)) (* s c)))))
double code(double x, double c, double s) {
return 1.0 / (x * ((c * (x * s)) * (s * c)));
}
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 * (x * s)) * (s * c)))
end function
public static double code(double x, double c, double s) {
return 1.0 / (x * ((c * (x * s)) * (s * c)));
}
def code(x, c, s): return 1.0 / (x * ((c * (x * s)) * (s * c)))
function code(x, c, s) return Float64(1.0 / Float64(x * Float64(Float64(c * Float64(x * s)) * Float64(s * c)))) end
function tmp = code(x, c, s) tmp = 1.0 / (x * ((c * (x * s)) * (s * c))); end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(s \cdot c\right)\right)}
\end{array}
Initial program 68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
associate-*r*60.2%
add-sqr-sqrt60.2%
unpow260.2%
pow-prod-down65.7%
pow-prod-down85.1%
sqrt-pow198.2%
metadata-eval98.2%
pow198.2%
Applied egg-rr98.2%
unpow298.2%
associate-*l*97.0%
*-commutative97.0%
associate-*r*97.5%
associate-*r*92.8%
associate-*l*92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 75.0%
Final simplification75.0%
(FPCore (x c s) :precision binary64 (/ (/ 1.0 c) (* (* x (* s c)) (* x s))))
double code(double x, double c, double s) {
return (1.0 / c) / ((x * (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 / c) / ((x * (s * c)) * (x * s))
end function
public static double code(double x, double c, double s) {
return (1.0 / c) / ((x * (s * c)) * (x * s));
}
def code(x, c, s): return (1.0 / c) / ((x * (s * c)) * (x * s))
function code(x, c, s) return Float64(Float64(1.0 / c) / Float64(Float64(x * Float64(s * c)) * Float64(x * s))) end
function tmp = code(x, c, s) tmp = (1.0 / c) / ((x * (s * c)) * (x * s)); end
code[x_, c_, s_] := N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{c}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot s\right)}
\end{array}
Initial program 68.9%
*-commutative68.9%
cos-neg68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
unpow261.4%
associate-*r*66.6%
associate-*r*61.4%
unpow261.4%
Simplified61.4%
Taylor expanded in x around 0 53.2%
associate-/r*53.2%
*-commutative53.2%
unpow253.2%
unpow253.2%
swap-sqr67.2%
unpow267.2%
associate-/r*67.2%
unpow267.2%
unpow267.2%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
associate-*l*79.2%
add-sqr-sqrt79.1%
sqrt-div79.2%
metadata-eval79.2%
unpow279.2%
sqrt-prod45.0%
add-sqr-sqrt58.5%
associate-*l*57.7%
sqrt-div57.7%
metadata-eval57.7%
unpow257.7%
sqrt-prod37.4%
add-sqr-sqrt78.3%
associate-*l*78.3%
Applied egg-rr78.3%
associate-/r*78.4%
frac-times77.2%
div-inv77.2%
*-commutative77.2%
associate-*l*77.2%
*-commutative77.2%
Applied egg-rr77.2%
Final simplification77.2%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (/ (/ 1.0 t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
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 * (s * c)
code = (1.0d0 / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return (1.0 / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (s * c) return (1.0 / t_0) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(Float64(1.0 / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = (1.0 / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $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(s \cdot c\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 68.9%
*-commutative68.9%
cos-neg68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
unpow261.4%
associate-*r*66.6%
associate-*r*61.4%
unpow261.4%
Simplified61.4%
Taylor expanded in x around 0 53.2%
associate-/r*53.2%
*-commutative53.2%
unpow253.2%
unpow253.2%
swap-sqr67.2%
unpow267.2%
associate-/r*67.2%
unpow267.2%
unpow267.2%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
associate-*l*79.2%
add-sqr-sqrt79.1%
sqrt-div79.2%
metadata-eval79.2%
unpow279.2%
sqrt-prod45.0%
add-sqr-sqrt58.5%
associate-*l*57.7%
sqrt-div57.7%
metadata-eval57.7%
unpow257.7%
sqrt-prod37.4%
add-sqr-sqrt78.3%
associate-*l*78.3%
Applied egg-rr78.3%
un-div-inv78.3%
*-commutative78.3%
associate-*l*78.3%
*-commutative78.3%
associate-*l*79.2%
Applied egg-rr79.2%
Final simplification79.2%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * 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 = c * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = c * (x * s); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 68.9%
*-commutative68.9%
cos-neg68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
*-commutative68.9%
associate-*r*61.4%
unpow261.4%
*-commutative61.4%
unpow261.4%
associate-*r*66.6%
associate-*r*61.4%
unpow261.4%
Simplified61.4%
Taylor expanded in x around 0 53.2%
associate-/r*53.2%
*-commutative53.2%
unpow253.2%
unpow253.2%
swap-sqr67.2%
unpow267.2%
associate-/r*67.2%
unpow267.2%
unpow267.2%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
associate-*l*79.2%
add-sqr-sqrt79.1%
sqrt-div79.2%
metadata-eval79.2%
unpow279.2%
sqrt-prod45.0%
add-sqr-sqrt58.5%
associate-*l*57.7%
sqrt-div57.7%
metadata-eval57.7%
unpow257.7%
sqrt-prod37.4%
add-sqr-sqrt78.3%
associate-*l*78.3%
Applied egg-rr78.3%
frac-2neg78.3%
metadata-eval78.3%
metadata-eval78.3%
frac-2neg78.3%
metadata-eval78.3%
metadata-eval78.3%
frac-times78.3%
metadata-eval78.3%
metadata-eval78.3%
metadata-eval78.3%
distribute-rgt-neg-in78.3%
*-commutative78.3%
distribute-rgt-neg-in78.3%
*-commutative78.3%
Applied egg-rr78.3%
Final simplification78.3%
herbie shell --seed 2023336
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))