Average Error: 3.3 → 0.5
Time: 4.3s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -3.2563957004446949 \cdot 10^{193} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.8922636299088758 \cdot 10^{-195}\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}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -3.2563957004446949 \cdot 10^{193} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.8922636299088758 \cdot 10^{-195}\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 r900342 = x;
        double r900343 = 1.0;
        double r900344 = y;
        double r900345 = r900343 - r900344;
        double r900346 = z;
        double r900347 = r900345 * r900346;
        double r900348 = r900343 - r900347;
        double r900349 = r900342 * r900348;
        return r900349;
}

double f(double x, double y, double z) {
        double r900350 = x;
        double r900351 = 1.0;
        double r900352 = y;
        double r900353 = r900351 - r900352;
        double r900354 = z;
        double r900355 = r900353 * r900354;
        double r900356 = r900351 - r900355;
        double r900357 = r900350 * r900356;
        double r900358 = -3.256395700444695e+193;
        bool r900359 = r900357 <= r900358;
        double r900360 = 5.892263629908876e-195;
        bool r900361 = r900357 <= r900360;
        double r900362 = !r900361;
        bool r900363 = r900359 || r900362;
        double r900364 = r900350 * r900351;
        double r900365 = r900350 * r900354;
        double r900366 = r900352 - r900351;
        double r900367 = r900365 * r900366;
        double r900368 = r900364 + r900367;
        double r900369 = r900363 ? r900368 : r900357;
        return r900369;
}

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
Herbie0.5
\[\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 (* x (- 1.0 (* (- 1.0 y) z))) < -3.256395700444695e+193 or 5.892263629908876e-195 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 5.7

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

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

      \[\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 -3.256395700444695e+193 < (* x (- 1.0 (* (- 1.0 y) z))) < 5.892263629908876e-195

    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.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -3.2563957004446949 \cdot 10^{193} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.8922636299088758 \cdot 10^{-195}\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 2020021 
(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))))