Average Error: 3.5 → 1.0
Time: 4.5s
Precision: binary64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.0626986475290302 \cdot 10^{218}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.3833224369737218 \cdot 10^{304}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(\left(x \cdot z\right) \cdot \sqrt{y - 1}\right) \cdot \sqrt{y - 1}\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.0626986475290302 \cdot 10^{218}:\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

\mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.3833224369737218 \cdot 10^{304}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 1 + \left(\left(x \cdot z\right) \cdot \sqrt{y - 1}\right) \cdot \sqrt{y - 1}\\

\end{array}
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) (x * ((double) (1.0 - ((double) (((double) (1.0 - y)) * z)))))) <= -7.06269864752903e+218)) {
		VAR = ((double) (((double) (x * 1.0)) + ((double) (((double) (x * z)) * ((double) (y - 1.0))))));
	} else {
		double VAR_1;
		if ((((double) (x * ((double) (1.0 - ((double) (((double) (1.0 - y)) * z)))))) <= 6.383322436973722e+304)) {
			VAR_1 = ((double) (x * ((double) (1.0 - ((double) (((double) (1.0 - y)) * z))))));
		} else {
			VAR_1 = ((double) (((double) (x * 1.0)) + ((double) (((double) (((double) (x * z)) * ((double) sqrt(((double) (y - 1.0)))))) * ((double) sqrt(((double) (y - 1.0))))))));
		}
		VAR = VAR_1;
	}
	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.5
Target0.2
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{50}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt 3.8922376496639029 \cdot 10^{134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* x (- 1.0 (* (- 1.0 y) z))) < -7.0626986475290302e218

    1. Initial program 16.3

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg16.3

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in16.3

      \[\leadsto \color{blue}{x \cdot 1 + x \cdot \left(-\left(1 - y\right) \cdot z\right)}\]
    5. Simplified0.1

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]

    if -7.0626986475290302e218 < (* x (- 1.0 (* (- 1.0 y) z))) < 6.3833224369737218e304

    1. Initial program 0.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]

    if 6.3833224369737218e304 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 54.9

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg54.9

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in54.9

      \[\leadsto \color{blue}{x \cdot 1 + x \cdot \left(-\left(1 - y\right) \cdot z\right)}\]
    5. Simplified0.3

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt32.3

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(\sqrt{y - 1} \cdot \sqrt{y - 1}\right)}\]
    8. Applied associate-*r*32.2

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(x \cdot z\right) \cdot \sqrt{y - 1}\right) \cdot \sqrt{y - 1}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.0626986475290302 \cdot 10^{218}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.3833224369737218 \cdot 10^{304}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(\left(x \cdot z\right) \cdot \sqrt{y - 1}\right) \cdot \sqrt{y - 1}\\ \end{array}\]

Reproduce

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