Average Error: 3.5 → 0.4
Time: 4.4s
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 -4.7588661750839972 \cdot 10^{279} \lor \neg \left(\left(1 - y\right) \cdot z \le 2.64255431221124823 \cdot 10^{70}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\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 -4.7588661750839972 \cdot 10^{279} \lor \neg \left(\left(1 - y\right) \cdot z \le 2.64255431221124823 \cdot 10^{70}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r668059 = x;
        double r668060 = 1.0;
        double r668061 = y;
        double r668062 = r668060 - r668061;
        double r668063 = z;
        double r668064 = r668062 * r668063;
        double r668065 = r668060 - r668064;
        double r668066 = r668059 * r668065;
        return r668066;
}

double f(double x, double y, double z) {
        double r668067 = 1.0;
        double r668068 = y;
        double r668069 = r668067 - r668068;
        double r668070 = z;
        double r668071 = r668069 * r668070;
        double r668072 = -4.758866175083997e+279;
        bool r668073 = r668071 <= r668072;
        double r668074 = 2.6425543122112482e+70;
        bool r668075 = r668071 <= r668074;
        double r668076 = !r668075;
        bool r668077 = r668073 || r668076;
        double r668078 = x;
        double r668079 = r668078 * r668067;
        double r668080 = r668078 * r668070;
        double r668081 = r668068 - r668067;
        double r668082 = r668080 * r668081;
        double r668083 = r668079 + r668082;
        double r668084 = r668067 - r668071;
        double r668085 = r668078 * r668084;
        double r668086 = r668077 ? r668083 : r668085;
        return r668086;
}

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.3
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 (* (- 1.0 y) z) < -4.758866175083997e+279 or 2.6425543122112482e+70 < (* (- 1.0 y) z)

    1. Initial program 14.3

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

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

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

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

    if -4.758866175083997e+279 < (* (- 1.0 y) z) < 2.6425543122112482e+70

    1. Initial program 0.1

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

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

Reproduce

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