Average Error: 3.4 → 0.2
Time: 21.2s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\ \;\;\;\;1 \cdot x + \left(z \cdot x\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}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\
\;\;\;\;1 \cdot x + \left(z \cdot x\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 r1006155 = x;
        double r1006156 = 1.0;
        double r1006157 = y;
        double r1006158 = r1006156 - r1006157;
        double r1006159 = z;
        double r1006160 = r1006158 * r1006159;
        double r1006161 = r1006156 - r1006160;
        double r1006162 = r1006155 * r1006161;
        return r1006162;
}

double f(double x, double y, double z) {
        double r1006163 = 1.0;
        double r1006164 = y;
        double r1006165 = r1006163 - r1006164;
        double r1006166 = z;
        double r1006167 = r1006165 * r1006166;
        double r1006168 = -4.721654532789329e+174;
        bool r1006169 = r1006167 <= r1006168;
        double r1006170 = 1.4508199093501263e+148;
        bool r1006171 = r1006167 <= r1006170;
        double r1006172 = !r1006171;
        bool r1006173 = r1006169 || r1006172;
        double r1006174 = x;
        double r1006175 = r1006163 * r1006174;
        double r1006176 = r1006166 * r1006174;
        double r1006177 = r1006164 - r1006163;
        double r1006178 = r1006176 * r1006177;
        double r1006179 = r1006175 + r1006178;
        double r1006180 = r1006163 - r1006167;
        double r1006181 = r1006174 * r1006180;
        double r1006182 = r1006173 ? r1006179 : r1006181;
        return r1006182;
}

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.2
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607049 \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.8922376496639029 \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 (* (- 1.0 y) z) < -4.721654532789329e+174 or 1.4508199093501263e+148 < (* (- 1.0 y) z)

    1. Initial program 14.4

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

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

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

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

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

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

    if -4.721654532789329e+174 < (* (- 1.0 y) z) < 1.4508199093501263e+148

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -4.72165453278932932 \cdot 10^{174} \lor \neg \left(\left(1 - y\right) \cdot z \le 1.45081990935012627 \cdot 10^{148}\right):\\ \;\;\;\;1 \cdot x + \left(z \cdot x\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 2020045 +o rules:numerics
(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))))