| Alternative 1 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 25920 |
\[\cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}
\]
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
(FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 20.0) x) (/ x 2.0))))
double code(double x) {
return cos(x) * exp((10.0 * (x * x)));
}
double code(double x) {
return cos(x) * pow(pow(exp(20.0), x), (x / 2.0));
}
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) * ((exp(20.0d0) ** x) ** (x / 2.0d0))
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.pow(Math.exp(20.0), x), (x / 2.0));
}
def code(x): return math.cos(x) * math.exp((10.0 * (x * x)))
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(20.0), x), (x / 2.0))
function code(x) return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x)))) end
function code(x) return Float64(cos(x) * ((exp(20.0) ^ x) ^ Float64(x / 2.0))) end
function tmp = code(x) tmp = cos(x) * exp((10.0 * (x * x))); end
function tmp = code(x) tmp = cos(x) * ((exp(20.0) ^ x) ^ (x / 2.0)); 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[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\cos x \cdot {\left({\left(e^{20}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}
Results
Initial program 94.5%
Simplified98.0%
[Start]94.5 | \[ \cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\] |
|---|---|
associate-*r* [=>]94.4 | \[ \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right) \cdot x}}
\] |
exp-prod [=>]95.0 | \[ \cos x \cdot \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}}
\] |
sqr-pow [=>]95.0 | \[ \cos x \cdot \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)}
\] |
sqr-pow [<=]95.0 | \[ \cos x \cdot \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}}
\] |
exp-prod [=>]98.0 | \[ \cos x \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{x}
\] |
Applied egg-rr95.2%
[Start]98.0 | \[ \cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}
\] |
|---|---|
add-cbrt-cube [=>]97.8 | \[ \cos x \cdot \color{blue}{\sqrt[3]{\left({\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}\right) \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}}}
\] |
pow3 [=>]97.8 | \[ \cos x \cdot \sqrt[3]{\color{blue}{{\left({\left({\left(e^{10}\right)}^{x}\right)}^{x}\right)}^{3}}}
\] |
pow-pow [=>]95.2 | \[ \cos x \cdot \sqrt[3]{{\color{blue}{\left({\left(e^{10}\right)}^{\left(x \cdot x\right)}\right)}}^{3}}
\] |
Applied egg-rr99.4%
[Start]95.2 | \[ \cos x \cdot \sqrt[3]{{\left({\left(e^{10}\right)}^{\left(x \cdot x\right)}\right)}^{3}}
\] |
|---|---|
rem-cbrt-cube [=>]95.3 | \[ \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}}
\] |
pow-unpow [=>]98.0 | \[ \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}}
\] |
sqr-pow [=>]98.0 | \[ \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)}
\] |
pow-prod-down [=>]98.0 | \[ \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}
\] |
pow-prod-down [=>]98.0 | \[ \cos x \cdot {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)}
\] |
prod-exp [=>]99.4 | \[ \cos x \cdot {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)}
\] |
metadata-eval [=>]99.4 | \[ \cos x \cdot {\left({\left(e^{\color{blue}{20}}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}
\] |
Final simplification99.4%
| Alternative 1 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 25920 |
| Alternative 2 | |
|---|---|
| Accuracy | 95.2% |
| Cost | 19840 |
| Alternative 3 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 19712 |
| Alternative 4 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 19584 |
| Alternative 5 | |
|---|---|
| Accuracy | 94.5% |
| Cost | 13504 |
| Alternative 6 | |
|---|---|
| Accuracy | 94.5% |
| Cost | 13248 |
| Alternative 7 | |
|---|---|
| Accuracy | 18.2% |
| Cost | 7232 |
| Alternative 8 | |
|---|---|
| Accuracy | 9.7% |
| Cost | 448 |
| Alternative 9 | |
|---|---|
| Accuracy | 1.5% |
| Cost | 64 |
herbie shell --seed 2023147
(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)))))