Average Error: 3.5 → 0.2
Time: 12.2s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.97935724292898741 \cdot 10^{-117} \lor \neg \left(x \le 2.02073659466729 \cdot 10^{-115}\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 1 + \left(\left(y \cdot x\right) \cdot z + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -2.97935724292898741 \cdot 10^{-117} \lor \neg \left(x \le 2.02073659466729 \cdot 10^{-115}\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 1 + \left(\left(y \cdot x\right) \cdot z + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r825497 = x;
        double r825498 = 1.0;
        double r825499 = y;
        double r825500 = r825498 - r825499;
        double r825501 = z;
        double r825502 = r825500 * r825501;
        double r825503 = r825498 - r825502;
        double r825504 = r825497 * r825503;
        return r825504;
}

double f(double x, double y, double z) {
        double r825505 = x;
        double r825506 = -2.9793572429289874e-117;
        bool r825507 = r825505 <= r825506;
        double r825508 = 2.0207365946672857e-115;
        bool r825509 = r825505 <= r825508;
        double r825510 = !r825509;
        bool r825511 = r825507 || r825510;
        double r825512 = 1.0;
        double r825513 = r825505 * r825512;
        double r825514 = y;
        double r825515 = z;
        double r825516 = r825505 * r825515;
        double r825517 = r825514 * r825516;
        double r825518 = -r825512;
        double r825519 = r825518 * r825516;
        double r825520 = r825517 + r825519;
        double r825521 = r825513 + r825520;
        double r825522 = r825514 * r825505;
        double r825523 = r825522 * r825515;
        double r825524 = r825523 + r825519;
        double r825525 = r825513 + r825524;
        double r825526 = r825511 ? r825521 : r825525;
        return r825526;
}

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.5
Target0.2
Herbie0.2
\[\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 x < -2.9793572429289874e-117 or 2.0207365946672857e-115 < x

    1. Initial program 1.1

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

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

      \[\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 -2.9793572429289874e-117 < x < 2.0207365946672857e-115

    1. Initial program 7.5

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

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

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

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

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

      \[\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. Simplified3.9

      \[\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. Simplified3.9

      \[\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*0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.97935724292898741 \cdot 10^{-117} \lor \neg \left(x \le 2.02073659466729 \cdot 10^{-115}\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 1 + \left(\left(y \cdot x\right) \cdot z + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \end{array}\]

Reproduce

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