Average Error: 0.3 → 0.2
Time: 15.9s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(z \cdot 6, y - x, x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(z \cdot 6, y - x, x\right)
double f(double x, double y, double z) {
        double r22073141 = x;
        double r22073142 = y;
        double r22073143 = r22073142 - r22073141;
        double r22073144 = 6.0;
        double r22073145 = r22073143 * r22073144;
        double r22073146 = z;
        double r22073147 = r22073145 * r22073146;
        double r22073148 = r22073141 + r22073147;
        return r22073148;
}

double f(double x, double y, double z) {
        double r22073149 = z;
        double r22073150 = 6.0;
        double r22073151 = r22073149 * r22073150;
        double r22073152 = y;
        double r22073153 = x;
        double r22073154 = r22073152 - r22073153;
        double r22073155 = fma(r22073151, r22073154, r22073153);
        return r22073155;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.3
Target0.2
Herbie0.2
\[x - \left(6 \cdot z\right) \cdot \left(x - y\right)\]

Derivation

  1. Initial program 0.3

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot 6, y - x, x\right)}\]
  3. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(z \cdot 6, y - x, x\right)\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"

  :herbie-target
  (- x (* (* 6.0 z) (- x y)))

  (+ x (* (* (- y x) 6.0) z)))