Average Error: 3.4 → 1.9
Time: 4.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le 35608010353305148:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le 35608010353305148:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r687224 = x;
        double r687225 = 1.0;
        double r687226 = y;
        double r687227 = r687225 - r687226;
        double r687228 = z;
        double r687229 = r687227 * r687228;
        double r687230 = r687225 - r687229;
        double r687231 = r687224 * r687230;
        return r687231;
}

double f(double x, double y, double z) {
        double r687232 = z;
        double r687233 = 35608010353305148.0;
        bool r687234 = r687232 <= r687233;
        double r687235 = x;
        double r687236 = 1.0;
        double r687237 = y;
        double r687238 = r687236 - r687237;
        double r687239 = r687238 * r687232;
        double r687240 = r687236 - r687239;
        double r687241 = r687235 * r687240;
        double r687242 = r687235 * r687236;
        double r687243 = r687235 * r687232;
        double r687244 = r687237 - r687236;
        double r687245 = r687243 * r687244;
        double r687246 = r687242 + r687245;
        double r687247 = r687234 ? r687241 : r687246;
        return r687247;
}

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
Herbie1.9
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607049 \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.8922376496639029 \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 < 35608010353305148.0

    1. Initial program 2.3

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]

    if 35608010353305148.0 < z

    1. Initial program 8.5

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 35608010353305148:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \end{array}\]

Reproduce

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