Average Error: 3.4 → 0.3
Time: 24.6s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -1.569143224315062905865578614887049706183 \cdot 10^{-49} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 1.913154983823862017253893947037984823451 \cdot 10^{-113}\right):\\ \;\;\;\;1 \cdot x + \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}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -1.569143224315062905865578614887049706183 \cdot 10^{-49} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 1.913154983823862017253893947037984823451 \cdot 10^{-113}\right):\\
\;\;\;\;1 \cdot x + \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 r531730 = x;
        double r531731 = 1.0;
        double r531732 = y;
        double r531733 = r531731 - r531732;
        double r531734 = z;
        double r531735 = r531733 * r531734;
        double r531736 = r531731 - r531735;
        double r531737 = r531730 * r531736;
        return r531737;
}

double f(double x, double y, double z) {
        double r531738 = x;
        double r531739 = 1.0;
        double r531740 = y;
        double r531741 = r531739 - r531740;
        double r531742 = z;
        double r531743 = r531741 * r531742;
        double r531744 = r531739 - r531743;
        double r531745 = r531738 * r531744;
        double r531746 = -1.569143224315063e-49;
        bool r531747 = r531745 <= r531746;
        double r531748 = 1.913154983823862e-113;
        bool r531749 = r531745 <= r531748;
        double r531750 = !r531749;
        bool r531751 = r531747 || r531750;
        double r531752 = r531739 * r531738;
        double r531753 = r531738 * r531742;
        double r531754 = r531740 - r531739;
        double r531755 = r531753 * r531754;
        double r531756 = r531752 + r531755;
        double r531757 = r531751 ? r531756 : r531745;
        return r531757;
}

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.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607048970493874632750554853795 \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.892237649663902900973248011051357504727 \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 (- 1.0 (* (- 1.0 y) z))) < -1.569143224315063e-49 or 1.913154983823862e-113 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 4.6

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

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

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

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

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

    if -1.569143224315063e-49 < (* x (- 1.0 (* (- 1.0 y) z))) < 1.913154983823862e-113

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -1.569143224315062905865578614887049706183 \cdot 10^{-49} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 1.913154983823862017253893947037984823451 \cdot 10^{-113}\right):\\ \;\;\;\;1 \cdot x + \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 2019326 
(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))))