Average Error: 3.8 → 0.4
Time: 38.5s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.607080134200986 \cdot 10^{-126}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\\ \mathbf{elif}\;z \le 8.604071023782878 \cdot 10^{-36}:\\ \;\;\;\;x \cdot \left(y \cdot z - 1.0 \cdot z\right) + 1.0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -1.607080134200986 \cdot 10^{-126}:\\
\;\;\;\;1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\\

\mathbf{elif}\;z \le 8.604071023782878 \cdot 10^{-36}:\\
\;\;\;\;x \cdot \left(y \cdot z - 1.0 \cdot z\right) + 1.0 \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r37853758 = x;
        double r37853759 = 1.0;
        double r37853760 = y;
        double r37853761 = r37853759 - r37853760;
        double r37853762 = z;
        double r37853763 = r37853761 * r37853762;
        double r37853764 = r37853759 - r37853763;
        double r37853765 = r37853758 * r37853764;
        return r37853765;
}

double f(double x, double y, double z) {
        double r37853766 = z;
        double r37853767 = -1.607080134200986e-126;
        bool r37853768 = r37853766 <= r37853767;
        double r37853769 = 1.0;
        double r37853770 = x;
        double r37853771 = r37853769 * r37853770;
        double r37853772 = r37853770 * r37853766;
        double r37853773 = y;
        double r37853774 = r37853773 - r37853769;
        double r37853775 = r37853772 * r37853774;
        double r37853776 = r37853771 + r37853775;
        double r37853777 = 8.604071023782878e-36;
        bool r37853778 = r37853766 <= r37853777;
        double r37853779 = r37853773 * r37853766;
        double r37853780 = r37853769 * r37853766;
        double r37853781 = r37853779 - r37853780;
        double r37853782 = r37853770 * r37853781;
        double r37853783 = r37853782 + r37853771;
        double r37853784 = r37853778 ? r37853783 : r37853776;
        double r37853785 = r37853768 ? r37853776 : r37853784;
        return r37853785;
}

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.8
Target0.2
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.607080134200986e-126 or 8.604071023782878e-36 < z

    1. Initial program 6.9

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

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

      \[\leadsto \color{blue}{1.0 \cdot x + x \cdot \left(z \cdot y - 1.0 \cdot z\right)}\]
    4. Taylor expanded around inf 6.9

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

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

    if -1.607080134200986e-126 < z < 8.604071023782878e-36

    1. Initial program 0.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.607080134200986 \cdot 10^{-126}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\\ \mathbf{elif}\;z \le 8.604071023782878 \cdot 10^{-36}:\\ \;\;\;\;x \cdot \left(y \cdot z - 1.0 \cdot z\right) + 1.0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\\ \end{array}\]

Reproduce

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