Average Error: 3.4 → 0.1
Time: 21.7s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.129991475236902007469806848939088027261 \cdot 10^{-15} \lor \neg \left(z \le 7.681675611657618504756773385799924641365 \cdot 10^{-77}\right):\\ \;\;\;\;1 \cdot x + \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 -1.129991475236902007469806848939088027261 \cdot 10^{-15} \lor \neg \left(z \le 7.681675611657618504756773385799924641365 \cdot 10^{-77}\right):\\
\;\;\;\;1 \cdot x + \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 r505693 = x;
        double r505694 = 1.0;
        double r505695 = y;
        double r505696 = r505694 - r505695;
        double r505697 = z;
        double r505698 = r505696 * r505697;
        double r505699 = r505694 - r505698;
        double r505700 = r505693 * r505699;
        return r505700;
}

double f(double x, double y, double z) {
        double r505701 = z;
        double r505702 = -1.129991475236902e-15;
        bool r505703 = r505701 <= r505702;
        double r505704 = 7.681675611657619e-77;
        bool r505705 = r505701 <= r505704;
        double r505706 = !r505705;
        bool r505707 = r505703 || r505706;
        double r505708 = 1.0;
        double r505709 = x;
        double r505710 = r505708 * r505709;
        double r505711 = r505709 * r505701;
        double r505712 = y;
        double r505713 = r505712 - r505708;
        double r505714 = r505711 * r505713;
        double r505715 = r505710 + r505714;
        double r505716 = r505708 - r505712;
        double r505717 = r505716 * r505701;
        double r505718 = r505708 - r505717;
        double r505719 = r505709 * r505718;
        double r505720 = r505707 ? r505715 : r505719;
        return r505720;
}

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 < -1.129991475236902e-15 or 7.681675611657619e-77 < z

    1. Initial program 7.1

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

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

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

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

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

    if -1.129991475236902e-15 < z < 7.681675611657619e-77

    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 -1.129991475236902007469806848939088027261 \cdot 10^{-15} \lor \neg \left(z \le 7.681675611657618504756773385799924641365 \cdot 10^{-77}\right):\\ \;\;\;\;1 \cdot x + \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 2019304 
(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.618195973607049e50) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 3.8922376496639029e134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x)))))

  (* x (- 1 (* (- 1 y) z))))