Average Error: 3.3 → 1.7
Time: 14.7s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)
double f(double x, double y, double z) {
        double r39822551 = x;
        double r39822552 = 1.0;
        double r39822553 = y;
        double r39822554 = r39822552 - r39822553;
        double r39822555 = z;
        double r39822556 = r39822554 * r39822555;
        double r39822557 = r39822552 - r39822556;
        double r39822558 = r39822551 * r39822557;
        return r39822558;
}

double f(double x, double y, double z) {
        double r39822559 = 1.0;
        double r39822560 = x;
        double r39822561 = r39822559 * r39822560;
        double r39822562 = z;
        double r39822563 = r39822560 * r39822562;
        double r39822564 = y;
        double r39822565 = r39822564 - r39822559;
        double r39822566 = r39822563 * r39822565;
        double r39822567 = r39822561 + r39822566;
        return r39822567;
}

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.3
Target0.2
Herbie1.7
\[\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. Initial program 3.3

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

    \[\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. Simplified3.5

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

    \[\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.7

    \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1.0\right)} + 1.0 \cdot x\]
  6. Final simplification1.7

    \[\leadsto 1.0 \cdot x + \left(x \cdot z\right) \cdot \left(y - 1.0\right)\]

Reproduce

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