Average Error: 3.4 → 0.1
Time: 13.9s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot y\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}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r915885 = x;
        double r915886 = 1.0;
        double r915887 = y;
        double r915888 = r915886 - r915887;
        double r915889 = z;
        double r915890 = r915888 * r915889;
        double r915891 = r915886 - r915890;
        double r915892 = r915885 * r915891;
        return r915892;
}

double f(double x, double y, double z) {
        double r915893 = z;
        double r915894 = -3.5627093803727213e+52;
        bool r915895 = r915893 <= r915894;
        double r915896 = 56035482213991.22;
        bool r915897 = r915893 <= r915896;
        double r915898 = !r915897;
        bool r915899 = r915895 || r915898;
        double r915900 = x;
        double r915901 = 1.0;
        double r915902 = r915900 * r915901;
        double r915903 = r915900 * r915893;
        double r915904 = y;
        double r915905 = r915904 - r915901;
        double r915906 = r915903 * r915905;
        double r915907 = r915902 + r915906;
        double r915908 = r915893 * r915904;
        double r915909 = r915901 + r915908;
        double r915910 = r915900 * r915909;
        double r915911 = -r915901;
        double r915912 = r915903 * r915911;
        double r915913 = r915910 + r915912;
        double r915914 = r915899 ? r915907 : r915913;
        return r915914;
}

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
\[\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 z < -3.5627093803727213e+52 or 56035482213991.22 < z

    1. Initial program 10.1

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

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

      \[\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 -3.5627093803727213e+52 < z < 56035482213991.22

    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. Simplified2.3

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

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

      \[\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+2.3

      \[\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(1 + z \cdot y\right)} + \left(x \cdot z\right) \cdot \left(-1\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

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

Reproduce

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