Average Error: 3.4 → 0.1
Time: 14.6s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) = -\infty:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + x \cdot 1.0\\ \mathbf{elif}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \le 2.1455752088136934 \cdot 10^{+93}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + x \cdot 1.0\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) = -\infty:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + x \cdot 1.0\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r38351604 = x;
        double r38351605 = 1.0;
        double r38351606 = y;
        double r38351607 = r38351605 - r38351606;
        double r38351608 = z;
        double r38351609 = r38351607 * r38351608;
        double r38351610 = r38351605 - r38351609;
        double r38351611 = r38351604 * r38351610;
        return r38351611;
}

double f(double x, double y, double z) {
        double r38351612 = x;
        double r38351613 = 1.0;
        double r38351614 = y;
        double r38351615 = r38351613 - r38351614;
        double r38351616 = z;
        double r38351617 = r38351615 * r38351616;
        double r38351618 = r38351613 - r38351617;
        double r38351619 = r38351612 * r38351618;
        double r38351620 = -inf.0;
        bool r38351621 = r38351619 <= r38351620;
        double r38351622 = r38351616 * r38351612;
        double r38351623 = r38351614 - r38351613;
        double r38351624 = r38351622 * r38351623;
        double r38351625 = r38351612 * r38351613;
        double r38351626 = r38351624 + r38351625;
        double r38351627 = 2.1455752088136934e+93;
        bool r38351628 = r38351619 <= r38351627;
        double r38351629 = r38351628 ? r38351619 : r38351626;
        double r38351630 = r38351621 ? r38351626 : r38351629;
        return r38351630;
}

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.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 (* x (- 1.0 (* (- 1.0 y) z))) < -inf.0 or 2.1455752088136934e+93 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 13.8

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

      \[\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.0

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

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

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

    if -inf.0 < (* x (- 1.0 (* (- 1.0 y) z))) < 2.1455752088136934e+93

    1. Initial program 0.1

      \[x \cdot \left(1.0 - \left(1.0 - 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.0 - \left(1.0 - y\right) \cdot z\right) = -\infty:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + x \cdot 1.0\\ \mathbf{elif}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \le 2.1455752088136934 \cdot 10^{+93}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + x \cdot 1.0\\ \end{array}\]

Reproduce

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