| Alternative 1 | |
|---|---|
| Accuracy | 95.9% |
| Cost | 13440 |
\[\cos \left(x + x\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}
\]
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* x (* c s)))
(t_1 (pow (* c (* x s)) 2.0))
(t_2 (cos (* 2.0 x)))
(t_3 (cos (+ x x))))
(if (<= (/ t_2 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
(/ (* (cbrt (/ t_3 t_1)) (cbrt (pow t_3 2.0))) (pow (cbrt t_1) 2.0))
(/ t_2 (* t_0 t_0)))))double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
double code(double x, double c, double s) {
double t_0 = x * (c * s);
double t_1 = pow((c * (x * s)), 2.0);
double t_2 = cos((2.0 * x));
double t_3 = cos((x + x));
double tmp;
if ((t_2 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
tmp = (cbrt((t_3 / t_1)) * cbrt(pow(t_3, 2.0))) / pow(cbrt(t_1), 2.0);
} else {
tmp = t_2 / (t_0 * t_0);
}
return tmp;
}
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));
}
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
double t_1 = Math.pow((c * (x * s)), 2.0);
double t_2 = Math.cos((2.0 * x));
double t_3 = Math.cos((x + x));
double tmp;
if ((t_2 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = (Math.cbrt((t_3 / t_1)) * Math.cbrt(Math.pow(t_3, 2.0))) / Math.pow(Math.cbrt(t_1), 2.0);
} else {
tmp = t_2 / (t_0 * t_0);
}
return tmp;
}
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 code(x, c, s) t_0 = Float64(x * Float64(c * s)) t_1 = Float64(c * Float64(x * s)) ^ 2.0 t_2 = cos(Float64(2.0 * x)) t_3 = cos(Float64(x + x)) tmp = 0.0 if (Float64(t_2 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf) tmp = Float64(Float64(cbrt(Float64(t_3 / t_1)) * cbrt((t_3 ^ 2.0))) / (cbrt(t_1) ^ 2.0)); else tmp = Float64(t_2 / Float64(t_0 * t_0)); end return tmp 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]
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Power[N[(t$95$3 / t$95$1), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[Power[t$95$3, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$2 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
t_1 := {\left(c \cdot \left(x \cdot s\right)\right)}^{2}\\
t_2 := \cos \left(2 \cdot x\right)\\
t_3 := \cos \left(x + x\right)\\
\mathbf{if}\;\frac{t_2}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\sqrt[3]{\frac{t_3}{t_1}} \cdot \sqrt[3]{{t_3}^{2}}}{{\left(\sqrt[3]{t_1}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{t_0 \cdot t_0}\\
\end{array}
Results
if (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) < +inf.0Initial program 71.0%
Simplified74.2%
[Start]71.0 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\] |
|---|---|
associate-*r* [=>]74.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}}
\] |
unpow2 [=>]74.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}
\] |
unpow2 [=>]74.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot s\right)}\right)\right) \cdot x}
\] |
Applied egg-rr43.5%
[Start]74.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}
\] |
|---|---|
add-cube-cbrt [=>]74.1 | \[ \frac{\color{blue}{\left(\sqrt[3]{\cos \left(2 \cdot x\right)} \cdot \sqrt[3]{\cos \left(2 \cdot x\right)}\right) \cdot \sqrt[3]{\cos \left(2 \cdot x\right)}}}{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}
\] |
add-cube-cbrt [=>]73.9 | \[ \frac{\left(\sqrt[3]{\cos \left(2 \cdot x\right)} \cdot \sqrt[3]{\cos \left(2 \cdot x\right)}\right) \cdot \sqrt[3]{\cos \left(2 \cdot x\right)}}{\color{blue}{\left(\sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x} \cdot \sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}\right) \cdot \sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}}}
\] |
times-frac [=>]73.9 | \[ \color{blue}{\frac{\sqrt[3]{\cos \left(2 \cdot x\right)} \cdot \sqrt[3]{\cos \left(2 \cdot x\right)}}{\sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x} \cdot \sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}} \cdot \frac{\sqrt[3]{\cos \left(2 \cdot x\right)}}{\sqrt[3]{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right) \cdot x}}}
\] |
Simplified98.4%
[Start]43.5 | \[ \frac{\sqrt[3]{{\cos \left(x + x\right)}^{2}}}{{\left(\sqrt[3]{x \cdot {\left(c \cdot \left(s \cdot \sqrt{x}\right)\right)}^{2}}\right)}^{2}} \cdot \sqrt[3]{\frac{\cos \left(x + x\right)}{x \cdot {\left(c \cdot \left(s \cdot \sqrt{x}\right)\right)}^{2}}}
\] |
|---|---|
associate-*l/ [=>]43.5 | \[ \color{blue}{\frac{\sqrt[3]{{\cos \left(x + x\right)}^{2}} \cdot \sqrt[3]{\frac{\cos \left(x + x\right)}{x \cdot {\left(c \cdot \left(s \cdot \sqrt{x}\right)\right)}^{2}}}}{{\left(\sqrt[3]{x \cdot {\left(c \cdot \left(s \cdot \sqrt{x}\right)\right)}^{2}}\right)}^{2}}}
\] |
if +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) Initial program 0.0%
Simplified95.6%
[Start]0.0 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\] |
|---|---|
*-commutative [=>]0.0 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)}
\] |
associate-*l* [=>]0.0 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}}
\] |
associate-*r* [=>]0.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}}
\] |
*-commutative [=>]0.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({c}^{2} \cdot {s}^{2}\right)}}
\] |
unpow2 [=>]0.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot {s}^{2}\right)}
\] |
unpow2 [=>]0.2 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)}
\] |
unswap-sqr [=>]65.1 | \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}}
\] |
unswap-sqr [=>]95.6 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}}
\] |
Final simplification97.8%
| Alternative 1 | |
|---|---|
| Accuracy | 95.9% |
| Cost | 13440 |
| Alternative 2 | |
|---|---|
| Accuracy | 81.4% |
| Cost | 7888 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 7756 |
| Alternative 4 | |
|---|---|
| Accuracy | 96.3% |
| Cost | 7753 |
| Alternative 5 | |
|---|---|
| Accuracy | 89.9% |
| Cost | 7625 |
| Alternative 6 | |
|---|---|
| Accuracy | 93.4% |
| Cost | 7625 |
| Alternative 7 | |
|---|---|
| Accuracy | 95.7% |
| Cost | 7625 |
| Alternative 8 | |
|---|---|
| Accuracy | 93.5% |
| Cost | 7624 |
| Alternative 9 | |
|---|---|
| Accuracy | 68.5% |
| Cost | 1097 |
| Alternative 10 | |
|---|---|
| Accuracy | 69.3% |
| Cost | 1096 |
| Alternative 11 | |
|---|---|
| Accuracy | 70.8% |
| Cost | 1096 |
| Alternative 12 | |
|---|---|
| Accuracy | 74.6% |
| Cost | 960 |
| Alternative 13 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 832 |
| Alternative 14 | |
|---|---|
| Accuracy | 74.3% |
| Cost | 832 |
| Alternative 15 | |
|---|---|
| Accuracy | 74.6% |
| Cost | 832 |
herbie shell --seed 2023138
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))