Average Error: 3.4 → 0.1
Time: 18.3s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot y\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 -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r923495 = x;
        double r923496 = 1.0;
        double r923497 = y;
        double r923498 = r923496 - r923497;
        double r923499 = z;
        double r923500 = r923498 * r923499;
        double r923501 = r923496 - r923500;
        double r923502 = r923495 * r923501;
        return r923502;
}

double f(double x, double y, double z) {
        double r923503 = z;
        double r923504 = -3.5627093803727213e+52;
        bool r923505 = r923503 <= r923504;
        double r923506 = 56035482213991.22;
        bool r923507 = r923503 <= r923506;
        double r923508 = !r923507;
        bool r923509 = r923505 || r923508;
        double r923510 = x;
        double r923511 = 1.0;
        double r923512 = r923510 * r923511;
        double r923513 = r923510 * r923503;
        double r923514 = y;
        double r923515 = r923514 - r923511;
        double r923516 = r923513 * r923515;
        double r923517 = r923512 + r923516;
        double r923518 = r923503 * r923514;
        double r923519 = r923511 + r923518;
        double r923520 = r923510 * r923519;
        double r923521 = -r923511;
        double r923522 = r923521 * r923513;
        double r923523 = r923520 + r923522;
        double r923524 = r923509 ? r923517 : r923523;
        return r923524;
}

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.4
Target0.3
Herbie0.1
\[\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 < -3.5627093803727213e+52 or 56035482213991.22 < z

    1. Initial program 10.1

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

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

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

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

    if -3.5627093803727213e+52 < z < 56035482213991.22

    1. Initial program 0.1

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

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

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

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

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

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

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

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

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

Reproduce

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