Average Error: 3.4 → 0.2
Time: 18.6s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r711972 = x;
        double r711973 = 1.0;
        double r711974 = y;
        double r711975 = r711973 - r711974;
        double r711976 = z;
        double r711977 = r711975 * r711976;
        double r711978 = r711973 - r711977;
        double r711979 = r711972 * r711978;
        return r711979;
}

double f(double x, double y, double z) {
        double r711980 = 1.0;
        double r711981 = y;
        double r711982 = r711980 - r711981;
        double r711983 = z;
        double r711984 = r711982 * r711983;
        double r711985 = -4.721654532789329e+174;
        bool r711986 = r711984 <= r711985;
        double r711987 = 1.4508199093501263e+148;
        bool r711988 = r711984 <= r711987;
        double r711989 = !r711988;
        bool r711990 = r711986 || r711989;
        double r711991 = x;
        double r711992 = r711991 * r711980;
        double r711993 = r711991 * r711983;
        double r711994 = r711981 - r711980;
        double r711995 = r711993 * r711994;
        double r711996 = r711992 + r711995;
        double r711997 = r711980 - r711984;
        double r711998 = r711991 * r711997;
        double r711999 = r711990 ? r711996 : r711998;
        return r711999;
}

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.2
Herbie0.2
\[\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 2 regimes
  2. if (* (- 1.0 y) z) < -4.721654532789329e+174 or 1.4508199093501263e+148 < (* (- 1.0 y) z)

    1. Initial program 14.4

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

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

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

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

    if -4.721654532789329e+174 < (* (- 1.0 y) z) < 1.4508199093501263e+148

    1. Initial program 0.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]

Reproduce

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

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

  (* x (- 1 (* (- 1 y) z))))