| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 13632 |
\[0.002777777777777778 \cdot {x}^{6} + \left(0.08333333333333333 \cdot {x}^{4} + x \cdot x\right)
\]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (+ (* 0.002777777777777778 (pow x 6.0)) (+ (+ (* 0.08333333333333333 (pow x 4.0)) (* x x)) (* 4.96031746031746e-5 (pow x 8.0)))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return (0.002777777777777778 * pow(x, 6.0)) + (((0.08333333333333333 * pow(x, 4.0)) + (x * x)) + (4.96031746031746e-5 * pow(x, 8.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - 2.0d0) + exp(-x)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = (0.002777777777777778d0 * (x ** 6.0d0)) + (((0.08333333333333333d0 * (x ** 4.0d0)) + (x * x)) + (4.96031746031746d-5 * (x ** 8.0d0)))
end function
public static double code(double x) {
return (Math.exp(x) - 2.0) + Math.exp(-x);
}
public static double code(double x) {
return (0.002777777777777778 * Math.pow(x, 6.0)) + (((0.08333333333333333 * Math.pow(x, 4.0)) + (x * x)) + (4.96031746031746e-5 * Math.pow(x, 8.0)));
}
def code(x): return (math.exp(x) - 2.0) + math.exp(-x)
def code(x): return (0.002777777777777778 * math.pow(x, 6.0)) + (((0.08333333333333333 * math.pow(x, 4.0)) + (x * x)) + (4.96031746031746e-5 * math.pow(x, 8.0)))
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function code(x) return Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + Float64(Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(x * x)) + Float64(4.96031746031746e-5 * (x ^ 8.0)))) end
function tmp = code(x) tmp = (exp(x) - 2.0) + exp(-x); end
function tmp = code(x) tmp = (0.002777777777777778 * (x ^ 6.0)) + (((0.08333333333333333 * (x ^ 4.0)) + (x * x)) + (4.96031746031746e-5 * (x ^ 8.0))); end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(4.96031746031746e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
0.002777777777777778 \cdot {x}^{6} + \left(\left(0.08333333333333333 \cdot {x}^{4} + x \cdot x\right) + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)
Results
| Original | 29.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
Initial program 29.5
Simplified29.5
[Start]29.5 | \[ \left(e^{x} - 2\right) + e^{-x}
\] |
|---|---|
associate-+l- [=>]29.5 | \[ \color{blue}{e^{x} - \left(2 - e^{-x}\right)}
\] |
sub-neg [=>]29.5 | \[ \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)}
\] |
+-commutative [=>]29.5 | \[ \color{blue}{\left(-\left(2 - e^{-x}\right)\right) + e^{x}}
\] |
neg-sub0 [=>]29.5 | \[ \color{blue}{\left(0 - \left(2 - e^{-x}\right)\right)} + e^{x}
\] |
associate-+l- [=>]29.5 | \[ \color{blue}{0 - \left(\left(2 - e^{-x}\right) - e^{x}\right)}
\] |
associate--l- [=>]29.6 | \[ 0 - \color{blue}{\left(2 - \left(e^{-x} + e^{x}\right)\right)}
\] |
+-commutative [=>]29.6 | \[ 0 - \left(2 - \color{blue}{\left(e^{x} + e^{-x}\right)}\right)
\] |
associate--r+ [=>]29.5 | \[ 0 - \color{blue}{\left(\left(2 - e^{x}\right) - e^{-x}\right)}
\] |
associate--r- [=>]29.5 | \[ \color{blue}{\left(0 - \left(2 - e^{x}\right)\right) + e^{-x}}
\] |
neg-sub0 [<=]29.5 | \[ \color{blue}{\left(-\left(2 - e^{x}\right)\right)} + e^{-x}
\] |
+-commutative [<=]29.5 | \[ \color{blue}{e^{-x} + \left(-\left(2 - e^{x}\right)\right)}
\] |
sub-neg [<=]29.5 | \[ \color{blue}{e^{-x} - \left(2 - e^{x}\right)}
\] |
Taylor expanded in x around 0 0.6
Applied egg-rr0.6
Applied egg-rr0.6
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 13632 |
| Alternative 2 | |
|---|---|
| Error | 1.1 |
| Cost | 6912 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 6912 |
| Alternative 4 | |
|---|---|
| Error | 1.1 |
| Cost | 192 |
| Alternative 5 | |
|---|---|
| Error | 60.2 |
| Cost | 128 |
herbie shell --seed 2023187
(FPCore (x)
:name "exp2 (problem 3.3.7)"
:precision binary64
:herbie-target
(* 4.0 (pow (sinh (/ x 2.0)) 2.0))
(+ (- (exp x) 2.0) (exp (- x))))