(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (fma 4.96031746031746e-5 (pow x 8.0) (fma 0.002777777777777778 (pow x 6.0) (fma x x (* 0.08333333333333333 (pow x 4.0))))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return fma(4.96031746031746e-5, pow(x, 8.0), fma(0.002777777777777778, pow(x, 6.0), fma(x, x, (0.08333333333333333 * pow(x, 4.0)))));
}
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function code(x) return fma(4.96031746031746e-5, (x ^ 8.0), fma(0.002777777777777778, (x ^ 6.0), fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0))))) end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(4.96031746031746e-5 * N[Power[x, 8.0], $MachinePrecision] + N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(4.96031746031746 \cdot 10^{-5}, {x}^{8}, \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\right)\right)




Bits error versus x
| Original | 29.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
Initial program 29.9
Taylor expanded in x around 0 0.5
Simplified0.5
Taylor expanded in x around 0 0.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2022131
(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))))