?

Average Accuracy: 53.4% → 99.0%
Time: 9.0s
Precision: binary64
Cost: 13568

?

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

Error?

Target

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

Derivation?

  1. Initial program 53.4%

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

    \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
  3. Simplified99.0%

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

    [Start]99.0

    \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    +-commutative [=>]99.0

    \[ \color{blue}{\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right) + 0.002777777777777778 \cdot {x}^{6}} \]

    associate-+l+ [=>]99.0

    \[ \color{blue}{{x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)} \]

    unpow2 [=>]99.0

    \[ \color{blue}{x \cdot x} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right) \]

    fma-def [=>]99.0

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

    fma-def [=>]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, 0.002777777777777778 \cdot {x}^{6}\right)}\right) \]
  4. Applied egg-rr99.0%

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}}\right) \]
    Proof

    [Start]99.0

    \[ \mathsf{fma}\left(x, x, \mathsf{fma}\left(0.08333333333333333, {x}^{4}, 0.002777777777777778 \cdot {x}^{6}\right)\right) \]

    fma-udef [=>]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}}\right) \]
  5. Taylor expanded in x around 0 99.0%

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{0.002777777777777778 \cdot {x}^{6} + 0.08333333333333333 \cdot {x}^{4}}\right) \]
  6. Simplified99.0%

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{{x}^{4} \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right)}\right) \]
    Proof

    [Start]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    metadata-eval [<=]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{\color{blue}{\left(2 \cdot 3\right)}} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    pow-sqr [<=]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \color{blue}{\left({x}^{3} \cdot {x}^{3}\right)} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    cube-mult [=>]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left({x}^{3} \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) + 0.08333333333333333 \cdot {x}^{4}\right) \]

    associate-*r* [=>]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \color{blue}{\left(\left({x}^{3} \cdot x\right) \cdot \left(x \cdot x\right)\right)} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    pow-plus [=>]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left(\color{blue}{{x}^{\left(3 + 1\right)}} \cdot \left(x \cdot x\right)\right) + 0.08333333333333333 \cdot {x}^{4}\right) \]

    metadata-eval [=>]99.0

    \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left({x}^{\color{blue}{4}} \cdot \left(x \cdot x\right)\right) + 0.08333333333333333 \cdot {x}^{4}\right) \]

    associate-*l* [<=]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{\left(0.002777777777777778 \cdot {x}^{4}\right) \cdot \left(x \cdot x\right)} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    *-commutative [=>]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{\left({x}^{4} \cdot 0.002777777777777778\right)} \cdot \left(x \cdot x\right) + 0.08333333333333333 \cdot {x}^{4}\right) \]

    associate-*r* [<=]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{{x}^{4} \cdot \left(0.002777777777777778 \cdot \left(x \cdot x\right)\right)} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    *-commutative [<=]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 0.002777777777777778\right)} + 0.08333333333333333 \cdot {x}^{4}\right) \]

    *-commutative [=>]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778\right) + \color{blue}{{x}^{4} \cdot 0.08333333333333333}\right) \]

    distribute-lft-out [=>]99.0

    \[ \mathsf{fma}\left(x, x, \color{blue}{{x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778 + 0.08333333333333333\right)}\right) \]

    associate-*l* [=>]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \left(\color{blue}{x \cdot \left(x \cdot 0.002777777777777778\right)} + 0.08333333333333333\right)\right) \]

    fma-def [=>]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right)}\right) \]
  7. Applied egg-rr99.0%

    \[\leadsto \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\left(x \cdot \left(x \cdot 0.002777777777777778\right) + 0.08333333333333333\right)}\right) \]
    Proof

    [Start]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right)\right) \]

    fma-udef [=>]99.0

    \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\left(x \cdot \left(x \cdot 0.002777777777777778\right) + 0.08333333333333333\right)}\right) \]
  8. Final simplification99.0%

    \[\leadsto \mathsf{fma}\left(x, x, {x}^{4} \cdot \left(x \cdot \left(x \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right) \]

Alternatives

Alternative 1
Accuracy98.8%
Cost13184
\[\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right) \]
Alternative 2
Accuracy98.8%
Cost6912
\[{x}^{4} \cdot 0.08333333333333333 + x \cdot x \]
Alternative 3
Accuracy98.3%
Cost192
\[x \cdot x \]
Alternative 4
Accuracy51.0%
Cost64
\[0 \]

Error

Reproduce?

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