Average Error: 3.4 → 0.2
Time: 26.8s
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.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\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.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\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 r717624 = x;
        double r717625 = 1.0;
        double r717626 = y;
        double r717627 = r717625 - r717626;
        double r717628 = z;
        double r717629 = r717627 * r717628;
        double r717630 = r717625 - r717629;
        double r717631 = r717624 * r717630;
        return r717631;
}

double f(double x, double y, double z) {
        double r717632 = 1.0;
        double r717633 = y;
        double r717634 = r717632 - r717633;
        double r717635 = z;
        double r717636 = r717634 * r717635;
        double r717637 = -4.721654532789329e+174;
        bool r717638 = r717636 <= r717637;
        double r717639 = 1.4508199093501263e+148;
        bool r717640 = r717636 <= r717639;
        double r717641 = !r717640;
        bool r717642 = r717638 || r717641;
        double r717643 = x;
        double r717644 = r717643 * r717632;
        double r717645 = r717643 * r717635;
        double r717646 = r717633 - r717632;
        double r717647 = r717645 * r717646;
        double r717648 = r717644 + r717647;
        double r717649 = r717632 - r717636;
        double r717650 = r717643 * r717649;
        double r717651 = r717642 ? r717648 : r717650;
        return r717651;
}

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.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 (* (- 1.0 y) z) < -4.721654532789329e+174 or 1.4508199093501263e+148 < (* (- 1.0 y) z)

    1. Initial program 14.4

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

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

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

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

    if -4.721654532789329e+174 < (* (- 1.0 y) z) < 1.4508199093501263e+148

    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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\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 2020045 
(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))))