Average Error: 3.6 → 0.2
Time: 3.0s
Precision: 64
\[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 -1.16375890301281403 \cdot 10^{44} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.04556621942801475 \cdot 10^{-82}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(x \cdot z\right) \cdot \left(-1\right)\\ \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 -1.16375890301281403 \cdot 10^{44} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.04556621942801475 \cdot 10^{-82}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r889162 = x;
        double r889163 = 1.0;
        double r889164 = y;
        double r889165 = r889163 - r889164;
        double r889166 = z;
        double r889167 = r889165 * r889166;
        double r889168 = r889163 - r889167;
        double r889169 = r889162 * r889168;
        return r889169;
}

double f(double x, double y, double z) {
        double r889170 = x;
        double r889171 = 1.0;
        double r889172 = y;
        double r889173 = r889171 - r889172;
        double r889174 = z;
        double r889175 = r889173 * r889174;
        double r889176 = r889171 - r889175;
        double r889177 = r889170 * r889176;
        double r889178 = -1.163758903012814e+44;
        bool r889179 = r889177 <= r889178;
        double r889180 = 6.045566219428015e-82;
        bool r889181 = r889177 <= r889180;
        double r889182 = !r889181;
        bool r889183 = r889179 || r889182;
        double r889184 = r889170 * r889171;
        double r889185 = r889170 * r889174;
        double r889186 = r889172 - r889171;
        double r889187 = r889185 * r889186;
        double r889188 = r889184 + r889187;
        double r889189 = r889174 * r889172;
        double r889190 = r889189 + r889171;
        double r889191 = r889170 * r889190;
        double r889192 = -r889171;
        double r889193 = r889185 * r889192;
        double r889194 = r889191 + r889193;
        double r889195 = r889183 ? r889188 : r889194;
        return r889195;
}

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.6
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 (* x (- 1.0 (* (- 1.0 y) z))) < -1.163758903012814e+44 or 6.045566219428015e-82 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 5.7

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

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

      \[\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)}\]

    if -1.163758903012814e+44 < (* x (- 1.0 (* (- 1.0 y) z))) < 6.045566219428015e-82

    1. Initial program 0.1

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied sub-neg4.2

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(x \cdot z\right) \cdot y + \left(x \cdot z\right) \cdot \left(-1\right)\right)}\]
    9. Applied associate-+r+4.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -1.16375890301281403 \cdot 10^{44} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.04556621942801475 \cdot 10^{-82}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(x \cdot z\right) \cdot \left(-1\right)\\ \end{array}\]

Reproduce

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