Average Error: 3.1 → 0.3
Time: 13.3s
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(-x \cdot \left(z \cdot \left(1.0 - y\right)\right)\right) + 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}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\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 -2.7171599342471754 \cdot 10^{+75}:\\
\;\;\;\;\left(-x \cdot \left(z \cdot \left(1.0 - y\right)\right)\right) + 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}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + 1.0 \cdot x\\

\end{array}
double f(double x, double y, double z) {
        double r35226179 = x;
        double r35226180 = 1.0;
        double r35226181 = y;
        double r35226182 = r35226180 - r35226181;
        double r35226183 = z;
        double r35226184 = r35226182 * r35226183;
        double r35226185 = r35226180 - r35226184;
        double r35226186 = r35226179 * r35226185;
        return r35226186;
}

double f(double x, double y, double z) {
        double r35226187 = x;
        double r35226188 = -2.7171599342471754e+75;
        bool r35226189 = r35226187 <= r35226188;
        double r35226190 = z;
        double r35226191 = 1.0;
        double r35226192 = y;
        double r35226193 = r35226191 - r35226192;
        double r35226194 = r35226190 * r35226193;
        double r35226195 = r35226187 * r35226194;
        double r35226196 = -r35226195;
        double r35226197 = r35226191 * r35226187;
        double r35226198 = r35226196 + r35226197;
        double r35226199 = 5.474649330783933e-139;
        bool r35226200 = r35226187 <= r35226199;
        double r35226201 = r35226192 * r35226187;
        double r35226202 = r35226201 - r35226197;
        double r35226203 = r35226202 * r35226190;
        double r35226204 = r35226197 + r35226203;
        double r35226205 = r35226190 * r35226187;
        double r35226206 = r35226192 - r35226191;
        double r35226207 = r35226205 * r35226206;
        double r35226208 = r35226207 + r35226197;
        double r35226209 = r35226200 ? r35226204 : r35226208;
        double r35226210 = r35226189 ? r35226198 : r35226209;
        return r35226210;
}

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. 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-lft-in0.1

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

    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 - x \cdot 1.0\right) + x \cdot 1.0}\]

    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 - x \cdot 1.0\right) + x \cdot 1.0}\]
    4. Using strategy rm
    5. Applied distribute-lft-out--4.4

      \[\leadsto z \cdot \color{blue}{\left(x \cdot \left(y - 1.0\right)\right)} + x \cdot 1.0\]
    6. Applied associate-*r*0.2

      \[\leadsto \color{blue}{\left(z \cdot x\right) \cdot \left(y - 1.0\right)} + x \cdot 1.0\]
  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(-x \cdot \left(z \cdot \left(1.0 - y\right)\right)\right) + 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}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1.0\right) + 1.0 \cdot x\\ \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))))