Average Error: 3.6 → 1.5
Time: 16.1s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[x \cdot 1 + \left(x \cdot z\right) \cdot \left(-\left(1 - y\right)\right)\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
x \cdot 1 + \left(x \cdot z\right) \cdot \left(-\left(1 - y\right)\right)
double f(double x, double y, double z) {
        double r589650 = x;
        double r589651 = 1.0;
        double r589652 = y;
        double r589653 = r589651 - r589652;
        double r589654 = z;
        double r589655 = r589653 * r589654;
        double r589656 = r589651 - r589655;
        double r589657 = r589650 * r589656;
        return r589657;
}

double f(double x, double y, double z) {
        double r589658 = x;
        double r589659 = 1.0;
        double r589660 = r589658 * r589659;
        double r589661 = z;
        double r589662 = r589658 * r589661;
        double r589663 = y;
        double r589664 = r589659 - r589663;
        double r589665 = -r589664;
        double r589666 = r589662 * r589665;
        double r589667 = r589660 + r589666;
        return r589667;
}

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.6
Target0.3
Herbie1.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. Initial program 3.6

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

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

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

    \[\leadsto x \cdot 1 + \color{blue}{x \cdot \left(-z \cdot \left(1 - y\right)\right)}\]
  6. Using strategy rm
  7. Applied distribute-rgt-neg-in3.6

    \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(z \cdot \left(-\left(1 - y\right)\right)\right)}\]
  8. Applied associate-*r*1.5

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

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

Reproduce

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