Average Error: 3.3 → 0.1
Time: 11.9s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\ \;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 1.244138311537022482981088382979488875058 \cdot 10^{242}:\\ \;\;\;\;\left(1 - \left(1 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot \left(y \cdot x\right) + \left(-1\right) \cdot \left(z \cdot x\right)\right) + x \cdot 1\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \le -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\
\;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r921378 = x;
        double r921379 = 1.0;
        double r921380 = y;
        double r921381 = r921379 - r921380;
        double r921382 = z;
        double r921383 = r921381 * r921382;
        double r921384 = r921379 - r921383;
        double r921385 = r921378 * r921384;
        return r921385;
}

double f(double x, double y, double z) {
        double r921386 = 1.0;
        double r921387 = y;
        double r921388 = r921386 - r921387;
        double r921389 = z;
        double r921390 = r921388 * r921389;
        double r921391 = -9.99257424762756e+187;
        bool r921392 = r921390 <= r921391;
        double r921393 = x;
        double r921394 = r921393 * r921386;
        double r921395 = r921389 * r921393;
        double r921396 = r921387 - r921386;
        double r921397 = r921395 * r921396;
        double r921398 = r921394 + r921397;
        double r921399 = 1.2441383115370225e+242;
        bool r921400 = r921390 <= r921399;
        double r921401 = r921386 - r921390;
        double r921402 = r921401 * r921393;
        double r921403 = r921387 * r921393;
        double r921404 = r921389 * r921403;
        double r921405 = -r921386;
        double r921406 = r921405 * r921395;
        double r921407 = r921404 + r921406;
        double r921408 = r921407 + r921394;
        double r921409 = r921400 ? r921402 : r921408;
        double r921410 = r921392 ? r921398 : r921409;
        return r921410;
}

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.3
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 (* (- 1.0 y) z) < -9.99257424762756e+187

    1. Initial program 15.4

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

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

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

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

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

    if -9.99257424762756e+187 < (* (- 1.0 y) z) < 1.2441383115370225e+242

    1. Initial program 0.1

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

    if 1.2441383115370225e+242 < (* (- 1.0 y) z)

    1. Initial program 24.8

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -9.992574247627560091858951880652586487745 \cdot 10^{187}:\\ \;\;\;\;x \cdot 1 + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 1.244138311537022482981088382979488875058 \cdot 10^{242}:\\ \;\;\;\;\left(1 - \left(1 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot \left(y \cdot x\right) + \left(-1\right) \cdot \left(z \cdot x\right)\right) + x \cdot 1\\ \end{array}\]

Reproduce

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