Average Error: 3.3 → 0.5
Time: 47.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.050645731720802115268344507513692974891 \cdot 10^{-19}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + y \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \le 1.48916113716272262092408564204582627696 \cdot 10^{172}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + \sqrt[3]{y} \cdot \left(\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot z\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + y \cdot \left(x \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -2.050645731720802115268344507513692974891 \cdot 10^{-19}:\\
\;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + y \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;z \le 1.48916113716272262092408564204582627696 \cdot 10^{172}:\\
\;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + \sqrt[3]{y} \cdot \left(\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot z\right) \cdot x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r36791441 = x;
        double r36791442 = 1.0;
        double r36791443 = y;
        double r36791444 = r36791442 - r36791443;
        double r36791445 = z;
        double r36791446 = r36791444 * r36791445;
        double r36791447 = r36791442 - r36791446;
        double r36791448 = r36791441 * r36791447;
        return r36791448;
}

double f(double x, double y, double z) {
        double r36791449 = z;
        double r36791450 = -2.050645731720802e-19;
        bool r36791451 = r36791449 <= r36791450;
        double r36791452 = 1.0;
        double r36791453 = r36791452 * r36791449;
        double r36791454 = r36791452 - r36791453;
        double r36791455 = x;
        double r36791456 = r36791454 * r36791455;
        double r36791457 = y;
        double r36791458 = r36791455 * r36791449;
        double r36791459 = r36791457 * r36791458;
        double r36791460 = r36791456 + r36791459;
        double r36791461 = 1.4891611371627226e+172;
        bool r36791462 = r36791449 <= r36791461;
        double r36791463 = cbrt(r36791457);
        double r36791464 = r36791463 * r36791463;
        double r36791465 = r36791464 * r36791449;
        double r36791466 = r36791465 * r36791455;
        double r36791467 = r36791463 * r36791466;
        double r36791468 = r36791456 + r36791467;
        double r36791469 = r36791462 ? r36791468 : r36791460;
        double r36791470 = r36791451 ? r36791460 : r36791469;
        return r36791470;
}

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.3
Target0.2
Herbie0.5
\[\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 2 regimes
  2. if z < -2.050645731720802e-19 or 1.4891611371627226e+172 < z

    1. Initial program 9.3

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

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

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

    if -2.050645731720802e-19 < z < 1.4891611371627226e+172

    1. Initial program 1.0

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

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

      \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot y + x \cdot \left(1 - z \cdot 1\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt2.2

      \[\leadsto \left(x \cdot z\right) \cdot \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}\right)} + x \cdot \left(1 - z \cdot 1\right)\]
    6. Applied associate-*r*2.3

      \[\leadsto \color{blue}{\left(\left(x \cdot z\right) \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right) \cdot \sqrt[3]{y}} + x \cdot \left(1 - z \cdot 1\right)\]
    7. Using strategy rm
    8. Applied associate-*l*0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.050645731720802115268344507513692974891 \cdot 10^{-19}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + y \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \le 1.48916113716272262092408564204582627696 \cdot 10^{172}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + \sqrt[3]{y} \cdot \left(\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot z\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - 1 \cdot z\right) \cdot x + y \cdot \left(x \cdot z\right)\\ \end{array}\]

Reproduce

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