Average Error: 3.4 → 0.3
Time: 23.4s
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 r624736 = x;
        double r624737 = 1.0;
        double r624738 = y;
        double r624739 = r624737 - r624738;
        double r624740 = z;
        double r624741 = r624739 * r624740;
        double r624742 = r624737 - r624741;
        double r624743 = r624736 * r624742;
        return r624743;
}

double f(double x, double y, double z) {
        double r624744 = x;
        double r624745 = 1.0;
        double r624746 = y;
        double r624747 = r624745 - r624746;
        double r624748 = z;
        double r624749 = r624747 * r624748;
        double r624750 = r624745 - r624749;
        double r624751 = r624744 * r624750;
        double r624752 = -1.569143224315063e-49;
        bool r624753 = r624751 <= r624752;
        double r624754 = 1.913154983823862e-113;
        bool r624755 = r624751 <= r624754;
        double r624756 = !r624755;
        bool r624757 = r624753 || r624756;
        double r624758 = r624745 * r624744;
        double r624759 = r624744 * r624748;
        double r624760 = r624746 - r624745;
        double r624761 = r624759 * r624760;
        double r624762 = r624758 + r624761;
        double r624763 = r624757 ? r624762 : r624751;
        return r624763;
}

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))))