Average Error: 3.5 → 0.2
Time: 27.3s
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 -1.514713594793416779048976227223603061964 \cdot 10^{232}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y - 1\right)\right) + x \cdot 1\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\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 -1.514713594793416779048976227223603061964 \cdot 10^{232}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y - 1\right)\right) + x \cdot 1\\

\mathbf{elif}\;\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r534301 = x;
        double r534302 = 1.0;
        double r534303 = y;
        double r534304 = r534302 - r534303;
        double r534305 = z;
        double r534306 = r534304 * r534305;
        double r534307 = r534302 - r534306;
        double r534308 = r534301 * r534307;
        return r534308;
}

double f(double x, double y, double z) {
        double r534309 = 1.0;
        double r534310 = y;
        double r534311 = r534309 - r534310;
        double r534312 = z;
        double r534313 = r534311 * r534312;
        double r534314 = -1.5147135947934168e+232;
        bool r534315 = r534313 <= r534314;
        double r534316 = x;
        double r534317 = r534310 - r534309;
        double r534318 = r534316 * r534317;
        double r534319 = r534312 * r534318;
        double r534320 = r534316 * r534309;
        double r534321 = r534319 + r534320;
        double r534322 = 2.218671642618789e+158;
        bool r534323 = r534313 <= r534322;
        double r534324 = r534309 - r534313;
        double r534325 = r534316 * r534324;
        double r534326 = r534316 * r534312;
        double r534327 = r534326 * r534317;
        double r534328 = r534320 + r534327;
        double r534329 = r534323 ? r534325 : r534328;
        double r534330 = r534315 ? r534321 : r534329;
        return r534330;
}

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.5
Target0.2
Herbie0.2
\[\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 3 regimes
  2. if (* (- 1.0 y) z) < -1.5147135947934168e+232

    1. Initial program 24.7

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied pow10.4

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{{\left(y - 1\right)}^{1}}\]
    8. Applied pow10.4

      \[\leadsto x \cdot 1 + \left(x \cdot \color{blue}{{z}^{1}}\right) \cdot {\left(y - 1\right)}^{1}\]
    9. Applied pow10.4

      \[\leadsto x \cdot 1 + \left(\color{blue}{{x}^{1}} \cdot {z}^{1}\right) \cdot {\left(y - 1\right)}^{1}\]
    10. Applied pow-prod-down0.4

      \[\leadsto x \cdot 1 + \color{blue}{{\left(x \cdot z\right)}^{1}} \cdot {\left(y - 1\right)}^{1}\]
    11. Applied pow-prod-down0.4

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

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

    if -1.5147135947934168e+232 < (* (- 1.0 y) z) < 2.218671642618789e+158

    1. Initial program 0.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]

    if 2.218671642618789e+158 < (* (- 1.0 y) z)

    1. Initial program 14.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -1.514713594793416779048976227223603061964 \cdot 10^{232}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y - 1\right)\right) + x \cdot 1\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 +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))))