Average Error: 3.3 → 0.1
Time: 16.9s
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 -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\ \;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 1.244138311537022482981088382979488875058 \cdot 10^{242}:\\ \;\;\;\;\left(1 - \left(1 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + z \cdot \left(x \cdot \left(y - 1\right)\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 -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\
\;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r38360858 = x;
        double r38360859 = 1.0;
        double r38360860 = y;
        double r38360861 = r38360859 - r38360860;
        double r38360862 = z;
        double r38360863 = r38360861 * r38360862;
        double r38360864 = r38360859 - r38360863;
        double r38360865 = r38360858 * r38360864;
        return r38360865;
}

double f(double x, double y, double z) {
        double r38360866 = 1.0;
        double r38360867 = y;
        double r38360868 = r38360866 - r38360867;
        double r38360869 = z;
        double r38360870 = r38360868 * r38360869;
        double r38360871 = -9.99257424762756e+187;
        bool r38360872 = r38360870 <= r38360871;
        double r38360873 = x;
        double r38360874 = r38360873 * r38360866;
        double r38360875 = r38360869 * r38360873;
        double r38360876 = r38360867 - r38360866;
        double r38360877 = r38360875 * r38360876;
        double r38360878 = r38360874 + r38360877;
        double r38360879 = 1.2441383115370225e+242;
        bool r38360880 = r38360870 <= r38360879;
        double r38360881 = r38360866 - r38360870;
        double r38360882 = r38360881 * r38360873;
        double r38360883 = r38360873 * r38360876;
        double r38360884 = r38360869 * r38360883;
        double r38360885 = r38360874 + r38360884;
        double r38360886 = r38360880 ? r38360882 : r38360885;
        double r38360887 = r38360872 ? r38360878 : r38360886;
        return r38360887;
}

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.3
Target0.3
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607048970493874632750554853795 \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.892237649663902900973248011051357504727 \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 (* (- 1.0 y) z) < -9.99257424762756e+187

    1. Initial program 15.4

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

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

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

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

    if -9.99257424762756e+187 < (* (- 1.0 y) z) < 1.2441383115370225e+242

    1. Initial program 0.1

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

    if 1.2441383115370225e+242 < (* (- 1.0 y) z)

    1. Initial program 24.8

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

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

      \[\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(z \cdot x\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied associate-*l*0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\ \;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 1.244138311537022482981088382979488875058 \cdot 10^{242}:\\ \;\;\;\;\left(1 - \left(1 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + z \cdot \left(x \cdot \left(y - 1\right)\right)\\ \end{array}\]

Reproduce

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

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

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