Average Error: 3.5 → 0.2
Time: 19.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -1.514713594793416779048976227223603061964 \cdot 10^{232} \lor \neg \left(\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}\right):\\ \;\;\;\;1 \cdot x + \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}\;\left(1 - y\right) \cdot z \le -1.514713594793416779048976227223603061964 \cdot 10^{232} \lor \neg \left(\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}\right):\\
\;\;\;\;1 \cdot x + \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 r512430 = x;
        double r512431 = 1.0;
        double r512432 = y;
        double r512433 = r512431 - r512432;
        double r512434 = z;
        double r512435 = r512433 * r512434;
        double r512436 = r512431 - r512435;
        double r512437 = r512430 * r512436;
        return r512437;
}

double f(double x, double y, double z) {
        double r512438 = 1.0;
        double r512439 = y;
        double r512440 = r512438 - r512439;
        double r512441 = z;
        double r512442 = r512440 * r512441;
        double r512443 = -1.5147135947934168e+232;
        bool r512444 = r512442 <= r512443;
        double r512445 = 2.218671642618789e+158;
        bool r512446 = r512442 <= r512445;
        double r512447 = !r512446;
        bool r512448 = r512444 || r512447;
        double r512449 = x;
        double r512450 = r512438 * r512449;
        double r512451 = r512449 * r512441;
        double r512452 = r512439 - r512438;
        double r512453 = r512451 * r512452;
        double r512454 = r512450 + r512453;
        double r512455 = r512438 - r512442;
        double r512456 = r512449 * r512455;
        double r512457 = r512448 ? r512454 : r512456;
        return r512457;
}

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.2
Herbie0.2
\[\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 (* (- 1.0 y) z) < -1.5147135947934168e+232 or 2.218671642618789e+158 < (* (- 1.0 y) z)

    1. Initial program 17.8

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

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

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

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

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

    if -1.5147135947934168e+232 < (* (- 1.0 y) z) < 2.218671642618789e+158

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -1.514713594793416779048976227223603061964 \cdot 10^{232} \lor \neg \left(\left(1 - y\right) \cdot z \le 2.218671642618789189937839910011116577429 \cdot 10^{158}\right):\\ \;\;\;\;1 \cdot x + \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 2019322 
(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))))