?

Average Error: 29.8 → 0.6
Time: 1.0min
Precision: binary64
Cost: 26624

?

\[\left(e^{x} - 2\right) + e^{-x} \]
\[0.002777777777777778 \cdot {x}^{6} + \left(\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) \]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
 :precision binary64
 (+
  (* 0.002777777777777778 (pow x 6.0))
  (+
   (fma x x (* (pow x 4.0) 0.08333333333333333))
   (* 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)) + (fma(x, x, (pow(x, 4.0) * 0.08333333333333333)) + (4.96031746031746e-5 * 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(fma(x, x, Float64((x ^ 4.0) * 0.08333333333333333)) + Float64(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[(x * x + N[(N[Power[x, 4.0], $MachinePrecision] * 0.08333333333333333), $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(\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)

Error?

Target

Original29.8
Target0.0
Herbie0.6
\[4 \cdot {\sinh \left(\frac{x}{2}\right)}^{2} \]

Derivation?

  1. Initial program 29.8

    \[\left(e^{x} - 2\right) + e^{-x} \]
  2. Taylor expanded in x around 0 0.6

    \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)} \]
  3. Applied egg-rr0.6

    \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\left(\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)} \]

Alternatives

Alternative 1
Error0.7
Cost19904
\[0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) \]
Alternative 2
Error0.8
Cost13184
\[\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) \]
Alternative 3
Error0.9
Cost6912
\[\left(0.08333333333333333 \cdot {x}^{3} + x\right) \cdot x \]
Alternative 4
Error1.1
Cost192
\[x \cdot x \]
Alternative 5
Error60.2
Cost128
\[-x \]

Error

Reproduce?

herbie shell --seed 2023033 
(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))))