Average Error: 3.1 → 0.3
Time: 15.9s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.7171599342471754 \cdot 10^{+75}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 5.474649330783933 \cdot 10^{-139}:\\ \;\;\;\;1.0 \cdot x + \left(y \cdot x - 1.0 \cdot x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -2.7171599342471754 \cdot 10^{+75}:\\
\;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r40801372 = x;
        double r40801373 = 1.0;
        double r40801374 = y;
        double r40801375 = r40801373 - r40801374;
        double r40801376 = z;
        double r40801377 = r40801375 * r40801376;
        double r40801378 = r40801373 - r40801377;
        double r40801379 = r40801372 * r40801378;
        return r40801379;
}

double f(double x, double y, double z) {
        double r40801380 = x;
        double r40801381 = -2.7171599342471754e+75;
        bool r40801382 = r40801380 <= r40801381;
        double r40801383 = z;
        double r40801384 = y;
        double r40801385 = 1.0;
        double r40801386 = r40801384 - r40801385;
        double r40801387 = r40801383 * r40801386;
        double r40801388 = r40801387 * r40801380;
        double r40801389 = r40801385 * r40801380;
        double r40801390 = r40801388 + r40801389;
        double r40801391 = 5.474649330783933e-139;
        bool r40801392 = r40801380 <= r40801391;
        double r40801393 = r40801384 * r40801380;
        double r40801394 = r40801393 - r40801389;
        double r40801395 = r40801394 * r40801383;
        double r40801396 = r40801389 + r40801395;
        double r40801397 = r40801383 * r40801380;
        double r40801398 = r40801386 * r40801397;
        double r40801399 = r40801389 + r40801398;
        double r40801400 = r40801392 ? r40801396 : r40801399;
        double r40801401 = r40801382 ? r40801390 : r40801400;
        return r40801401;
}

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.1
Target0.2
Herbie0.3
\[\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 x < -2.7171599342471754e+75

    1. Initial program 0.1

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 0.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. Simplified10.9

      \[\leadsto \color{blue}{z \cdot \left(x \cdot y - 1.0 \cdot x\right) + 1.0 \cdot x}\]
    4. Taylor expanded around inf 0.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.1

      \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1.0\right)} + 1.0 \cdot x\]
    6. Using strategy rm
    7. Applied associate-*l*0.1

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

    if -2.7171599342471754e+75 < x < 5.474649330783933e-139

    1. Initial program 5.1

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 5.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}\]

    if 5.474649330783933e-139 < x

    1. Initial program 1.2

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

      \[\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. Simplified4.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.7171599342471754 \cdot 10^{+75}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 5.474649330783933 \cdot 10^{-139}:\\ \;\;\;\;1.0 \cdot x + \left(y \cdot x - 1.0 \cdot x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]

Reproduce

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