Average Error: 3.3 → 0.1
Time: 17.8s
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}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \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}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

\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 r59569036 = x;
        double r59569037 = 1.0;
        double r59569038 = y;
        double r59569039 = r59569037 - r59569038;
        double r59569040 = z;
        double r59569041 = r59569039 * r59569040;
        double r59569042 = r59569037 - r59569041;
        double r59569043 = r59569036 * r59569042;
        return r59569043;
}

double f(double x, double y, double z) {
        double r59569044 = 1.0;
        double r59569045 = y;
        double r59569046 = r59569044 - r59569045;
        double r59569047 = z;
        double r59569048 = r59569046 * r59569047;
        double r59569049 = -9.99257424762756e+187;
        bool r59569050 = r59569048 <= r59569049;
        double r59569051 = x;
        double r59569052 = r59569051 * r59569044;
        double r59569053 = r59569047 * r59569051;
        double r59569054 = r59569045 - r59569044;
        double r59569055 = r59569053 * r59569054;
        double r59569056 = r59569052 + r59569055;
        double r59569057 = 1.2441383115370225e+242;
        bool r59569058 = r59569048 <= r59569057;
        double r59569059 = r59569044 - r59569048;
        double r59569060 = r59569051 * r59569059;
        double r59569061 = r59569051 * r59569054;
        double r59569062 = r59569047 * r59569061;
        double r59569063 = r59569052 + r59569062;
        double r59569064 = r59569058 ? r59569060 : r59569063;
        double r59569065 = r59569050 ? r59569056 : r59569064;
        return r59569065;
}

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}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \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))))