Average Error: 3.4 → 0.4
Time: 16.6s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.561444125271963536658058669094541099896 \cdot 10^{-94}:\\ \;\;\;\;1 \cdot x + z \cdot \left(y \cdot x - 1 \cdot x\right)\\ \mathbf{elif}\;z \le 2.811602231371343827384096539240095965801 \cdot 10^{71}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + z \cdot \left(y \cdot x - 1 \cdot x\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -3.561444125271963536658058669094541099896 \cdot 10^{-94}:\\
\;\;\;\;1 \cdot x + z \cdot \left(y \cdot x - 1 \cdot x\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r43843185 = x;
        double r43843186 = 1.0;
        double r43843187 = y;
        double r43843188 = r43843186 - r43843187;
        double r43843189 = z;
        double r43843190 = r43843188 * r43843189;
        double r43843191 = r43843186 - r43843190;
        double r43843192 = r43843185 * r43843191;
        return r43843192;
}

double f(double x, double y, double z) {
        double r43843193 = z;
        double r43843194 = -3.5614441252719635e-94;
        bool r43843195 = r43843193 <= r43843194;
        double r43843196 = 1.0;
        double r43843197 = x;
        double r43843198 = r43843196 * r43843197;
        double r43843199 = y;
        double r43843200 = r43843199 * r43843197;
        double r43843201 = r43843200 - r43843198;
        double r43843202 = r43843193 * r43843201;
        double r43843203 = r43843198 + r43843202;
        double r43843204 = 2.811602231371344e+71;
        bool r43843205 = r43843193 <= r43843204;
        double r43843206 = r43843196 - r43843199;
        double r43843207 = r43843206 * r43843193;
        double r43843208 = r43843196 - r43843207;
        double r43843209 = r43843197 * r43843208;
        double r43843210 = r43843205 ? r43843209 : r43843203;
        double r43843211 = r43843195 ? r43843203 : r43843210;
        return r43843211;
}

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.3
Herbie0.4
\[\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 < -3.5614441252719635e-94 or 2.811602231371344e+71 < z

    1. Initial program 7.7

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 7.7

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

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

    if -3.5614441252719635e-94 < z < 2.811602231371344e+71

    1. Initial program 0.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.561444125271963536658058669094541099896 \cdot 10^{-94}:\\ \;\;\;\;1 \cdot x + z \cdot \left(y \cdot x - 1 \cdot x\right)\\ \mathbf{elif}\;z \le 2.811602231371343827384096539240095965801 \cdot 10^{71}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + z \cdot \left(y \cdot x - 1 \cdot x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 
(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))))