Average Error: 29.5 → 0.0
Time: 2.1s
Precision: 64
\[e^{a \cdot x} - 1\]
\[\mathsf{expm1}\left(a \cdot x\right)\]
e^{a \cdot x} - 1
\mathsf{expm1}\left(a \cdot x\right)
double code(double a, double x) {
	return (exp((a * x)) - 1.0);
}
double code(double a, double x) {
	return expm1((a * x));
}

Error

Bits error versus a

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.5
Target0.1
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| \lt 0.10000000000000001:\\ \;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \end{array}\]

Derivation

  1. Initial program 29.5

    \[e^{a \cdot x} - 1\]
  2. Using strategy rm
  3. Applied expm1-log1p-u29.5

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{a \cdot x} - 1\right)\right)}\]
  4. Taylor expanded around inf 29.5

    \[\leadsto \color{blue}{e^{a \cdot x} - 1}\]
  5. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{expm1}\left(a \cdot x\right)}\]
  6. Final simplification0.0

    \[\leadsto \mathsf{expm1}\left(a \cdot x\right)\]

Reproduce

herbie shell --seed 2020092 +o rules:numerics
(FPCore (a x)
  :name "expax (section 3.5)"
  :precision binary64
  :herbie-expected 14

  :herbie-target
  (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))

  (- (exp (* a x)) 1))