Average Error: 3.8 → 0.4
Time: 3.9s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.821134117448161 \cdot 10^{131} \lor \neg \left(z \le 2.6179480675622549 \cdot 10^{-20}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left({\left(\sqrt[3]{1}\right)}^{3} - 1 \cdot z\right) + z \cdot y\right) \cdot 1\right) \cdot x + x \cdot \left(\left(1 - y\right) \cdot \left(\left(-z\right) + z\right)\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -5.821134117448161 \cdot 10^{131} \lor \neg \left(z \le 2.6179480675622549 \cdot 10^{-20}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left({\left(\sqrt[3]{1}\right)}^{3} - 1 \cdot z\right) + z \cdot y\right) \cdot 1\right) \cdot x + x \cdot \left(\left(1 - y\right) \cdot \left(\left(-z\right) + z\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r804394 = x;
        double r804395 = 1.0;
        double r804396 = y;
        double r804397 = r804395 - r804396;
        double r804398 = z;
        double r804399 = r804397 * r804398;
        double r804400 = r804395 - r804399;
        double r804401 = r804394 * r804400;
        return r804401;
}

double f(double x, double y, double z) {
        double r804402 = z;
        double r804403 = -5.821134117448161e+131;
        bool r804404 = r804402 <= r804403;
        double r804405 = 2.617948067562255e-20;
        bool r804406 = r804402 <= r804405;
        double r804407 = !r804406;
        bool r804408 = r804404 || r804407;
        double r804409 = x;
        double r804410 = 1.0;
        double r804411 = r804409 * r804410;
        double r804412 = r804409 * r804402;
        double r804413 = y;
        double r804414 = r804413 - r804410;
        double r804415 = r804412 * r804414;
        double r804416 = r804411 + r804415;
        double r804417 = cbrt(r804410);
        double r804418 = 3.0;
        double r804419 = pow(r804417, r804418);
        double r804420 = r804410 * r804402;
        double r804421 = r804419 - r804420;
        double r804422 = r804402 * r804413;
        double r804423 = r804421 + r804422;
        double r804424 = 1.0;
        double r804425 = r804423 * r804424;
        double r804426 = r804425 * r804409;
        double r804427 = r804410 - r804413;
        double r804428 = -r804402;
        double r804429 = r804428 + r804402;
        double r804430 = r804427 * r804429;
        double r804431 = r804409 * r804430;
        double r804432 = r804426 + r804431;
        double r804433 = r804408 ? r804416 : r804432;
        return r804433;
}

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.8
Target0.3
Herbie0.4
\[\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 z < -5.821134117448161e+131 or 2.617948067562255e-20 < z

    1. Initial program 10.9

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

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

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

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

    if -5.821134117448161e+131 < z < 2.617948067562255e-20

    1. Initial program 0.5

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.5

      \[\leadsto x \cdot \left(\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}} - \left(1 - y\right) \cdot z\right)\]
    4. Applied prod-diff0.5

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{1} \cdot \sqrt[3]{1}, \sqrt[3]{1}, -z \cdot \left(1 - y\right)\right) + \mathsf{fma}\left(-z, 1 - y, z \cdot \left(1 - y\right)\right)\right)}\]
    5. Applied distribute-lft-in0.5

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(\sqrt[3]{1} \cdot \sqrt[3]{1}, \sqrt[3]{1}, -z \cdot \left(1 - y\right)\right) + x \cdot \mathsf{fma}\left(-z, 1 - y, z \cdot \left(1 - y\right)\right)}\]
    6. Simplified0.5

      \[\leadsto \color{blue}{\left(\left(\left({\left(\sqrt[3]{1}\right)}^{3} - 1 \cdot z\right) + z \cdot y\right) \cdot 1\right) \cdot x} + x \cdot \mathsf{fma}\left(-z, 1 - y, z \cdot \left(1 - y\right)\right)\]
    7. Simplified0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.821134117448161 \cdot 10^{131} \lor \neg \left(z \le 2.6179480675622549 \cdot 10^{-20}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left({\left(\sqrt[3]{1}\right)}^{3} - 1 \cdot z\right) + z \cdot y\right) \cdot 1\right) \cdot x + x \cdot \left(\left(1 - y\right) \cdot \left(\left(-z\right) + z\right)\right)\\ \end{array}\]

Reproduce

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