Average Error: 3.8 → 0.8
Time: 16.3s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.147778753457494596605973797462311911088 \cdot 10^{77}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \le 2.086550764333192983468099141385475427199 \cdot 10^{-149}:\\ \;\;\;\;\left(y \cdot x - 1 \cdot x\right) \cdot z + 1 \cdot x\\ \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 \le -1.147778753457494596605973797462311911088 \cdot 10^{77}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

\mathbf{elif}\;x \le 2.086550764333192983468099141385475427199 \cdot 10^{-149}:\\
\;\;\;\;\left(y \cdot x - 1 \cdot x\right) \cdot z + 1 \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r37638690 = x;
        double r37638691 = 1.0;
        double r37638692 = y;
        double r37638693 = r37638691 - r37638692;
        double r37638694 = z;
        double r37638695 = r37638693 * r37638694;
        double r37638696 = r37638691 - r37638695;
        double r37638697 = r37638690 * r37638696;
        return r37638697;
}

double f(double x, double y, double z) {
        double r37638698 = x;
        double r37638699 = -1.1477787534574946e+77;
        bool r37638700 = r37638698 <= r37638699;
        double r37638701 = 1.0;
        double r37638702 = y;
        double r37638703 = r37638701 - r37638702;
        double r37638704 = z;
        double r37638705 = r37638703 * r37638704;
        double r37638706 = r37638701 - r37638705;
        double r37638707 = r37638698 * r37638706;
        double r37638708 = 2.086550764333193e-149;
        bool r37638709 = r37638698 <= r37638708;
        double r37638710 = r37638702 * r37638698;
        double r37638711 = r37638701 * r37638698;
        double r37638712 = r37638710 - r37638711;
        double r37638713 = r37638712 * r37638704;
        double r37638714 = r37638713 + r37638711;
        double r37638715 = r37638709 ? r37638714 : r37638707;
        double r37638716 = r37638700 ? r37638707 : r37638715;
        return r37638716;
}

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.8
Target0.2
Herbie0.8
\[\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 x < -1.1477787534574946e+77 or 2.086550764333193e-149 < x

    1. Initial program 1.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]

    if -1.1477787534574946e+77 < x < 2.086550764333193e-149

    1. Initial program 6.2

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

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \sqrt[3]{1 - y}\right)} \cdot z\right)\]
    4. Applied associate-*l*6.5

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\sqrt[3]{1 - y} \cdot \sqrt[3]{1 - y}\right) \cdot \left(\sqrt[3]{1 - y} \cdot z\right)}\right)\]
    5. Taylor expanded around inf 6.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.147778753457494596605973797462311911088 \cdot 10^{77}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \le 2.086550764333192983468099141385475427199 \cdot 10^{-149}:\\ \;\;\;\;\left(y \cdot x - 1 \cdot x\right) \cdot z + 1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))

  (* x (- 1.0 (* (- 1.0 y) z))))