?

Average Accuracy: 53.6% → 99.1%
Time: 13.6s
Precision: binary64
Cost: 39168

?

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

Error?

Target

Original53.6%
Target99.9%
Herbie99.1%
\[4 \cdot {\sinh \left(\frac{x}{2}\right)}^{2} \]

Derivation?

  1. Initial program 53.6%

    \[\left(e^{x} - 2\right) + e^{-x} \]
  2. Simplified53.6%

    \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    Proof

    [Start]53.6

    \[ \left(e^{x} - 2\right) + e^{-x} \]

    associate-+l- [=>]53.6

    \[ \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]

    sub-neg [=>]53.6

    \[ \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]

    neg-sub0 [=>]53.6

    \[ e^{x} + \color{blue}{\left(0 - \left(2 - e^{-x}\right)\right)} \]

    associate--r- [=>]53.6

    \[ e^{x} + \color{blue}{\left(\left(0 - 2\right) + e^{-x}\right)} \]

    metadata-eval [=>]53.6

    \[ e^{x} + \left(\color{blue}{-2} + e^{-x}\right) \]

    metadata-eval [<=]53.6

    \[ e^{x} + \left(\color{blue}{\left(-2\right)} + e^{-x}\right) \]

    +-commutative [=>]53.6

    \[ e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]

    metadata-eval [=>]53.6

    \[ e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
  3. Taylor expanded in x around 0 99.1%

    \[\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)} \]
  4. Simplified99.1%

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

    [Start]99.1

    \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right) \]

    fma-def [=>]99.1

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

    unpow2 [=>]99.1

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

    fma-def [=>]99.1

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

    fma-def [=>]99.1

    \[ \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)}\right)\right) \]
  5. Final simplification99.1%

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

Alternatives

Alternative 1
Accuracy99.0%
Cost7552
\[\left(x \cdot x + 0.002777777777777778 \cdot {x}^{6}\right) + 0.08333333333333333 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \]
Alternative 2
Accuracy98.8%
Cost704
\[\left(x \cdot x\right) \cdot \left(0.08333333333333333 \cdot \left(x \cdot x\right) + 1\right) \]
Alternative 3
Accuracy98.2%
Cost192
\[x \cdot x \]
Alternative 4
Accuracy5.9%
Cost64
\[x \]

Error

Reproduce?

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