Average Error: 3.7 → 0.3
Time: 4.3s
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 r807389 = x;
        double r807390 = 1.0;
        double r807391 = y;
        double r807392 = r807390 - r807391;
        double r807393 = z;
        double r807394 = r807392 * r807393;
        double r807395 = r807390 - r807394;
        double r807396 = r807389 * r807395;
        return r807396;
}

double f(double x, double y, double z) {
        double r807397 = z;
        double r807398 = -1.2483158484967966e-39;
        bool r807399 = r807397 <= r807398;
        double r807400 = 4.6177819333441916e-88;
        bool r807401 = r807397 <= r807400;
        double r807402 = !r807401;
        bool r807403 = r807399 || r807402;
        double r807404 = x;
        double r807405 = 1.0;
        double r807406 = r807404 * r807405;
        double r807407 = r807404 * r807397;
        double r807408 = y;
        double r807409 = r807408 - r807405;
        double r807410 = r807407 * r807409;
        double r807411 = r807406 + r807410;
        double r807412 = r807405 - r807408;
        double r807413 = r807412 * r807397;
        double r807414 = r807405 - r807413;
        double r807415 = r807404 * r807414;
        double r807416 = r807403 ? r807411 : r807415;
        return r807416;
}

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 
(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))))