Average Error: 58.8 → 0.0
Time: 15.1s
Precision: 64
Internal Precision: 128
\[e^{x} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le 0.00018080568618904114:\\ \;\;\;\;x + \left(x \cdot x\right) \cdot \left(\frac{1}{6} \cdot x + \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{e^{x}} - 1\right) \cdot \left(1 + \sqrt{e^{x}}\right)\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < 0.00018080568618904114

    1. Initial program 59.5

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

      \[\leadsto \color{blue}{x + \left(\frac{1}{6} \cdot {x}^{3} + \frac{1}{2} \cdot {x}^{2}\right)}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{x + \left(x \cdot x\right) \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right)}\]

    if 0.00018080568618904114 < x

    1. Initial program 2.3

      \[e^{x} - 1\]
    2. Using strategy rm
    3. Applied *-un-lft-identity2.3

      \[\leadsto e^{x} - \color{blue}{1 \cdot 1}\]
    4. Applied add-sqr-sqrt3.1

      \[\leadsto \color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1 \cdot 1\]
    5. Applied difference-of-squares3.0

      \[\leadsto \color{blue}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 0.00018080568618904114:\\ \;\;\;\;x + \left(x \cdot x\right) \cdot \left(\frac{1}{6} \cdot x + \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{e^{x}} - 1\right) \cdot \left(1 + \sqrt{e^{x}}\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (* x (+ (+ 1 (/ x 2)) (/ (* x x) 6)))

  (- (exp x) 1))