Average Error: 3.4 → 0.3
Time: 7.8s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.8632866288602766 \cdot 10^{+63}:\\ \;\;\;\;\left(z \cdot \left(1.0 - y\right)\right) \cdot \left(-x\right) + 1.0 \cdot x\\ \mathbf{elif}\;x \le 3.4989711450626845 \cdot 10^{-186}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot \left(y - 1.0\right)\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(y - 1.0\right) \cdot \left(z \cdot x\right) + 1.0 \cdot x\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -3.8632866288602766 \cdot 10^{+63}:\\
\;\;\;\;\left(z \cdot \left(1.0 - y\right)\right) \cdot \left(-x\right) + 1.0 \cdot x\\

\mathbf{elif}\;x \le 3.4989711450626845 \cdot 10^{-186}:\\
\;\;\;\;1.0 \cdot x + \left(x \cdot \left(y - 1.0\right)\right) \cdot z\\

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

\end{array}
double f(double x, double y, double z) {
        double r16321746 = x;
        double r16321747 = 1.0;
        double r16321748 = y;
        double r16321749 = r16321747 - r16321748;
        double r16321750 = z;
        double r16321751 = r16321749 * r16321750;
        double r16321752 = r16321747 - r16321751;
        double r16321753 = r16321746 * r16321752;
        return r16321753;
}

double f(double x, double y, double z) {
        double r16321754 = x;
        double r16321755 = -3.8632866288602766e+63;
        bool r16321756 = r16321754 <= r16321755;
        double r16321757 = z;
        double r16321758 = 1.0;
        double r16321759 = y;
        double r16321760 = r16321758 - r16321759;
        double r16321761 = r16321757 * r16321760;
        double r16321762 = -r16321754;
        double r16321763 = r16321761 * r16321762;
        double r16321764 = r16321758 * r16321754;
        double r16321765 = r16321763 + r16321764;
        double r16321766 = 3.4989711450626845e-186;
        bool r16321767 = r16321754 <= r16321766;
        double r16321768 = r16321759 - r16321758;
        double r16321769 = r16321754 * r16321768;
        double r16321770 = r16321769 * r16321757;
        double r16321771 = r16321764 + r16321770;
        double r16321772 = r16321757 * r16321754;
        double r16321773 = r16321768 * r16321772;
        double r16321774 = r16321773 + r16321764;
        double r16321775 = r16321767 ? r16321771 : r16321774;
        double r16321776 = r16321756 ? r16321765 : r16321775;
        return r16321776;
}

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.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -3.8632866288602766e+63

    1. Initial program 0.1

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

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

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

    if -3.8632866288602766e+63 < x < 3.4989711450626845e-186

    1. Initial program 5.5

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

      \[\leadsto x \cdot \color{blue}{\left(1.0 + \left(-\left(1.0 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-rgt-in5.5

      \[\leadsto \color{blue}{1.0 \cdot x + \left(-\left(1.0 - y\right) \cdot z\right) \cdot x}\]
    5. Taylor expanded around inf 5.5

      \[\leadsto \color{blue}{\left(1.0 \cdot x + x \cdot \left(z \cdot y\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
    6. Simplified3.0

      \[\leadsto \color{blue}{\left(z \cdot x\right) \cdot \left(y - 1.0\right) + 1.0 \cdot x}\]
    7. Using strategy rm
    8. Applied associate-*l*0.2

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

    if 3.4989711450626845e-186 < x

    1. Initial program 1.9

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

      \[\leadsto x \cdot \color{blue}{\left(1.0 + \left(-\left(1.0 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-rgt-in1.9

      \[\leadsto \color{blue}{1.0 \cdot x + \left(-\left(1.0 - y\right) \cdot z\right) \cdot x}\]
    5. Taylor expanded around inf 1.9

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

      \[\leadsto \color{blue}{\left(z \cdot x\right) \cdot \left(y - 1.0\right) + 1.0 \cdot x}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.8632866288602766 \cdot 10^{+63}:\\ \;\;\;\;\left(z \cdot \left(1.0 - y\right)\right) \cdot \left(-x\right) + 1.0 \cdot x\\ \mathbf{elif}\;x \le 3.4989711450626845 \cdot 10^{-186}:\\ \;\;\;\;1.0 \cdot x + \left(x \cdot \left(y - 1.0\right)\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(y - 1.0\right) \cdot \left(z \cdot x\right) + 1.0 \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))

  (* x (- 1.0 (* (- 1.0 y) z))))