Average Error: 3.6 → 0.3
Time: 18.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\ \;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1\right) \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 -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\
\;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r929448 = x;
        double r929449 = 1.0;
        double r929450 = y;
        double r929451 = r929449 - r929450;
        double r929452 = z;
        double r929453 = r929451 * r929452;
        double r929454 = r929449 - r929453;
        double r929455 = r929448 * r929454;
        return r929455;
}

double f(double x, double y, double z) {
        double r929456 = z;
        double r929457 = -5.928829482005966e+90;
        bool r929458 = r929456 <= r929457;
        double r929459 = 2.1856788904363955e-58;
        bool r929460 = r929456 <= r929459;
        double r929461 = !r929460;
        bool r929462 = r929458 || r929461;
        double r929463 = x;
        double r929464 = 1.0;
        double r929465 = r929463 * r929464;
        double r929466 = y;
        double r929467 = r929463 * r929456;
        double r929468 = r929466 * r929467;
        double r929469 = -r929464;
        double r929470 = r929469 * r929467;
        double r929471 = r929468 + r929470;
        double r929472 = r929465 + r929471;
        double r929473 = r929456 * r929466;
        double r929474 = r929473 + r929464;
        double r929475 = r929463 * r929474;
        double r929476 = r929475 + r929470;
        double r929477 = r929462 ? r929472 : r929476;
        return r929477;
}

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.6
Target0.2
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607049 \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.8922376496639029 \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 < -5.928829482005966e+90 or 2.1856788904363955e-58 < z

    1. Initial program 9.0

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg9.0

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in9.0

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied sub-neg0.2

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}\]
    8. Applied distribute-lft-in0.2

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

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

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

    if -5.928829482005966e+90 < z < 2.1856788904363955e-58

    1. Initial program 0.4

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg0.4

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in0.4

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied sub-neg2.6

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}\]
    8. Applied distribute-lft-in2.6

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

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

      \[\leadsto x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \color{blue}{\left(-1\right) \cdot \left(x \cdot z\right)}\right)\]
    11. Using strategy rm
    12. Applied associate-+r+2.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\ \;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1\right) \cdot \left(x \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
  :precision binary64

  :herbie-target
  (if (< (* x (- 1 (* (- 1 y) z))) -1.618195973607049e+50) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x)))))

  (* x (- 1 (* (- 1 y) z))))