| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 6912 |
\[x \cdot x + {x}^{4} \cdot 0.08333333333333333
\]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (+ (* 0.002777777777777778 (pow x 6.0)) (+ (* x x) (* (pow x 4.0) 0.08333333333333333))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return (0.002777777777777778 * pow(x, 6.0)) + ((x * x) + (pow(x, 4.0) * 0.08333333333333333));
}
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)) + ((x * x) + ((x ** 4.0d0) * 0.08333333333333333d0))
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)) + ((x * x) + (Math.pow(x, 4.0) * 0.08333333333333333));
}
def code(x): return (math.exp(x) - 2.0) + math.exp(-x)
def code(x): return (0.002777777777777778 * math.pow(x, 6.0)) + ((x * x) + (math.pow(x, 4.0) * 0.08333333333333333))
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(x * x) + Float64((x ^ 4.0) * 0.08333333333333333))) end
function tmp = code(x) tmp = (exp(x) - 2.0) + exp(-x); end
function tmp = code(x) tmp = (0.002777777777777778 * (x ^ 6.0)) + ((x * x) + ((x ^ 4.0) * 0.08333333333333333)); 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[(x * x), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
0.002777777777777778 \cdot {x}^{6} + \left(x \cdot x + {x}^{4} \cdot 0.08333333333333333\right)
Results
| Original | 29.8 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
Initial program 29.8
Simplified29.8
Taylor expanded in x around 0 0.7
Applied egg-rr0.7
Applied egg-rr0.7
Final simplification0.7
| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 6912 |
| Alternative 2 | |
|---|---|
| Error | 1.2 |
| Cost | 192 |
| Alternative 3 | |
|---|---|
| Error | 60.2 |
| Cost | 64 |
herbie shell --seed 2022317
(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))))