| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 32320 |
\[\cos x \cdot {\left(\sqrt{{\left(e^{20}\right)}^{x}}\right)}^{x}
\]

(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
(FPCore (x) :precision binary64 (* (cos x) (pow (sqrt (pow (exp 20.0) x)) x)))
double code(double x) {
return cos(x) * exp((10.0 * (x * x)));
}
double code(double x) {
return cos(x) * pow(sqrt(pow(exp(20.0), x)), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * exp((10.0d0 * (x * x)))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (sqrt((exp(20.0d0) ** x)) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.sqrt(Math.pow(Math.exp(20.0), x)), x);
}
def code(x): return math.cos(x) * math.exp((10.0 * (x * x)))
def code(x): return math.cos(x) * math.pow(math.sqrt(math.pow(math.exp(20.0), x)), x)
function code(x) return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x)))) end
function code(x) return Float64(cos(x) * (sqrt((exp(20.0) ^ x)) ^ x)) end
function tmp = code(x) tmp = cos(x) * exp((10.0 * (x * x))); end
function tmp = code(x) tmp = cos(x) * (sqrt((exp(20.0) ^ x)) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Sqrt[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision]], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\cos x \cdot {\left(\sqrt{{\left(e^{20}\right)}^{x}}\right)}^{x}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 94.6%
Applied egg-rr94.1%
[Start]94.6% | \[ \cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\] |
|---|---|
*-un-lft-identity [=>]94.6% | \[ \cos x \cdot e^{\color{blue}{1 \cdot \left(10 \cdot \left(x \cdot x\right)\right)}}
\] |
exp-prod [=>]94.2% | \[ \cos x \cdot \color{blue}{{\left(e^{1}\right)}^{\left(10 \cdot \left(x \cdot x\right)\right)}}
\] |
associate-*r* [=>]93.9% | \[ \cos x \cdot {\left(e^{1}\right)}^{\color{blue}{\left(\left(10 \cdot x\right) \cdot x\right)}}
\] |
pow-unpow [=>]94.1% | \[ \cos x \cdot \color{blue}{{\left({\left(e^{1}\right)}^{\left(10 \cdot x\right)}\right)}^{x}}
\] |
Applied egg-rr99.1%
[Start]94.1% | \[ \cos x \cdot {\left({\left(e^{1}\right)}^{\left(10 \cdot x\right)}\right)}^{x}
\] |
|---|---|
pow-exp [=>]95.2% | \[ \cos x \cdot {\color{blue}{\left(e^{1 \cdot \left(10 \cdot x\right)}\right)}}^{x}
\] |
*-un-lft-identity [<=]95.2% | \[ \cos x \cdot {\left(e^{\color{blue}{10 \cdot x}}\right)}^{x}
\] |
pow-exp [<=]97.9% | \[ \cos x \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{x}
\] |
add-sqr-sqrt [=>]97.9% | \[ \cos x \cdot {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x}
\] |
sqrt-unprod [=>]97.9% | \[ \cos x \cdot {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x}
\] |
pow-prod-down [=>]97.9% | \[ \cos x \cdot {\left(\sqrt{\color{blue}{{\left(e^{10} \cdot e^{10}\right)}^{x}}}\right)}^{x}
\] |
prod-exp [=>]99.1% | \[ \cos x \cdot {\left(\sqrt{{\color{blue}{\left(e^{10 + 10}\right)}}^{x}}\right)}^{x}
\] |
metadata-eval [=>]99.1% | \[ \cos x \cdot {\left(\sqrt{{\left(e^{\color{blue}{20}}\right)}^{x}}\right)}^{x}
\] |
Final simplification99.1%
| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 32320 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 32320 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 25920 |
| Alternative 4 | |
|---|---|
| Accuracy | 95.2% |
| Cost | 19648 |
| Alternative 5 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 19584 |
| Alternative 6 | |
|---|---|
| Accuracy | 94.5% |
| Cost | 13248 |
| Alternative 7 | |
|---|---|
| Accuracy | 18.2% |
| Cost | 7232 |
| Alternative 8 | |
|---|---|
| Accuracy | 1.5% |
| Cost | 448 |
| Alternative 9 | |
|---|---|
| Accuracy | 9.7% |
| Cost | 448 |
herbie shell --seed 2023277
(FPCore (x)
:name "ENA, Section 1.4, Exercise 1"
:precision binary64
:pre (and (<= 1.99 x) (<= x 2.01))
(* (cos x) (exp (* 10.0 (* x x)))))