Average Error: 29.2 → 0.4
Time: 3.0s
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.0003443200474434158)) {
		VAR = ((double) (((double) exp(((double) (a * x)))) - 1.0));
	} else {
		VAR = ((double) (((double) (a * x)) + ((double) (a * ((double) (x * ((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.2
Target0.2
Herbie0.4
\[\]

Derivation

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

    1. Initial program 0.0

      \[\]

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

    1. Initial program 44.4

      \[\]
    2. Taylor expanded around 0 14.4

      \[\leadsto \]
    3. Simplified8.0

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

      \[\leadsto \]
    5. Simplified4.4

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

      \[\leadsto \]
    8. Simplified0.5

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

    \[\leadsto \]

Reproduce

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