Average Error: 30.0 → 0.4
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)) <= -6.685306244171875e-06)) {
		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

Original30.0
Target0.1
Herbie0.4
\[\]

Derivation

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

    1. Initial program 0.1

      \[\]

    if -6.685306244171875e-6 < (* a x)

    1. Initial program 44.8

      \[\]
    2. Taylor expanded around 0 14.1

      \[\leadsto \]
    3. Simplified7.7

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

      \[\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 2020190 
(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))