Average Error: 29.6 → 29.5
Time: 11.4s
Precision: binary64
Cost: 64960
\[\left(e^{x} - 2\right) + e^{-x} \]
\[\begin{array}{l} t_0 := e^{x} + 2\\ \frac{\sqrt{{\left(\mathsf{fma}\left(\sqrt[3]{{\left(e^{x}\right)}^{6}} + -4, e^{x}, t_0\right)\right)}^{2}}}{e^{x} \cdot t_0} \end{array} \]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ (exp x) 2.0)))
   (/
    (sqrt (pow (fma (+ (cbrt (pow (exp x) 6.0)) -4.0) (exp x) t_0) 2.0))
    (* (exp x) t_0))))
double code(double x) {
	return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
	double t_0 = exp(x) + 2.0;
	return sqrt(pow(fma((cbrt(pow(exp(x), 6.0)) + -4.0), exp(x), t_0), 2.0)) / (exp(x) * t_0);
}
function code(x)
	return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
end
function code(x)
	t_0 = Float64(exp(x) + 2.0)
	return Float64(sqrt((fma(Float64(cbrt((exp(x) ^ 6.0)) + -4.0), exp(x), t_0) ^ 2.0)) / Float64(exp(x) * t_0))
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[Exp[x], $MachinePrecision] + 2.0), $MachinePrecision]}, N[(N[Sqrt[N[Power[N[(N[(N[Power[N[Power[N[Exp[x], $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision] + -4.0), $MachinePrecision] * N[Exp[x], $MachinePrecision] + t$95$0), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]
\left(e^{x} - 2\right) + e^{-x}
\begin{array}{l}
t_0 := e^{x} + 2\\
\frac{\sqrt{{\left(\mathsf{fma}\left(\sqrt[3]{{\left(e^{x}\right)}^{6}} + -4, e^{x}, t_0\right)\right)}^{2}}}{e^{x} \cdot t_0}
\end{array}

Error

Target

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

Derivation

  1. Initial program 29.6

    \[\left(e^{x} - 2\right) + e^{-x} \]
  2. Applied egg-rr29.6

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{x}, e^{x}, -4\right) \cdot e^{x} + \left(e^{x} + 2\right) \cdot 1}{\left(e^{x} + 2\right) \cdot e^{x}}} \]
  3. Simplified29.5

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({\left(e^{x}\right)}^{2} + -4, e^{x}, e^{x} - -2\right)}{e^{x} \cdot \left(e^{x} - -2\right)}} \]
    Proof
    (/.f64 (fma.f64 (+.f64 (pow.f64 (exp.f64 x) 2) -4) (exp.f64 x) (-.f64 (exp.f64 x) -2)) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 0 points decrease in error
    (/.f64 (fma.f64 (+.f64 (Rewrite=> unpow2_binary64 (*.f64 (exp.f64 x) (exp.f64 x))) -4) (exp.f64 x) (-.f64 (exp.f64 x) -2)) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 0 points decrease in error
    (/.f64 (fma.f64 (Rewrite<= fma-udef_binary64 (fma.f64 (exp.f64 x) (exp.f64 x) -4)) (exp.f64 x) (-.f64 (exp.f64 x) -2)) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 2 points decrease in error
    (/.f64 (fma.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x) (Rewrite=> sub-neg_binary64 (+.f64 (exp.f64 x) (neg.f64 -2)))) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 0 points decrease in error
    (/.f64 (fma.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x) (+.f64 (exp.f64 x) (Rewrite=> metadata-eval 2))) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 0 points decrease in error
    (/.f64 (fma.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x) (Rewrite<= *-rgt-identity_binary64 (*.f64 (+.f64 (exp.f64 x) 2) 1))) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x)) (*.f64 (+.f64 (exp.f64 x) 2) 1))) (*.f64 (exp.f64 x) (-.f64 (exp.f64 x) -2))): 11 points increase in error, 3 points decrease in error
    (/.f64 (+.f64 (*.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x)) (*.f64 (+.f64 (exp.f64 x) 2) 1)) (*.f64 (exp.f64 x) (Rewrite=> sub-neg_binary64 (+.f64 (exp.f64 x) (neg.f64 -2))))): 0 points increase in error, 0 points decrease in error
    (/.f64 (+.f64 (*.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x)) (*.f64 (+.f64 (exp.f64 x) 2) 1)) (*.f64 (exp.f64 x) (+.f64 (exp.f64 x) (Rewrite=> metadata-eval 2)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (+.f64 (*.f64 (fma.f64 (exp.f64 x) (exp.f64 x) -4) (exp.f64 x)) (*.f64 (+.f64 (exp.f64 x) 2) 1)) (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (exp.f64 x) 2) (exp.f64 x)))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr29.5

    \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{e^{x + x}} + -4, e^{x}, e^{x} - -2\right)}{e^{x} \cdot \left(e^{x} - -2\right)} \]
  5. Applied egg-rr29.5

    \[\leadsto \frac{\color{blue}{\sqrt{{\left(\mathsf{fma}\left({\left(e^{x}\right)}^{2} + -4, e^{x}, e^{x} + 2\right)\right)}^{2}}}}{e^{x} \cdot \left(e^{x} - -2\right)} \]
  6. Applied egg-rr29.5

    \[\leadsto \frac{\sqrt{{\left(\mathsf{fma}\left(\color{blue}{\sqrt[3]{{\left(e^{x}\right)}^{6}}} + -4, e^{x}, e^{x} + 2\right)\right)}^{2}}}{e^{x} \cdot \left(e^{x} - -2\right)} \]
  7. Final simplification29.5

    \[\leadsto \frac{\sqrt{{\left(\mathsf{fma}\left(\sqrt[3]{{\left(e^{x}\right)}^{6}} + -4, e^{x}, e^{x} + 2\right)\right)}^{2}}}{e^{x} \cdot \left(e^{x} + 2\right)} \]

Alternatives

Alternative 1
Error29.5
Cost39360
\[\begin{array}{l} t_0 := e^{x} + 2\\ \frac{\mathsf{fma}\left(-4 + e^{x + x}, e^{x}, t_0\right)}{e^{x} \cdot t_0} \end{array} \]
Alternative 2
Error29.5
Cost32832
\[\frac{\mathsf{fma}\left(e^{x + x} + -3, e^{x}, 2\right)}{e^{x} \cdot \left(e^{x} + 2\right)} \]
Alternative 3
Error29.6
Cost13184
\[e^{x} + \left(-2 + e^{-x}\right) \]
Alternative 4
Error29.6
Cost13184
\[\left(e^{x} + -2\right) + e^{-x} \]
Alternative 5
Error29.6
Cost6720
\[-2 + 2 \cdot \cosh x \]

Error

Reproduce

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