Average Error: 3.5 → 0.2
Time: 11.0s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.238958166180944220920392289331491446517 \cdot 10^{60} \lor \neg \left(z \le 196914592157254175430467911680\right):\\ \;\;\;\;1 \cdot \left(x - x \cdot z\right) + \left(x \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1 \cdot \left(x \cdot z\right)\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -6.238958166180944220920392289331491446517 \cdot 10^{60} \lor \neg \left(z \le 196914592157254175430467911680\right):\\
\;\;\;\;1 \cdot \left(x - x \cdot z\right) + \left(x \cdot y\right) \cdot z\\

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

\end{array}
double f(double x, double y, double z) {
        double r667915 = x;
        double r667916 = 1.0;
        double r667917 = y;
        double r667918 = r667916 - r667917;
        double r667919 = z;
        double r667920 = r667918 * r667919;
        double r667921 = r667916 - r667920;
        double r667922 = r667915 * r667921;
        return r667922;
}

double f(double x, double y, double z) {
        double r667923 = z;
        double r667924 = -6.238958166180944e+60;
        bool r667925 = r667923 <= r667924;
        double r667926 = 1.9691459215725418e+29;
        bool r667927 = r667923 <= r667926;
        double r667928 = !r667927;
        bool r667929 = r667925 || r667928;
        double r667930 = 1.0;
        double r667931 = x;
        double r667932 = r667931 * r667923;
        double r667933 = r667931 - r667932;
        double r667934 = r667930 * r667933;
        double r667935 = y;
        double r667936 = r667931 * r667935;
        double r667937 = r667936 * r667923;
        double r667938 = r667934 + r667937;
        double r667939 = r667923 * r667935;
        double r667940 = r667939 + r667930;
        double r667941 = r667931 * r667940;
        double r667942 = r667930 * r667932;
        double r667943 = -r667942;
        double r667944 = r667941 + r667943;
        double r667945 = r667929 ? r667938 : r667944;
        return r667945;
}

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 2 regimes
  2. if z < -6.238958166180944e+60 or 1.9691459215725418e+29 < z

    1. Initial program 10.5

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 10.5

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

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

    if -6.238958166180944e+60 < z < 1.9691459215725418e+29

    1. Initial program 0.2

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 0.2

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(x + \left(-x \cdot z\right)\right)} + \left(x \cdot y\right) \cdot z\]
    6. Applied distribute-rgt-in4.7

      \[\leadsto \color{blue}{\left(x \cdot 1 + \left(-x \cdot z\right) \cdot 1\right)} + \left(x \cdot y\right) \cdot z\]
    7. Applied associate-+l+4.7

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(z \cdot x\right) \cdot \left(y - 1\right)}\]
    9. Using strategy rm
    10. Applied sub-neg2.3

      \[\leadsto x \cdot 1 + \left(z \cdot x\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}\]
    11. Applied distribute-rgt-in2.3

      \[\leadsto x \cdot 1 + \color{blue}{\left(y \cdot \left(z \cdot x\right) + \left(-1\right) \cdot \left(z \cdot x\right)\right)}\]
    12. Applied associate-+r+2.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.238958166180944220920392289331491446517 \cdot 10^{60} \lor \neg \left(z \le 196914592157254175430467911680\right):\\ \;\;\;\;1 \cdot \left(x - x \cdot z\right) + \left(x \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1 \cdot \left(x \cdot z\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019195 
(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))))