Average Error: 3.4 → 0.1
Time: 3.6s
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.1711120102804009 \cdot 10^{-63} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 4.2801093120863509 \cdot 10^{23}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\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.1711120102804009 \cdot 10^{-63} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 4.2801093120863509 \cdot 10^{23}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r816701 = x;
        double r816702 = 1.0;
        double r816703 = y;
        double r816704 = r816702 - r816703;
        double r816705 = z;
        double r816706 = r816704 * r816705;
        double r816707 = r816702 - r816706;
        double r816708 = r816701 * r816707;
        return r816708;
}

double f(double x, double y, double z) {
        double r816709 = x;
        double r816710 = 1.0;
        double r816711 = y;
        double r816712 = r816710 - r816711;
        double r816713 = z;
        double r816714 = r816712 * r816713;
        double r816715 = r816710 - r816714;
        double r816716 = r816709 * r816715;
        double r816717 = -1.1711120102804009e-63;
        bool r816718 = r816716 <= r816717;
        double r816719 = 4.280109312086351e+23;
        bool r816720 = r816716 <= r816719;
        double r816721 = !r816720;
        bool r816722 = r816718 || r816721;
        double r816723 = r816709 * r816710;
        double r816724 = r816709 * r816713;
        double r816725 = r816711 - r816710;
        double r816726 = r816724 * r816725;
        double r816727 = r816723 + r816726;
        double r816728 = r816722 ? r816727 : r816716;
        return r816728;
}

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.2
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 (* x (- 1.0 (* (- 1.0 y) z))) < -1.1711120102804009e-63 or 4.280109312086351e+23 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 5.3

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

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

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

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

    if -1.1711120102804009e-63 < (* x (- 1.0 (* (- 1.0 y) z))) < 4.280109312086351e+23

    1. Initial program 0.1

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

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

Reproduce

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