Average Error: 3.4 → 0.1
Time: 3.8s
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 -1.0085285988747638 \cdot 10^{148} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.2909404280952141 \cdot 10^{50}\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 -1.0085285988747638 \cdot 10^{148} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.2909404280952141 \cdot 10^{50}\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 r818415 = x;
        double r818416 = 1.0;
        double r818417 = y;
        double r818418 = r818416 - r818417;
        double r818419 = z;
        double r818420 = r818418 * r818419;
        double r818421 = r818416 - r818420;
        double r818422 = r818415 * r818421;
        return r818422;
}

double f(double x, double y, double z) {
        double r818423 = x;
        double r818424 = 1.0;
        double r818425 = y;
        double r818426 = r818424 - r818425;
        double r818427 = z;
        double r818428 = r818426 * r818427;
        double r818429 = r818424 - r818428;
        double r818430 = r818423 * r818429;
        double r818431 = -1.0085285988747638e+148;
        bool r818432 = r818430 <= r818431;
        double r818433 = 5.290940428095214e+50;
        bool r818434 = r818430 <= r818433;
        double r818435 = !r818434;
        bool r818436 = r818432 || r818435;
        double r818437 = r818423 * r818424;
        double r818438 = r818423 * r818427;
        double r818439 = r818425 - r818424;
        double r818440 = r818438 * r818439;
        double r818441 = r818437 + r818440;
        double r818442 = r818436 ? r818441 : r818430;
        return r818442;
}

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
Herbie0.1
\[\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))) < -1.0085285988747638e+148 or 5.290940428095214e+50 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 8.0

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

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

      \[\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)}\]

    if -1.0085285988747638e+148 < (* x (- 1.0 (* (- 1.0 y) z))) < 5.290940428095214e+50

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -1.0085285988747638 \cdot 10^{148} \lor \neg \left(x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 5.2909404280952141 \cdot 10^{50}\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 2020081 
(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))))