Average Error: 29.4 → 0.5
Time: 2.4s
Precision: binary64
\[\]
\[\]
double code(double a, double x) {
	return ((double) (((double) exp(((double) (a * x)))) - 1.0));
}
double code(double a, double x) {
	double VAR;
	if ((((double) (a * x)) <= -0.00020474461449866745)) {
		VAR = ((double) (((double) exp(((double) (a * x)))) - 1.0));
	} else {
		VAR = ((double) (x * ((double) (a + ((double) (a * ((double) (a * ((double) (x * 0.5))))))))));
	}
	return VAR;
}

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.4
Target0.2
Herbie0.5
\[\]

Derivation

  1. Split input into 2 regimes
  2. if (* a x) < -2.04744614498667449e-4

    1. Initial program 0.0

      \[\]

    if -2.04744614498667449e-4 < (* a x)

    1. Initial program 44.1

      \[\]
    2. Taylor expanded around 0 14.6

      \[\leadsto \]
    3. Simplified8.0

      \[\leadsto \]
    4. Taylor expanded around 0 8.6

      \[\leadsto \]
    5. Simplified4.8

      \[\leadsto \]
    6. Using strategy rm
    7. Applied associate-*r*0.7

      \[\leadsto \]
    8. Simplified0.7

      \[\leadsto \]
    9. Using strategy rm
    10. Applied distribute-rgt1-in0.7

      \[\leadsto \]
    11. Applied associate-*r*0.7

      \[\leadsto \]
    12. Simplified0.7

      \[\leadsto \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \]

Reproduce

herbie shell --seed 2020179 
(FPCore (a x)
  :name "expax (section 3.5)"
  :precision binary64
  :herbie-expected 14

  :herbie-target
  (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0))

  (- (exp (* a x)) 1.0))