Average Error: 3.5 → 3.5
Time: 10.8s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[x \cdot \left(1 + z \cdot \left(y - 1\right)\right)\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
x \cdot \left(1 + z \cdot \left(y - 1\right)\right)
double f(double x, double y, double z) {
        double r533100 = x;
        double r533101 = 1.0;
        double r533102 = y;
        double r533103 = r533101 - r533102;
        double r533104 = z;
        double r533105 = r533103 * r533104;
        double r533106 = r533101 - r533105;
        double r533107 = r533100 * r533106;
        return r533107;
}

double f(double x, double y, double z) {
        double r533108 = x;
        double r533109 = 1.0;
        double r533110 = z;
        double r533111 = y;
        double r533112 = r533111 - r533109;
        double r533113 = r533110 * r533112;
        double r533114 = r533109 + r533113;
        double r533115 = r533108 * r533114;
        return r533115;
}

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.5
Target0.3
Herbie3.5
\[\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 (* (- 1.0 y) z) < -9.127917089108886e+184 or 4.35243194448323e+189 < (* (- 1.0 y) z)

    1. Initial program 17.4

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

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

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

    if -9.127917089108886e+184 < (* (- 1.0 y) z) < 4.35243194448323e+189

    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 simplification3.5

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

Reproduce

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