Average Error: 3.3 → 0.4
Time: 4.4s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.0247081817427441 \cdot 10^{-170}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;x \le 4.9259374917009595 \cdot 10^{-91}:\\ \;\;\;\;x \cdot 1 + {\left(\left(x \cdot \left(y - 1\right)\right) \cdot z\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot \left(z \cdot y\right) + \left(x \cdot z\right) \cdot \left(-1\right)\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -9.0247081817427441 \cdot 10^{-170}:\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r832656 = x;
        double r832657 = 1.0;
        double r832658 = y;
        double r832659 = r832657 - r832658;
        double r832660 = z;
        double r832661 = r832659 * r832660;
        double r832662 = r832657 - r832661;
        double r832663 = r832656 * r832662;
        return r832663;
}

double f(double x, double y, double z) {
        double r832664 = x;
        double r832665 = -9.024708181742744e-170;
        bool r832666 = r832664 <= r832665;
        double r832667 = 1.0;
        double r832668 = r832664 * r832667;
        double r832669 = z;
        double r832670 = r832664 * r832669;
        double r832671 = y;
        double r832672 = r832671 - r832667;
        double r832673 = r832670 * r832672;
        double r832674 = r832668 + r832673;
        double r832675 = 4.92593749170096e-91;
        bool r832676 = r832664 <= r832675;
        double r832677 = r832664 * r832672;
        double r832678 = r832677 * r832669;
        double r832679 = 1.0;
        double r832680 = pow(r832678, r832679);
        double r832681 = r832668 + r832680;
        double r832682 = r832669 * r832671;
        double r832683 = r832664 * r832682;
        double r832684 = -r832667;
        double r832685 = r832670 * r832684;
        double r832686 = r832683 + r832685;
        double r832687 = r832668 + r832686;
        double r832688 = r832676 ? r832681 : r832687;
        double r832689 = r832666 ? r832674 : r832688;
        return r832689;
}

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.3
Target0.2
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 3 regimes
  2. if x < -9.024708181742744e-170

    1. Initial program 1.6

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

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

      \[\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)}\]

    if -9.024708181742744e-170 < x < 4.92593749170096e-91

    1. Initial program 7.2

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

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

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

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

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(\left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right) \cdot \sqrt[3]{y - 1}\right)}\]
    8. Applied associate-*r*4.3

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(x \cdot z\right) \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right) \cdot \sqrt[3]{y - 1}}\]
    9. Using strategy rm
    10. Applied associate-*l*5.2

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot \left(z \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right)\right)} \cdot \sqrt[3]{y - 1}\]
    11. Using strategy rm
    12. Applied pow15.2

      \[\leadsto x \cdot 1 + \left(x \cdot \left(z \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right)\right) \cdot \color{blue}{{\left(\sqrt[3]{y - 1}\right)}^{1}}\]
    13. Applied pow15.2

      \[\leadsto x \cdot 1 + \left(x \cdot \left(z \cdot \left(\sqrt[3]{y - 1} \cdot \color{blue}{{\left(\sqrt[3]{y - 1}\right)}^{1}}\right)\right)\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    14. Applied pow15.2

      \[\leadsto x \cdot 1 + \left(x \cdot \left(z \cdot \left(\color{blue}{{\left(\sqrt[3]{y - 1}\right)}^{1}} \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\right)\right)\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    15. Applied pow-prod-down5.2

      \[\leadsto x \cdot 1 + \left(x \cdot \left(z \cdot \color{blue}{{\left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)}^{1}}\right)\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    16. Applied pow15.2

      \[\leadsto x \cdot 1 + \left(x \cdot \left(\color{blue}{{z}^{1}} \cdot {\left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)}^{1}\right)\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    17. Applied pow-prod-down5.2

      \[\leadsto x \cdot 1 + \left(x \cdot \color{blue}{{\left(z \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right)}^{1}}\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    18. Applied pow15.2

      \[\leadsto x \cdot 1 + \left(\color{blue}{{x}^{1}} \cdot {\left(z \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right)}^{1}\right) \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    19. Applied pow-prod-down5.2

      \[\leadsto x \cdot 1 + \color{blue}{{\left(x \cdot \left(z \cdot \left(\sqrt[3]{y - 1} \cdot \sqrt[3]{y - 1}\right)\right)\right)}^{1}} \cdot {\left(\sqrt[3]{y - 1}\right)}^{1}\]
    20. Applied pow-prod-down5.2

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

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

    if 4.92593749170096e-91 < x

    1. Initial program 0.8

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

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

      \[\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)}\]
    6. Using strategy rm
    7. Applied sub-neg0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.0247081817427441 \cdot 10^{-170}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;x \le 4.9259374917009595 \cdot 10^{-91}:\\ \;\;\;\;x \cdot 1 + {\left(\left(x \cdot \left(y - 1\right)\right) \cdot z\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot \left(z \cdot y\right) + \left(x \cdot z\right) \cdot \left(-1\right)\right)\\ \end{array}\]

Reproduce

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