Average Error: 58.8 → 0.5
Time: 4.4s
Precision: binary64
Cost: 704
\[-0.00017 < x\]
\[e^{x} - 1\]
\[x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)\]
e^{x} - 1
x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)
(FPCore (x) :precision binary64 (- (exp x) 1.0))
(FPCore (x)
 :precision binary64
 (+ x (* x (* x (+ 0.5 (* x 0.16666666666666666))))))
double code(double x) {
	return exp(x) - 1.0;
}
double code(double x) {
	return x + (x * (x * (0.5 + (x * 0.16666666666666666))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original58.8
Target0.5
Herbie0.5
\[x \cdot \left(\left(1 + \frac{x}{2}\right) + \frac{x \cdot x}{6}\right)\]

Alternatives

Alternative 1
Error58.8
Cost39104
\[\sqrt[3]{e^{x} + -1} \cdot \left(\sqrt[3]{e^{x} + -1} \cdot \sqrt[3]{e^{x} + -1}\right)\]
Alternative 2
Error58.8
Cost26368
\[\frac{-1 + {\left(e^{x}\right)}^{3}}{1 + e^{x} \cdot \left(1 + e^{x}\right)}\]
Alternative 3
Error58.8
Cost26048
\[\left(1 + \sqrt{e^{x}}\right) \cdot \left(\sqrt{e^{x}} + -1\right)\]
Alternative 4
Error58.8
Cost19456
\[\sqrt[3]{{\left(e^{x} + -1\right)}^{3}}\]
Alternative 5
Error59.4
Cost19392
\[e^{\log \left(e^{x} + -1\right)}\]
Alternative 6
Error58.8
Cost6592
\[e^{x} + -1\]
Alternative 7
Error0.6
Cost448
\[x + 0.5 \cdot \left(x \cdot x\right)\]
Alternative 8
Error1.2
Cost64
\[x\]
Alternative 9
Error61.5
Cost64
\[1\]
Alternative 10
Error60.5
Cost64
\[0\]
Alternative 11
Error61.6
Cost64
\[-1\]

Error

Derivation

  1. Initial program 58.8

    \[e^{x} - 1\]
  2. Taylor expanded around 0 0.5

    \[\leadsto \color{blue}{x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right)}\]
  3. Simplified0.5

    \[\leadsto \color{blue}{x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}\]
  4. Simplified0.5

    \[\leadsto \color{blue}{x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}\]
  5. Final simplification0.5

    \[\leadsto x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)\]

Reproduce

herbie shell --seed 2021042 
(FPCore (x)
  :name "expm1 (example 3.7)"
  :precision binary64
  :pre (< -0.00017 x)

  :herbie-target
  (* x (+ (+ 1.0 (/ x 2.0)) (/ (* x x) 6.0)))

  (- (exp x) 1.0))