Average Error: 3.7 → 0.3
Time: 13.3s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.90404110154511993349936181731768963248 \cdot 10^{122}:\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.021354150296090950226088461595639164278 \cdot 10^{289}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(x \cdot z\right) \cdot \left(y - 1\right)} \cdot \sqrt{\left(x \cdot z\right) \cdot \left(y - 1\right)} + 1 \cdot x\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.90404110154511993349936181731768963248 \cdot 10^{122}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r560926 = x;
        double r560927 = 1.0;
        double r560928 = y;
        double r560929 = r560927 - r560928;
        double r560930 = z;
        double r560931 = r560929 * r560930;
        double r560932 = r560927 - r560931;
        double r560933 = r560926 * r560932;
        return r560933;
}

double f(double x, double y, double z) {
        double r560934 = x;
        double r560935 = 1.0;
        double r560936 = y;
        double r560937 = r560935 - r560936;
        double r560938 = z;
        double r560939 = r560937 * r560938;
        double r560940 = r560935 - r560939;
        double r560941 = r560934 * r560940;
        double r560942 = -7.90404110154512e+122;
        bool r560943 = r560941 <= r560942;
        double r560944 = r560934 * r560938;
        double r560945 = r560936 - r560935;
        double r560946 = r560944 * r560945;
        double r560947 = r560935 * r560934;
        double r560948 = r560946 + r560947;
        double r560949 = 6.021354150296091e+289;
        bool r560950 = r560941 <= r560949;
        double r560951 = sqrt(r560946);
        double r560952 = r560951 * r560951;
        double r560953 = r560952 + r560947;
        double r560954 = r560950 ? r560941 : r560953;
        double r560955 = r560943 ? r560948 : r560954;
        return r560955;
}

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.7
Target0.2
Herbie0.3
\[\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 (* x (- 1.0 (* (- 1.0 y) z))) < -7.90404110154512e+122

    1. Initial program 9.7

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    4. Applied associate-*l*10.8

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(1 - \left(1 - y\right) \cdot z\right)\right)}\]
    5. Taylor expanded around inf 9.7

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

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

    if -7.90404110154512e+122 < (* x (- 1.0 (* (- 1.0 y) z))) < 6.021354150296091e+289

    1. Initial program 0.1

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

    if 6.021354150296091e+289 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 41.1

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    4. Applied associate-*l*41.6

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(1 - \left(1 - y\right) \cdot z\right)\right)}\]
    5. Taylor expanded around inf 41.1

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

      \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt5.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -7.90404110154511993349936181731768963248 \cdot 10^{122}:\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 6.021354150296090950226088461595639164278 \cdot 10^{289}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(x \cdot z\right) \cdot \left(y - 1\right)} \cdot \sqrt{\left(x \cdot z\right) \cdot \left(y - 1\right)} + 1 \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019209 
(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.618195973607049e50) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 3.8922376496639029e134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x)))))

  (* x (- 1 (* (- 1 y) z))))