Average Error: 2.9 → 0.1
Time: 13.9s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1.0 - y\right) \cdot z = -\infty:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;\left(1.0 - y\right) \cdot z \le 2.6159144216759665 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x - x \cdot 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}\;\left(1.0 - y\right) \cdot z = -\infty:\\
\;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r40995412 = x;
        double r40995413 = 1.0;
        double r40995414 = y;
        double r40995415 = r40995413 - r40995414;
        double r40995416 = z;
        double r40995417 = r40995415 * r40995416;
        double r40995418 = r40995413 - r40995417;
        double r40995419 = r40995412 * r40995418;
        return r40995419;
}

double f(double x, double y, double z) {
        double r40995420 = 1.0;
        double r40995421 = y;
        double r40995422 = r40995420 - r40995421;
        double r40995423 = z;
        double r40995424 = r40995422 * r40995423;
        double r40995425 = -inf.0;
        bool r40995426 = r40995424 <= r40995425;
        double r40995427 = x;
        double r40995428 = r40995427 * r40995420;
        double r40995429 = r40995421 - r40995420;
        double r40995430 = r40995423 * r40995427;
        double r40995431 = r40995429 * r40995430;
        double r40995432 = r40995428 + r40995431;
        double r40995433 = 2.6159144216759665e+212;
        bool r40995434 = r40995424 <= r40995433;
        double r40995435 = r40995420 - r40995424;
        double r40995436 = r40995427 * r40995435;
        double r40995437 = r40995421 * r40995427;
        double r40995438 = r40995437 - r40995428;
        double r40995439 = r40995423 * r40995438;
        double r40995440 = r40995439 + r40995428;
        double r40995441 = r40995434 ? r40995436 : r40995440;
        double r40995442 = r40995426 ? r40995432 : r40995441;
        return r40995442;
}

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

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

    1. Initial program 60.1

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

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

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

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

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

    if -inf.0 < (* (- 1.0 y) z) < 2.6159144216759665e+212

    1. Initial program 0.1

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

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

    if 2.6159144216759665e+212 < (* (- 1.0 y) z)

    1. Initial program 18.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1.0 - y\right) \cdot z = -\infty:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;\left(1.0 - y\right) \cdot z \le 2.6159144216759665 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x - x \cdot 1.0\right) + x \cdot 1.0\\ \end{array}\]

Reproduce

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