Average Error: 3.5 → 0.2
Time: 4.6s
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):\\ \;\;\;\;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}\;\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):\\
\;\;\;\;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 r747143 = x;
        double r747144 = 1.0;
        double r747145 = y;
        double r747146 = r747144 - r747145;
        double r747147 = z;
        double r747148 = r747146 * r747147;
        double r747149 = r747144 - r747148;
        double r747150 = r747143 * r747149;
        return r747150;
}

double f(double x, double y, double z) {
        double r747151 = 1.0;
        double r747152 = y;
        double r747153 = r747151 - r747152;
        double r747154 = z;
        double r747155 = r747153 * r747154;
        double r747156 = -1.5147135947934168e+232;
        bool r747157 = r747155 <= r747156;
        double r747158 = 2.218671642618789e+158;
        bool r747159 = r747155 <= r747158;
        double r747160 = !r747159;
        bool r747161 = r747157 || r747160;
        double r747162 = x;
        double r747163 = r747162 * r747151;
        double r747164 = r747162 * r747154;
        double r747165 = r747152 - r747151;
        double r747166 = r747164 * r747165;
        double r747167 = r747163 + r747166;
        double r747168 = r747151 - r747155;
        double r747169 = r747162 * r747168;
        double r747170 = r747161 ? r747167 : r747169;
        return r747170;
}

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. Simplified0.8

      \[\leadsto x \cdot 1 + \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):\\ \;\;\;\;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 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.618195973607049e50) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 3.8922376496639029e134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x)))))

  (* x (- 1 (* (- 1 y) z))))