| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 7753 |
(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 (cos (+ x x))))
(if (<= s 3.7e-140)
(* (/ t_0 (* x (* s c))) (/ (/ 1.0 (* s c)) x))
(if (<= s 6e+221)
(* t_0 (pow (* s (* x c)) -2.0))
(/ 1.0 (/ (* s x) (/ (/ (/ 1.0 c) (* s x)) c)))))))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 = cos((x + x));
double tmp;
if (s <= 3.7e-140) {
tmp = (t_0 / (x * (s * c))) * ((1.0 / (s * c)) / x);
} else if (s <= 6e+221) {
tmp = t_0 * pow((s * (x * c)), -2.0);
} else {
tmp = 1.0 / ((s * x) / (((1.0 / c) / (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
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
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) :: tmp
t_0 = cos((x + x))
if (s <= 3.7d-140) then
tmp = (t_0 / (x * (s * c))) * ((1.0d0 / (s * c)) / x)
else if (s <= 6d+221) then
tmp = t_0 * ((s * (x * c)) ** (-2.0d0))
else
tmp = 1.0d0 / ((s * x) / (((1.0d0 / c) / (s * x)) / c))
end if
code = tmp
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));
}
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x + x));
double tmp;
if (s <= 3.7e-140) {
tmp = (t_0 / (x * (s * c))) * ((1.0 / (s * c)) / x);
} else if (s <= 6e+221) {
tmp = t_0 * Math.pow((s * (x * c)), -2.0);
} else {
tmp = 1.0 / ((s * x) / (((1.0 / c) / (s * x)) / c));
}
return tmp;
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
def code(x, c, s): t_0 = math.cos((x + x)) tmp = 0 if s <= 3.7e-140: tmp = (t_0 / (x * (s * c))) * ((1.0 / (s * c)) / x) elif s <= 6e+221: tmp = t_0 * math.pow((s * (x * c)), -2.0) else: tmp = 1.0 / ((s * x) / (((1.0 / c) / (s * x)) / c)) 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 = cos(Float64(x + x)) tmp = 0.0 if (s <= 3.7e-140) tmp = Float64(Float64(t_0 / Float64(x * Float64(s * c))) * Float64(Float64(1.0 / Float64(s * c)) / x)); elseif (s <= 6e+221) tmp = Float64(t_0 * (Float64(s * Float64(x * c)) ^ -2.0)); else tmp = Float64(1.0 / Float64(Float64(s * x) / Float64(Float64(Float64(1.0 / c) / Float64(s * x)) / c))); end return tmp end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
function tmp_2 = code(x, c, s) t_0 = cos((x + x)); tmp = 0.0; if (s <= 3.7e-140) tmp = (t_0 / (x * (s * c))) * ((1.0 / (s * c)) / x); elseif (s <= 6e+221) tmp = t_0 * ((s * (x * c)) ^ -2.0); else tmp = 1.0 / ((s * x) / (((1.0 / c) / (s * x)) / c)); end tmp_2 = 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[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s, 3.7e-140], N[(N[(t$95$0 / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(s * c), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[s, 6e+221], N[(t$95$0 * N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(s * x), $MachinePrecision] / N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $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 := \cos \left(x + x\right)\\
\mathbf{if}\;s \leq 3.7 \cdot 10^{-140}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(s \cdot c\right)} \cdot \frac{\frac{1}{s \cdot c}}{x}\\
\mathbf{elif}\;s \leq 6 \cdot 10^{+221}:\\
\;\;\;\;t_0 \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{s \cdot x}{\frac{\frac{\frac{1}{c}}{s \cdot x}}{c}}}\\
\end{array}
Results
if s < 3.69999999999999977e-140Initial program 45.2%
Simplified94.3%
[Start]45.2 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\] |
|---|---|
*-commutative [=>]45.2 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)}
\] |
associate-*l* [=>]39.9 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}}
\] |
associate-*r* [=>]39.6 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}}
\] |
*-commutative [=>]39.6 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({c}^{2} \cdot {s}^{2}\right)}}
\] |
unpow2 [=>]39.6 | \[ \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 [=>]39.6 | \[ \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 [=>]66.6 | \[ \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 [=>]94.3 | \[ \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)}}
\] |
Applied egg-rr94.7%
Applied egg-rr94.1%
Applied egg-rr94.2%
if 3.69999999999999977e-140 < s < 6.0000000000000003e221Initial program 60.5%
Simplified96.0%
[Start]60.5 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\] |
|---|---|
*-commutative [=>]60.5 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)}
\] |
associate-*l* [=>]54.5 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}}
\] |
associate-*r* [=>]54.0 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}}
\] |
*-commutative [=>]54.0 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({c}^{2} \cdot {s}^{2}\right)}}
\] |
unpow2 [=>]54.0 | \[ \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 [=>]54.0 | \[ \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 [=>]66.8 | \[ \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 [=>]96.0 | \[ \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)}}
\] |
Taylor expanded in x around inf 54.5%
Simplified98.7%
[Start]54.5 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}
\] |
|---|---|
count-2 [<=]54.5 | \[ \frac{\cos \color{blue}{\left(x + x\right)}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}
\] |
associate-*r* [=>]54.0 | \[ \frac{\cos \left(x + x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}}
\] |
unpow2 [=>]54.0 | \[ \frac{\cos \left(x + x\right)}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}}
\] |
associate-/r* [=>]54.1 | \[ \color{blue}{\frac{\frac{\cos \left(x + x\right)}{{c}^{2} \cdot {s}^{2}}}{x \cdot x}}
\] |
unpow2 [=>]54.1 | \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot {s}^{2}}}{x \cdot x}
\] |
unpow2 [=>]54.1 | \[ \frac{\frac{\cos \left(x + x\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(s \cdot s\right)}}}{x \cdot x}
\] |
swap-sqr [<=]66.8 | \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(c \cdot s\right)}}}{x \cdot x}
\] |
unpow2 [<=]66.8 | \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}}}}{x \cdot x}
\] |
*-lft-identity [<=]66.8 | \[ \frac{\color{blue}{1 \cdot \frac{\cos \left(x + x\right)}{{\left(c \cdot s\right)}^{2}}}}{x \cdot x}
\] |
associate-*l/ [<=]66.4 | \[ \color{blue}{\frac{1}{x \cdot x} \cdot \frac{\cos \left(x + x\right)}{{\left(c \cdot s\right)}^{2}}}
\] |
unpow2 [=>]66.4 | \[ \frac{1}{x \cdot x} \cdot \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(c \cdot s\right)}}
\] |
associate-/r* [=>]66.6 | \[ \frac{1}{x \cdot x} \cdot \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot s}}{c \cdot s}}
\] |
times-frac [<=]74.2 | \[ \color{blue}{\frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\left(x \cdot x\right) \cdot \left(c \cdot s\right)}}
\] |
*-commutative [<=]74.2 | \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(c \cdot s\right) \cdot \left(x \cdot x\right)}}
\] |
associate-*r* [=>]89.6 | \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot x}}
\] |
*-commutative [<=]89.6 | \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right)} \cdot x}
\] |
if 6.0000000000000003e221 < s Initial program 62.1%
Simplified62.1%
[Start]62.1 | \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\] |
|---|---|
associate-*r* [=>]62.1 | \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}}
\] |
unpow2 [=>]62.1 | \[ \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 [=>]62.1 | \[ \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}
\] |
Taylor expanded in x around 0 53.8%
Simplified68.3%
[Start]53.8 | \[ \frac{1}{{s}^{2} \cdot \left({c}^{2} \cdot {x}^{2}\right)}
\] |
|---|---|
associate-*r* [=>]54.0 | \[ \frac{1}{\color{blue}{\left({s}^{2} \cdot {c}^{2}\right) \cdot {x}^{2}}}
\] |
*-commutative [<=]54.0 | \[ \frac{1}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right)} \cdot {x}^{2}}
\] |
associate-*r* [<=]54.0 | \[ \frac{1}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}}
\] |
unpow2 [=>]54.0 | \[ \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)}
\] |
sqr-pow [=>]54.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left({s}^{\left(\frac{2}{2}\right)} \cdot {s}^{\left(\frac{2}{2}\right)}\right)} \cdot {x}^{2}\right)}
\] |
unpow2 [=>]54.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left({s}^{\left(\frac{2}{2}\right)} \cdot {s}^{\left(\frac{2}{2}\right)}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)}
\] |
unswap-sqr [=>]74.1 | \[ \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left({s}^{\left(\frac{2}{2}\right)} \cdot x\right) \cdot \left({s}^{\left(\frac{2}{2}\right)} \cdot x\right)\right)}}
\] |
metadata-eval [=>]74.1 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left({s}^{\color{blue}{1}} \cdot x\right) \cdot \left({s}^{\left(\frac{2}{2}\right)} \cdot x\right)\right)}
\] |
unpow1 [=>]74.1 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(\color{blue}{s} \cdot x\right) \cdot \left({s}^{\left(\frac{2}{2}\right)} \cdot x\right)\right)}
\] |
rem-square-sqrt [<=]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}\right) \cdot \left({s}^{\left(\frac{2}{2}\right)} \cdot x\right)\right)}
\] |
metadata-eval [=>]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)\right) \cdot \left({s}^{\color{blue}{1}} \cdot x\right)\right)}
\] |
unpow1 [=>]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)}
\] |
rem-square-sqrt [<=]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)\right) \cdot \left(s \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}\right)\right)}
\] |
associate-*l* [<=]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(\left(s \cdot \sqrt{x}\right) \cdot \sqrt{x}\right)} \cdot \left(s \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)\right)\right)}
\] |
associate-*l* [<=]35.0 | \[ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(\left(s \cdot \sqrt{x}\right) \cdot \sqrt{x}\right) \cdot \color{blue}{\left(\left(s \cdot \sqrt{x}\right) \cdot \sqrt{x}\right)}\right)}
\] |
Applied egg-rr91.0%
Final simplification95.8%
| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 7753 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 7752 |
| Alternative 3 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 7752 |
| Alternative 4 | |
|---|---|
| Accuracy | 77.3% |
| Cost | 7625 |
| Alternative 5 | |
|---|---|
| Accuracy | 87.7% |
| Cost | 7625 |
| Alternative 6 | |
|---|---|
| Accuracy | 91.6% |
| Cost | 7625 |
| Alternative 7 | |
|---|---|
| Accuracy | 96.1% |
| Cost | 7625 |
| Alternative 8 | |
|---|---|
| Accuracy | 94.2% |
| Cost | 7624 |
| Alternative 9 | |
|---|---|
| Accuracy | 73.8% |
| Cost | 960 |
| Alternative 10 | |
|---|---|
| Accuracy | 73.8% |
| Cost | 960 |
| Alternative 11 | |
|---|---|
| Accuracy | 50.4% |
| Cost | 832 |
| Alternative 12 | |
|---|---|
| Accuracy | 69.2% |
| Cost | 832 |
| Alternative 13 | |
|---|---|
| Accuracy | 73.4% |
| Cost | 832 |
herbie shell --seed 2023129
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))