Average Error: 12.5 → 1.9
Time: 3.0s
Precision: binary64
\[\]
\[\]
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y + z)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((((double) (((double) (x * ((double) (y + z)))) / z)) <= -1.0941573754303678e+301) || !(((double) (((double) (x * ((double) (y + z)))) / z)) <= -9.191605125197159e+72))) {
		VAR = ((double) (x + ((double) (x * ((double) (y / z))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (x * y)) * ((double) (1.0 / z))))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.5
Target3.0
Herbie1.9
\[\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -1.0941573754303678e301 or -9.1916051251971588e72 < (/ (* x (+ y z)) z)

    1. Initial program 14.7

      \[\]
    2. Simplified2.2

      \[\leadsto \]

    if -1.0941573754303678e301 < (/ (* x (+ y z)) z) < -9.1916051251971588e72

    1. Initial program 0.2

      \[\]
    2. Simplified9.5

      \[\leadsto \]
    3. Using strategy rm
    4. Applied div-inv9.5

      \[\leadsto \]
    5. Applied associate-*r*0.2

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))