Average Error: 0.2 → 0.2
Time: 17.8s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)
double f(double x, double y, double z) {
        double r773962 = x;
        double r773963 = y;
        double r773964 = r773963 - r773962;
        double r773965 = 6.0;
        double r773966 = r773964 * r773965;
        double r773967 = z;
        double r773968 = r773966 * r773967;
        double r773969 = r773962 + r773968;
        return r773969;
}

double f(double x, double y, double z) {
        double r773970 = z;
        double r773971 = y;
        double r773972 = x;
        double r773973 = r773971 - r773972;
        double r773974 = 6.0;
        double r773975 = r773973 * r773974;
        double r773976 = fma(r773970, r773975, r773972);
        return r773976;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.2

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
  2. Taylor expanded around 0 0.2

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

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

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

Reproduce

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

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

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