Average Error: 3.6 → 0.4
Time: 4.2s
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 3.5008624442891087 \cdot 10^{-96}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot \left(z \cdot y\right) + \left(x \cdot z\right) \cdot \left(-1\right)\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 3.5008624442891087 \cdot 10^{-96}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r809438 = x;
        double r809439 = 1.0;
        double r809440 = y;
        double r809441 = r809439 - r809440;
        double r809442 = z;
        double r809443 = r809441 * r809442;
        double r809444 = r809439 - r809443;
        double r809445 = r809438 * r809444;
        return r809445;
}

double f(double x, double y, double z) {
        double r809446 = z;
        double r809447 = -5.928829482005966e+90;
        bool r809448 = r809446 <= r809447;
        double r809449 = 3.5008624442891087e-96;
        bool r809450 = r809446 <= r809449;
        double r809451 = !r809450;
        bool r809452 = r809448 || r809451;
        double r809453 = x;
        double r809454 = 1.0;
        double r809455 = r809453 * r809454;
        double r809456 = r809453 * r809446;
        double r809457 = y;
        double r809458 = r809457 - r809454;
        double r809459 = r809456 * r809458;
        double r809460 = r809455 + r809459;
        double r809461 = r809446 * r809457;
        double r809462 = r809453 * r809461;
        double r809463 = -r809454;
        double r809464 = r809456 * r809463;
        double r809465 = r809462 + r809464;
        double r809466 = r809455 + r809465;
        double r809467 = r809452 ? r809460 : r809466;
        return r809467;
}

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.4
\[\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 3.5008624442891087e-96 < z

    1. Initial program 8.2

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

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

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

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

    if -5.928829482005966e+90 < z < 3.5008624442891087e-96

    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. Simplified0.4

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

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(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))))