Average Error: 3.4 → 0.3
Time: 15.4s
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 r42932808 = x;
        double r42932809 = 1.0;
        double r42932810 = y;
        double r42932811 = r42932809 - r42932810;
        double r42932812 = z;
        double r42932813 = r42932811 * r42932812;
        double r42932814 = r42932809 - r42932813;
        double r42932815 = r42932808 * r42932814;
        return r42932815;
}

double f(double x, double y, double z) {
        double r42932816 = 1.0;
        double r42932817 = y;
        double r42932818 = r42932816 - r42932817;
        double r42932819 = z;
        double r42932820 = r42932818 * r42932819;
        double r42932821 = -5.052029033726575e+79;
        bool r42932822 = r42932820 <= r42932821;
        double r42932823 = x;
        double r42932824 = r42932823 * r42932816;
        double r42932825 = r42932817 - r42932816;
        double r42932826 = r42932819 * r42932823;
        double r42932827 = r42932825 * r42932826;
        double r42932828 = r42932824 + r42932827;
        double r42932829 = 1.1928770169997492e+224;
        bool r42932830 = r42932820 <= r42932829;
        double r42932831 = r42932816 - r42932820;
        double r42932832 = r42932831 * r42932823;
        double r42932833 = r42932830 ? r42932832 : r42932828;
        double r42932834 = r42932822 ? r42932828 : r42932833;
        return r42932834;
}

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