Average Error: 3.4 → 0.1
Time: 3.1s
Precision: binary64
\[\]
\[\]
double code(double x, double y, double z) {
	return ((double) (x * ((double) (1.0 - ((double) (((double) (1.0 - y)) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((((double) (((double) (1.0 - y)) * z)) <= -3.2249253961681566e+196) || !(((double) (((double) (1.0 - y)) * z)) <= 7.300248578649677e+174))) {
		VAR = ((double) (((double) (1.0 * x)) + ((double) (((double) (z * x)) * ((double) (y - 1.0))))));
	} else {
		VAR = ((double) (((double) (1.0 * x)) + ((double) (x * ((double) (((double) (y * z)) - ((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

Original3.4
Target0.3
Herbie0.1
\[\]

Derivation

  1. Split input into 2 regimes
  2. if (* (- 1.0 y) z) < -3.22492539616815657e196 or 7.300248578649677e174 < (* (- 1.0 y) z)

    1. Initial program 16.3

      \[\]
    2. Using strategy rm
    3. Applied sub-neg16.3

      \[\leadsto \]
    4. Applied distribute-lft-in16.3

      \[\leadsto \]
    5. Simplified16.3

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

      \[\leadsto \]

    if -3.22492539616815657e196 < (* (- 1.0 y) z) < 7.300248578649677e174

    1. Initial program 0.1

      \[\]
    2. Using strategy rm
    3. Applied sub-neg0.1

      \[\leadsto \]
    4. Applied distribute-lft-in0.1

      \[\leadsto \]
    5. Simplified0.1

      \[\leadsto \]
    6. Using strategy rm
    7. Applied sub-neg0.1

      \[\leadsto \]
    8. Applied distribute-lft-in0.1

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
  :precision binary64

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (neg z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (neg z) x)))))

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