Average Error: 3.8 → 0.8
Time: 16.2s
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 r38685380 = x;
        double r38685381 = 1.0;
        double r38685382 = y;
        double r38685383 = r38685381 - r38685382;
        double r38685384 = z;
        double r38685385 = r38685383 * r38685384;
        double r38685386 = r38685381 - r38685385;
        double r38685387 = r38685380 * r38685386;
        return r38685387;
}

double f(double x, double y, double z) {
        double r38685388 = x;
        double r38685389 = -1.1477787534574946e+77;
        bool r38685390 = r38685388 <= r38685389;
        double r38685391 = 1.0;
        double r38685392 = y;
        double r38685393 = r38685391 - r38685392;
        double r38685394 = z;
        double r38685395 = r38685393 * r38685394;
        double r38685396 = r38685391 - r38685395;
        double r38685397 = r38685388 * r38685396;
        double r38685398 = 2.086550764333193e-149;
        bool r38685399 = r38685388 <= r38685398;
        double r38685400 = r38685392 * r38685388;
        double r38685401 = r38685391 * r38685388;
        double r38685402 = r38685400 - r38685401;
        double r38685403 = r38685402 * r38685394;
        double r38685404 = r38685403 + r38685401;
        double r38685405 = r38685399 ? r38685404 : r38685397;
        double r38685406 = r38685390 ? r38685397 : r38685405;
        return r38685406;
}

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))))