Average Error: 10.4 → 0.1
Time: 3.0s
Precision: binary64
\[\]
\[\]
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (((double) (y - z)) + 1.0)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((z <= -1131976122.9438014) || !(z <= 3.883515823559066e-33))) {
		VAR = ((double) (((double) (x * ((double) (((double) (y + 1.0)) / z)))) - x));
	} else {
		VAR = ((double) (((double) (x * ((double) (1.0 + ((double) (y - z)))))) / 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

Original10.4
Target0.4
Herbie0.1
\[\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1131976122.9438014 or 3.88351582355906611e-33 < z

    1. Initial program 16.7

      \[\]
    2. Simplified0.1

      \[\leadsto \]

    if -1131976122.9438014 < z < 3.88351582355906611e-33

    1. Initial program 0.1

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))

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