Average Error: 3.6 → 0.1
Time: 5.1s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.329374264349992850062661166929405576475 \cdot 10^{-45} \lor \neg \left(z \le 14399917448371046271501632115048448\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 -3.329374264349992850062661166929405576475 \cdot 10^{-45} \lor \neg \left(z \le 14399917448371046271501632115048448\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 r995380 = x;
        double r995381 = 1.0;
        double r995382 = y;
        double r995383 = r995381 - r995382;
        double r995384 = z;
        double r995385 = r995383 * r995384;
        double r995386 = r995381 - r995385;
        double r995387 = r995380 * r995386;
        return r995387;
}

double f(double x, double y, double z) {
        double r995388 = z;
        double r995389 = -3.329374264349993e-45;
        bool r995390 = r995388 <= r995389;
        double r995391 = 1.4399917448371046e+34;
        bool r995392 = r995388 <= r995391;
        double r995393 = !r995392;
        bool r995394 = r995390 || r995393;
        double r995395 = x;
        double r995396 = 1.0;
        double r995397 = r995395 * r995396;
        double r995398 = r995395 * r995388;
        double r995399 = y;
        double r995400 = r995399 - r995396;
        double r995401 = r995398 * r995400;
        double r995402 = r995397 + r995401;
        double r995403 = r995396 - r995399;
        double r995404 = r995403 * r995388;
        double r995405 = r995396 - r995404;
        double r995406 = r995395 * r995405;
        double r995407 = r995394 ? r995402 : r995406;
        return r995407;
}

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.6
Target0.2
Herbie0.1
\[\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 < -3.329374264349993e-45 or 1.4399917448371046e+34 < z

    1. Initial program 8.8

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg8.8

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in8.8

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

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

    if -3.329374264349993e-45 < z < 1.4399917448371046e+34

    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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.329374264349992850062661166929405576475 \cdot 10^{-45} \lor \neg \left(z \le 14399917448371046271501632115048448\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 2019362 
(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))))