Average Error: 3.7 → 0.3
Time: 22.1s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.65927490258674399 \cdot 10^{-44} \lor \neg \left(z \le 6.8158029305576074 \cdot 10^{-126}\right):\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -9.65927490258674399 \cdot 10^{-44} \lor \neg \left(z \le 6.8158029305576074 \cdot 10^{-126}\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y - 1\right) + 1 \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r618339 = x;
        double r618340 = 1.0;
        double r618341 = y;
        double r618342 = r618340 - r618341;
        double r618343 = z;
        double r618344 = r618342 * r618343;
        double r618345 = r618340 - r618344;
        double r618346 = r618339 * r618345;
        return r618346;
}

double f(double x, double y, double z) {
        double r618347 = z;
        double r618348 = -9.659274902586744e-44;
        bool r618349 = r618347 <= r618348;
        double r618350 = 6.815802930557607e-126;
        bool r618351 = r618347 <= r618350;
        double r618352 = !r618351;
        bool r618353 = r618349 || r618352;
        double r618354 = x;
        double r618355 = r618354 * r618347;
        double r618356 = y;
        double r618357 = 1.0;
        double r618358 = r618356 - r618357;
        double r618359 = r618355 * r618358;
        double r618360 = r618357 * r618354;
        double r618361 = r618359 + r618360;
        double r618362 = r618357 - r618356;
        double r618363 = r618362 * r618347;
        double r618364 = r618357 - r618363;
        double r618365 = r618354 * r618364;
        double r618366 = r618353 ? r618361 : r618365;
        return r618366;
}

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.3
Herbie0.3
\[\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 < -9.659274902586744e-44 or 6.815802930557607e-126 < z

    1. Initial program 6.7

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

      \[\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*7.9

      \[\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 6.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.6

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

    if -9.659274902586744e-44 < z < 6.815802930557607e-126

    1. Initial program 0.1

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

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

Reproduce

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