Average Error: 3.3 → 1.6
Time: 16.1s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[x \cdot 1 + \left(y - 1\right) \cdot \left(x \cdot z\right)\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
x \cdot 1 + \left(y - 1\right) \cdot \left(x \cdot z\right)
double f(double x, double y, double z) {
        double r37428600 = x;
        double r37428601 = 1.0;
        double r37428602 = y;
        double r37428603 = r37428601 - r37428602;
        double r37428604 = z;
        double r37428605 = r37428603 * r37428604;
        double r37428606 = r37428601 - r37428605;
        double r37428607 = r37428600 * r37428606;
        return r37428607;
}

double f(double x, double y, double z) {
        double r37428608 = x;
        double r37428609 = 1.0;
        double r37428610 = r37428608 * r37428609;
        double r37428611 = y;
        double r37428612 = r37428611 - r37428609;
        double r37428613 = z;
        double r37428614 = r37428608 * r37428613;
        double r37428615 = r37428612 * r37428614;
        double r37428616 = r37428610 + r37428615;
        return r37428616;
}

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.3
Target0.2
Herbie1.6
\[\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. Initial program 3.3

    \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
  2. Simplified3.3

    \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(z, y - 1, 1\right)}\]
  3. Using strategy rm
  4. Applied fma-udef3.3

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

    \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1\right)\right) + x \cdot 1}\]
  6. Taylor expanded around inf 3.3

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

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

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

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(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))))