Average Error: 3.6 → 1.8
Time: 13.0s
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 1.1945884688446095 \cdot 10^{159}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot \left(1 - y\right)\right) \cdot \left(-z\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 1.1945884688446095 \cdot 10^{159}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r1487757 = x;
        double r1487758 = 1.0;
        double r1487759 = y;
        double r1487760 = r1487758 - r1487759;
        double r1487761 = z;
        double r1487762 = r1487760 * r1487761;
        double r1487763 = r1487758 - r1487762;
        double r1487764 = r1487757 * r1487763;
        return r1487764;
}

double f(double x, double y, double z) {
        double r1487765 = 1.0;
        double r1487766 = y;
        double r1487767 = r1487765 - r1487766;
        double r1487768 = z;
        double r1487769 = r1487767 * r1487768;
        double r1487770 = 1.1945884688446095e+159;
        bool r1487771 = r1487769 <= r1487770;
        double r1487772 = x;
        double r1487773 = r1487765 - r1487769;
        double r1487774 = r1487772 * r1487773;
        double r1487775 = r1487772 * r1487765;
        double r1487776 = r1487772 * r1487767;
        double r1487777 = -r1487768;
        double r1487778 = r1487776 * r1487777;
        double r1487779 = r1487775 + r1487778;
        double r1487780 = r1487771 ? r1487774 : r1487779;
        return r1487780;
}

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.6
Target0.2
Herbie1.8
\[\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 (* (- 1.0 y) z) < 1.1945884688446095e+159

    1. Initial program 1.9

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

    if 1.1945884688446095e+159 < (* (- 1.0 y) z)

    1. Initial program 15.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt15.5

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \sqrt[3]{1 - y}\right)} \cdot z\right)\]
    4. Applied associate-*l*15.5

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

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

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

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

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

Reproduce

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