Average Error: 3.1 → 0.3
Time: 15.6s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.7171599342471754 \cdot 10^{+75}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 5.474649330783933 \cdot 10^{-139}:\\ \;\;\;\;1.0 \cdot x + \left(y \cdot x - 1.0 \cdot x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -2.7171599342471754 \cdot 10^{+75}:\\
\;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r35245167 = x;
        double r35245168 = 1.0;
        double r35245169 = y;
        double r35245170 = r35245168 - r35245169;
        double r35245171 = z;
        double r35245172 = r35245170 * r35245171;
        double r35245173 = r35245168 - r35245172;
        double r35245174 = r35245167 * r35245173;
        return r35245174;
}

double f(double x, double y, double z) {
        double r35245175 = x;
        double r35245176 = -2.7171599342471754e+75;
        bool r35245177 = r35245175 <= r35245176;
        double r35245178 = z;
        double r35245179 = y;
        double r35245180 = 1.0;
        double r35245181 = r35245179 - r35245180;
        double r35245182 = r35245178 * r35245181;
        double r35245183 = r35245182 * r35245175;
        double r35245184 = r35245180 * r35245175;
        double r35245185 = r35245183 + r35245184;
        double r35245186 = 5.474649330783933e-139;
        bool r35245187 = r35245175 <= r35245186;
        double r35245188 = r35245179 * r35245175;
        double r35245189 = r35245188 - r35245184;
        double r35245190 = r35245189 * r35245178;
        double r35245191 = r35245184 + r35245190;
        double r35245192 = r35245178 * r35245175;
        double r35245193 = r35245181 * r35245192;
        double r35245194 = r35245184 + r35245193;
        double r35245195 = r35245187 ? r35245191 : r35245194;
        double r35245196 = r35245177 ? r35245185 : r35245195;
        return r35245196;
}

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.1
Target0.2
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 < -2.7171599342471754e+75

    1. Initial program 0.1

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 0.1

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

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

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

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

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

    if -2.7171599342471754e+75 < x < 5.474649330783933e-139

    1. Initial program 5.1

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 5.1

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

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

    if 5.474649330783933e-139 < x

    1. Initial program 1.2

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 1.2

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot z\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 -2.7171599342471754 \cdot 10^{+75}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 5.474649330783933 \cdot 10^{-139}:\\ \;\;\;\;1.0 \cdot x + \left(y \cdot x - 1.0 \cdot x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]

Reproduce

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