Average Error: 3.4 → 0.1
Time: 2.6s
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 -1.28749435279069585 \cdot 10^{267} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.4322306713169816 \cdot 10^{215}\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}\;\left(1 - y\right) \cdot z \le -1.28749435279069585 \cdot 10^{267} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.4322306713169816 \cdot 10^{215}\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 r887037 = x;
        double r887038 = 1.0;
        double r887039 = y;
        double r887040 = r887038 - r887039;
        double r887041 = z;
        double r887042 = r887040 * r887041;
        double r887043 = r887038 - r887042;
        double r887044 = r887037 * r887043;
        return r887044;
}

double f(double x, double y, double z) {
        double r887045 = 1.0;
        double r887046 = y;
        double r887047 = r887045 - r887046;
        double r887048 = z;
        double r887049 = r887047 * r887048;
        double r887050 = -1.2874943527906958e+267;
        bool r887051 = r887049 <= r887050;
        double r887052 = 1.4322306713169816e+215;
        bool r887053 = r887049 <= r887052;
        double r887054 = !r887053;
        bool r887055 = r887051 || r887054;
        double r887056 = x;
        double r887057 = r887056 * r887045;
        double r887058 = r887056 * r887048;
        double r887059 = r887046 - r887045;
        double r887060 = r887058 * r887059;
        double r887061 = r887057 + r887060;
        double r887062 = r887048 * r887046;
        double r887063 = r887056 * r887062;
        double r887064 = -r887045;
        double r887065 = r887058 * r887064;
        double r887066 = r887063 + r887065;
        double r887067 = r887057 + r887066;
        double r887068 = r887055 ? r887061 : r887067;
        return r887068;
}

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.2
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 (* (- 1.0 y) z) < -1.2874943527906958e+267 or 1.4322306713169816e+215 < (* (- 1.0 y) z)

    1. Initial program 26.3

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

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

      \[\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)}\]

    if -1.2874943527906958e+267 < (* (- 1.0 y) z) < 1.4322306713169816e+215

    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. Simplified1.8

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

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

      \[\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.1

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -1.28749435279069585 \cdot 10^{267} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.4322306713169816 \cdot 10^{215}\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 2020027 
(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))))