?

Average Accuracy: 53.8% → 98.9%
Time: 8.2s
Precision: binary64
Cost: 832

?

\[\left(e^{x} - 2\right) + e^{-x} \]
\[x \cdot x + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.08333333333333333\right) \]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
 :precision binary64
 (+ (* x x) (* (* x x) (* (* x x) 0.08333333333333333))))
double code(double x) {
	return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
	return (x * x) + ((x * x) * ((x * x) * 0.08333333333333333));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (exp(x) - 2.0d0) + exp(-x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x * x) + ((x * x) * ((x * x) * 0.08333333333333333d0))
end function
public static double code(double x) {
	return (Math.exp(x) - 2.0) + Math.exp(-x);
}
public static double code(double x) {
	return (x * x) + ((x * x) * ((x * x) * 0.08333333333333333));
}
def code(x):
	return (math.exp(x) - 2.0) + math.exp(-x)
def code(x):
	return (x * x) + ((x * x) * ((x * x) * 0.08333333333333333))
function code(x)
	return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
end
function code(x)
	return Float64(Float64(x * x) + Float64(Float64(x * x) * Float64(Float64(x * x) * 0.08333333333333333)))
end
function tmp = code(x)
	tmp = (exp(x) - 2.0) + exp(-x);
end
function tmp = code(x)
	tmp = (x * x) + ((x * x) * ((x * x) * 0.08333333333333333));
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * x), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
x \cdot x + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.08333333333333333\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 53.8%

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

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

    [Start]53.8

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

    associate-+l- [=>]53.8

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

    sub-neg [=>]53.8

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

    sub-neg [=>]53.8

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

    +-commutative [=>]53.8

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

    distribute-neg-in [=>]53.8

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

    remove-double-neg [=>]53.8

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

    metadata-eval [=>]53.8

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

    \[\leadsto \color{blue}{{x}^{2} + 0.08333333333333333 \cdot {x}^{4}} \]
  4. Simplified98.9%

    \[\leadsto \color{blue}{x \cdot x + 0.08333333333333333 \cdot {x}^{4}} \]
    Proof

    [Start]98.9

    \[ {x}^{2} + 0.08333333333333333 \cdot {x}^{4} \]

    unpow2 [=>]98.9

    \[ \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4} \]
  5. Applied egg-rr98.6%

    \[\leadsto x \cdot x + \color{blue}{\left(\left(1 + 0.08333333333333333 \cdot {x}^{4}\right) - 1\right)} \]
    Proof

    [Start]98.9

    \[ x \cdot x + 0.08333333333333333 \cdot {x}^{4} \]

    expm1-log1p-u [=>]98.9

    \[ x \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.08333333333333333 \cdot {x}^{4}\right)\right)} \]

    expm1-udef [=>]98.6

    \[ x \cdot x + \color{blue}{\left(e^{\mathsf{log1p}\left(0.08333333333333333 \cdot {x}^{4}\right)} - 1\right)} \]

    log1p-udef [=>]98.6

    \[ x \cdot x + \left(e^{\color{blue}{\log \left(1 + 0.08333333333333333 \cdot {x}^{4}\right)}} - 1\right) \]

    add-exp-log [<=]98.6

    \[ x \cdot x + \left(\color{blue}{\left(1 + 0.08333333333333333 \cdot {x}^{4}\right)} - 1\right) \]
  6. Applied egg-rr98.9%

    \[\leadsto x \cdot x + \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.08333333333333333\right)} \]
    Proof

    [Start]98.6

    \[ x \cdot x + \left(\left(1 + 0.08333333333333333 \cdot {x}^{4}\right) - 1\right) \]

    add-exp-log [=>]98.6

    \[ x \cdot x + \left(\color{blue}{e^{\log \left(1 + 0.08333333333333333 \cdot {x}^{4}\right)}} - 1\right) \]

    log1p-udef [<=]98.6

    \[ x \cdot x + \left(e^{\color{blue}{\mathsf{log1p}\left(0.08333333333333333 \cdot {x}^{4}\right)}} - 1\right) \]

    expm1-udef [<=]98.9

    \[ x \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.08333333333333333 \cdot {x}^{4}\right)\right)} \]

    expm1-log1p-u [<=]98.9

    \[ x \cdot x + \color{blue}{0.08333333333333333 \cdot {x}^{4}} \]

    *-commutative [=>]98.9

    \[ x \cdot x + \color{blue}{{x}^{4} \cdot 0.08333333333333333} \]

    sqr-pow [=>]98.9

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

    metadata-eval [=>]98.9

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

    pow2 [<=]98.9

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

    metadata-eval [=>]98.9

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

    pow2 [<=]98.9

    \[ x \cdot x + \left(\left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot 0.08333333333333333 \]

    associate-*l* [=>]98.9

    \[ x \cdot x + \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.08333333333333333\right)} \]
  7. Final simplification98.9%

    \[\leadsto x \cdot x + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.08333333333333333\right) \]

Alternatives

Alternative 1
Accuracy98.9%
Cost704
\[\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot 0.08333333333333333\right) + 1\right) \]
Alternative 2
Accuracy98.4%
Cost192
\[x \cdot x \]
Alternative 3
Accuracy51.6%
Cost64
\[0 \]

Error

Reproduce?

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