| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 13248 |
\[{x}^{2} + 0.08333333333333333 \cdot {x}^{4}
\]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (+ (pow x 2.0) (+ (* 0.08333333333333333 (pow x 4.0)) (* 0.002777777777777778 (pow x 6.0)))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return pow(x, 2.0) + ((0.08333333333333333 * pow(x, 4.0)) + (0.002777777777777778 * pow(x, 6.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 = (x ** 2.0d0) + ((0.08333333333333333d0 * (x ** 4.0d0)) + (0.002777777777777778d0 * (x ** 6.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 Math.pow(x, 2.0) + ((0.08333333333333333 * Math.pow(x, 4.0)) + (0.002777777777777778 * Math.pow(x, 6.0)));
}
def code(x): return (math.exp(x) - 2.0) + math.exp(-x)
def code(x): return math.pow(x, 2.0) + ((0.08333333333333333 * math.pow(x, 4.0)) + (0.002777777777777778 * math.pow(x, 6.0)))
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function code(x) return Float64((x ^ 2.0) + Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(0.002777777777777778 * (x ^ 6.0)))) end
function tmp = code(x) tmp = (exp(x) - 2.0) + exp(-x); end
function tmp = code(x) tmp = (x ^ 2.0) + ((0.08333333333333333 * (x ^ 4.0)) + (0.002777777777777778 * (x ^ 6.0))); end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Power[x, 2.0], $MachinePrecision] + N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
{x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)
Results
| Original | 29.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
Initial program 29.6
Simplified29.6
[Start]29.6 | \[ \left(e^{x} - 2\right) + e^{-x}
\] |
|---|---|
rational_best-simplify-1 [=>]29.6 | \[ \color{blue}{e^{-x} + \left(e^{x} - 2\right)}
\] |
rational_best-simplify-61 [=>]29.6 | \[ e^{-x} + \color{blue}{\left(e^{x} + \left(-2\right)\right)}
\] |
rational_best-simplify-115 [=>]29.6 | \[ \color{blue}{e^{x} + \left(\left(-2\right) + e^{-x}\right)}
\] |
rational_best-simplify-1 [=>]29.6 | \[ e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)}
\] |
metadata-eval [=>]29.6 | \[ e^{x} + \left(e^{-x} + \color{blue}{-2}\right)
\] |
Taylor expanded in x around 0 0.5
Simplified0.5
[Start]0.5 | \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
|---|---|
rational_best-simplify-115 [=>]0.5 | \[ \color{blue}{{x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)}
\] |
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 1.0 |
| Cost | 6528 |
| Alternative 3 | |
|---|---|
| Error | 60.2 |
| Cost | 64 |
herbie shell --seed 2023104
(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))))