Average Error: 3.5 → 0.3
Time: 15.1s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -7.039728002290877410520308681367419739362 \cdot 10^{-28}:\\ \;\;\;\;x \cdot 1 + \left(y - 1\right) \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \le 4.895488592636590496420003434676489359632 \cdot 10^{-97}:\\ \;\;\;\;\left(1 + \left(y - 1\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + z \cdot \left(x \cdot \left(y - 1\right)\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -7.039728002290877410520308681367419739362 \cdot 10^{-28}:\\
\;\;\;\;x \cdot 1 + \left(y - 1\right) \cdot \left(x \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r632153 = x;
        double r632154 = 1.0;
        double r632155 = y;
        double r632156 = r632154 - r632155;
        double r632157 = z;
        double r632158 = r632156 * r632157;
        double r632159 = r632154 - r632158;
        double r632160 = r632153 * r632159;
        return r632160;
}

double f(double x, double y, double z) {
        double r632161 = z;
        double r632162 = -7.039728002290877e-28;
        bool r632163 = r632161 <= r632162;
        double r632164 = x;
        double r632165 = 1.0;
        double r632166 = r632164 * r632165;
        double r632167 = y;
        double r632168 = r632167 - r632165;
        double r632169 = r632164 * r632161;
        double r632170 = r632168 * r632169;
        double r632171 = r632166 + r632170;
        double r632172 = 4.89548859263659e-97;
        bool r632173 = r632161 <= r632172;
        double r632174 = r632168 * r632161;
        double r632175 = r632165 + r632174;
        double r632176 = r632175 * r632164;
        double r632177 = r632164 * r632168;
        double r632178 = r632161 * r632177;
        double r632179 = r632166 + r632178;
        double r632180 = r632173 ? r632176 : r632179;
        double r632181 = r632163 ? r632171 : r632180;
        return r632181;
}

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.3
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 z < -7.039728002290877e-28

    1. Initial program 7.7

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Simplified7.7

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

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

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

    if -7.039728002290877e-28 < z < 4.89548859263659e-97

    1. Initial program 0.1

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

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

    if 4.89548859263659e-97 < z

    1. Initial program 6.5

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Simplified6.5

      \[\leadsto \color{blue}{x \cdot \left(1 + z \cdot \left(y - 1\right)\right)}\]
    3. Using strategy rm
    4. Applied distribute-lft-in6.5

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -7.039728002290877410520308681367419739362 \cdot 10^{-28}:\\ \;\;\;\;x \cdot 1 + \left(y - 1\right) \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \le 4.895488592636590496420003434676489359632 \cdot 10^{-97}:\\ \;\;\;\;\left(1 + \left(y - 1\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + z \cdot \left(x \cdot \left(y - 1\right)\right)\\ \end{array}\]

Reproduce

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