Average Error: 3.7 → 0.3
Time: 4.2s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.24831584849679658126409785071053668818 \cdot 10^{-39} \lor \neg \left(z \le 4.617781933344191629679609470919368971773 \cdot 10^{-88}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \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 -1.24831584849679658126409785071053668818 \cdot 10^{-39} \lor \neg \left(z \le 4.617781933344191629679609470919368971773 \cdot 10^{-88}\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r857343 = x;
        double r857344 = 1.0;
        double r857345 = y;
        double r857346 = r857344 - r857345;
        double r857347 = z;
        double r857348 = r857346 * r857347;
        double r857349 = r857344 - r857348;
        double r857350 = r857343 * r857349;
        return r857350;
}

double f(double x, double y, double z) {
        double r857351 = z;
        double r857352 = -1.2483158484967966e-39;
        bool r857353 = r857351 <= r857352;
        double r857354 = 4.6177819333441916e-88;
        bool r857355 = r857351 <= r857354;
        double r857356 = !r857355;
        bool r857357 = r857353 || r857356;
        double r857358 = x;
        double r857359 = 1.0;
        double r857360 = r857358 * r857359;
        double r857361 = r857358 * r857351;
        double r857362 = y;
        double r857363 = r857362 - r857359;
        double r857364 = r857361 * r857363;
        double r857365 = r857360 + r857364;
        double r857366 = r857359 - r857362;
        double r857367 = r857366 * r857351;
        double r857368 = r857359 - r857367;
        double r857369 = r857358 * r857368;
        double r857370 = r857357 ? r857365 : r857369;
        return r857370;
}

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 2 regimes
  2. if z < -1.2483158484967966e-39 or 4.6177819333441916e-88 < z

    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. Simplified0.4

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

    if -1.2483158484967966e-39 < z < 4.6177819333441916e-88

    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 -1.24831584849679658126409785071053668818 \cdot 10^{-39} \lor \neg \left(z \le 4.617781933344191629679609470919368971773 \cdot 10^{-88}\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]

Reproduce

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