Average Error: 3.2 → 0.1
Time: 12.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -125543025.69646199047565460205078125 \lor \neg \left(z \le 4.064178163898853502207711971952432317481 \cdot 10^{-41}\right):\\ \;\;\;\;x \cdot 1 + \left(\left(x \cdot z\right) \cdot y + \left(-x \cdot \left(1 \cdot z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot \left(y - 1\right)\right) + x \cdot 1\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -125543025.69646199047565460205078125 \lor \neg \left(z \le 4.064178163898853502207711971952432317481 \cdot 10^{-41}\right):\\
\;\;\;\;x \cdot 1 + \left(\left(x \cdot z\right) \cdot y + \left(-x \cdot \left(1 \cdot z\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r632689 = x;
        double r632690 = 1.0;
        double r632691 = y;
        double r632692 = r632690 - r632691;
        double r632693 = z;
        double r632694 = r632692 * r632693;
        double r632695 = r632690 - r632694;
        double r632696 = r632689 * r632695;
        return r632696;
}

double f(double x, double y, double z) {
        double r632697 = z;
        double r632698 = -125543025.69646199;
        bool r632699 = r632697 <= r632698;
        double r632700 = 4.0641781638988535e-41;
        bool r632701 = r632697 <= r632700;
        double r632702 = !r632701;
        bool r632703 = r632699 || r632702;
        double r632704 = x;
        double r632705 = 1.0;
        double r632706 = r632704 * r632705;
        double r632707 = r632704 * r632697;
        double r632708 = y;
        double r632709 = r632707 * r632708;
        double r632710 = r632705 * r632697;
        double r632711 = r632704 * r632710;
        double r632712 = -r632711;
        double r632713 = r632709 + r632712;
        double r632714 = r632706 + r632713;
        double r632715 = r632708 - r632705;
        double r632716 = r632697 * r632715;
        double r632717 = r632704 * r632716;
        double r632718 = r632717 + r632706;
        double r632719 = r632703 ? r632714 : r632718;
        return r632719;
}

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.2
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 2 regimes
  2. if z < -125543025.69646199 or 4.0641781638988535e-41 < z

    1. Initial program 7.3

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 7.3

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

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

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

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

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

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

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

    if -125543025.69646199 < z < 4.0641781638988535e-41

    1. Initial program 0.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 0.1

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

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

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

Reproduce

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