Average Error: 3.4 → 0.1
Time: 3.6s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.930485680726371264248619752379454439506 \cdot 10^{-5} \lor \neg \left(z \le 9.367272916408732786322919300036508863611 \cdot 10^{-65}\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}\;z \le -8.930485680726371264248619752379454439506 \cdot 10^{-5} \lor \neg \left(z \le 9.367272916408732786322919300036508863611 \cdot 10^{-65}\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 r783036 = x;
        double r783037 = 1.0;
        double r783038 = y;
        double r783039 = r783037 - r783038;
        double r783040 = z;
        double r783041 = r783039 * r783040;
        double r783042 = r783037 - r783041;
        double r783043 = r783036 * r783042;
        return r783043;
}

double f(double x, double y, double z) {
        double r783044 = z;
        double r783045 = -8.930485680726371e-05;
        bool r783046 = r783044 <= r783045;
        double r783047 = 9.367272916408733e-65;
        bool r783048 = r783044 <= r783047;
        double r783049 = !r783048;
        bool r783050 = r783046 || r783049;
        double r783051 = x;
        double r783052 = 1.0;
        double r783053 = r783051 * r783052;
        double r783054 = r783051 * r783044;
        double r783055 = y;
        double r783056 = r783055 - r783052;
        double r783057 = r783054 * r783056;
        double r783058 = r783053 + r783057;
        double r783059 = r783052 - r783055;
        double r783060 = r783059 * r783044;
        double r783061 = r783052 - r783060;
        double r783062 = r783051 * r783061;
        double r783063 = r783050 ? r783058 : r783062;
        return r783063;
}

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.618195973607048970493874632750554853795 \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.892237649663902900973248011051357504727 \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 < -8.930485680726371e-05 or 9.367272916408733e-65 < z

    1. Initial program 7.5

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

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

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

    if -8.930485680726371e-05 < z < 9.367272916408733e-65

    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}\;z \le -8.930485680726371264248619752379454439506 \cdot 10^{-5} \lor \neg \left(z \le 9.367272916408732786322919300036508863611 \cdot 10^{-65}\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 2019354 
(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))))