Average Error: 3.4 → 0.1
Time: 18.2s
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) = -\infty:\\ \;\;\;\;z \cdot \left(x \cdot y - x \cdot 1\right) + x \cdot 1\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 9.315294676975161914170286969749668060103 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - 1\right) \cdot \left(z \cdot x\right) + x \cdot 1\\ \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) = -\infty:\\
\;\;\;\;z \cdot \left(x \cdot y - x \cdot 1\right) + x \cdot 1\\

\mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 9.315294676975161914170286969749668060103 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r40006396 = x;
        double r40006397 = 1.0;
        double r40006398 = y;
        double r40006399 = r40006397 - r40006398;
        double r40006400 = z;
        double r40006401 = r40006399 * r40006400;
        double r40006402 = r40006397 - r40006401;
        double r40006403 = r40006396 * r40006402;
        return r40006403;
}

double f(double x, double y, double z) {
        double r40006404 = x;
        double r40006405 = 1.0;
        double r40006406 = y;
        double r40006407 = r40006405 - r40006406;
        double r40006408 = z;
        double r40006409 = r40006407 * r40006408;
        double r40006410 = r40006405 - r40006409;
        double r40006411 = r40006404 * r40006410;
        double r40006412 = -inf.0;
        bool r40006413 = r40006411 <= r40006412;
        double r40006414 = r40006404 * r40006406;
        double r40006415 = r40006404 * r40006405;
        double r40006416 = r40006414 - r40006415;
        double r40006417 = r40006408 * r40006416;
        double r40006418 = r40006417 + r40006415;
        double r40006419 = 9.315294676975162e-05;
        bool r40006420 = r40006411 <= r40006419;
        double r40006421 = r40006406 - r40006405;
        double r40006422 = r40006408 * r40006404;
        double r40006423 = r40006421 * r40006422;
        double r40006424 = r40006423 + r40006415;
        double r40006425 = r40006420 ? r40006411 : r40006424;
        double r40006426 = r40006413 ? r40006418 : r40006425;
        return r40006426;
}

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.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 3 regimes
  2. if (* x (- 1.0 (* (- 1.0 y) z))) < -inf.0

    1. Initial program 64.0

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

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

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

    if -inf.0 < (* x (- 1.0 (* (- 1.0 y) z))) < 9.315294676975162e-05

    1. Initial program 0.1

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

    if 9.315294676975162e-05 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 5.1

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

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

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

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

      \[\leadsto 1 \cdot x + \color{blue}{\left(z \cdot x\right) \cdot \left(y - 1\right)}\]
  3. Recombined 3 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) = -\infty:\\ \;\;\;\;z \cdot \left(x \cdot y - x \cdot 1\right) + x \cdot 1\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 9.315294676975161914170286969749668060103 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - 1\right) \cdot \left(z \cdot x\right) + x \cdot 1\\ \end{array}\]

Reproduce

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