Average Error: 3.4 → 0.3
Time: 16.0s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1.0 - y\right) \cdot z \le -5.052029033726575 \cdot 10^{+79}:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;\left(1.0 - y\right) \cdot z \le 1.1928770169997492 \cdot 10^{+224}:\\ \;\;\;\;\left(1.0 - \left(1.0 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;\left(1.0 - y\right) \cdot z \le -5.052029033726575 \cdot 10^{+79}:\\
\;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\

\mathbf{elif}\;\left(1.0 - y\right) \cdot z \le 1.1928770169997492 \cdot 10^{+224}:\\
\;\;\;\;\left(1.0 - \left(1.0 - y\right) \cdot z\right) \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r42368496 = x;
        double r42368497 = 1.0;
        double r42368498 = y;
        double r42368499 = r42368497 - r42368498;
        double r42368500 = z;
        double r42368501 = r42368499 * r42368500;
        double r42368502 = r42368497 - r42368501;
        double r42368503 = r42368496 * r42368502;
        return r42368503;
}

double f(double x, double y, double z) {
        double r42368504 = 1.0;
        double r42368505 = y;
        double r42368506 = r42368504 - r42368505;
        double r42368507 = z;
        double r42368508 = r42368506 * r42368507;
        double r42368509 = -5.052029033726575e+79;
        bool r42368510 = r42368508 <= r42368509;
        double r42368511 = x;
        double r42368512 = r42368511 * r42368504;
        double r42368513 = r42368505 - r42368504;
        double r42368514 = r42368507 * r42368511;
        double r42368515 = r42368513 * r42368514;
        double r42368516 = r42368512 + r42368515;
        double r42368517 = 1.1928770169997492e+224;
        bool r42368518 = r42368508 <= r42368517;
        double r42368519 = r42368504 - r42368508;
        double r42368520 = r42368519 * r42368511;
        double r42368521 = r42368518 ? r42368520 : r42368516;
        double r42368522 = r42368510 ? r42368516 : r42368521;
        return r42368522;
}

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.4
Target0.2
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1.0 - 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) < -5.052029033726575e+79 or 1.1928770169997492e+224 < (* (- 1.0 y) z)

    1. Initial program 12.6

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 12.6

      \[\leadsto \color{blue}{\left(1.0 \cdot x + x \cdot \left(z \cdot y\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
    3. Simplified1.3

      \[\leadsto \color{blue}{z \cdot \left(x \cdot y - 1.0 \cdot x\right) + 1.0 \cdot x}\]
    4. Taylor expanded around inf 12.6

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

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

    if -5.052029033726575e+79 < (* (- 1.0 y) z) < 1.1928770169997492e+224

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1.0 - y\right) \cdot z \le -5.052029033726575 \cdot 10^{+79}:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;\left(1.0 - y\right) \cdot z \le 1.1928770169997492 \cdot 10^{+224}:\\ \;\;\;\;\left(1.0 - \left(1.0 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.0 + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]

Reproduce

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