Average Error: 3.6 → 0.3
Time: 18.5s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\ \;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot y\right) + \left(x \cdot z\right) \cdot \left(-1\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\
\;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r964253 = x;
        double r964254 = 1.0;
        double r964255 = y;
        double r964256 = r964254 - r964255;
        double r964257 = z;
        double r964258 = r964256 * r964257;
        double r964259 = r964254 - r964258;
        double r964260 = r964253 * r964259;
        return r964260;
}

double f(double x, double y, double z) {
        double r964261 = z;
        double r964262 = -5.928829482005966e+90;
        bool r964263 = r964261 <= r964262;
        double r964264 = 2.1856788904363955e-58;
        bool r964265 = r964261 <= r964264;
        double r964266 = !r964265;
        bool r964267 = r964263 || r964266;
        double r964268 = x;
        double r964269 = 1.0;
        double r964270 = r964268 * r964269;
        double r964271 = y;
        double r964272 = r964268 * r964261;
        double r964273 = r964271 * r964272;
        double r964274 = -r964269;
        double r964275 = r964274 * r964272;
        double r964276 = r964273 + r964275;
        double r964277 = r964270 + r964276;
        double r964278 = r964261 * r964271;
        double r964279 = r964269 + r964278;
        double r964280 = r964268 * r964279;
        double r964281 = r964272 * r964274;
        double r964282 = r964280 + r964281;
        double r964283 = r964267 ? r964277 : r964282;
        return r964283;
}

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.6
Target0.2
Herbie0.3
\[\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 < -5.928829482005966e+90 or 2.1856788904363955e-58 < z

    1. Initial program 9.0

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied sub-neg0.2

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}\]
    8. Applied distribute-lft-in0.2

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

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

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

    if -5.928829482005966e+90 < z < 2.1856788904363955e-58

    1. Initial program 0.4

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]
    6. Using strategy rm
    7. Applied sub-neg2.6

      \[\leadsto x \cdot 1 + \left(x \cdot z\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}\]
    8. Applied distribute-lft-in2.6

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(x \cdot z\right) \cdot y + \left(x \cdot z\right) \cdot \left(-1\right)\right)}\]
    9. Applied associate-+r+2.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.92882948200596562 \cdot 10^{90} \lor \neg \left(z \le 2.1856788904363955 \cdot 10^{-58}\right):\\ \;\;\;\;x \cdot 1 + \left(y \cdot \left(x \cdot z\right) + \left(-1\right) \cdot \left(x \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot y\right) + \left(x \cdot z\right) \cdot \left(-1\right)\\ \end{array}\]

Reproduce

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