Average Error: 0.3 → 0.2
Time: 14.1s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(z, 6 \cdot y, x\right) + \left(-6\right) \cdot \left(x \cdot z\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(z, 6 \cdot y, x\right) + \left(-6\right) \cdot \left(x \cdot z\right)
double f(double x, double y, double z) {
        double r33822960 = x;
        double r33822961 = y;
        double r33822962 = r33822961 - r33822960;
        double r33822963 = 6.0;
        double r33822964 = r33822962 * r33822963;
        double r33822965 = z;
        double r33822966 = r33822964 * r33822965;
        double r33822967 = r33822960 + r33822966;
        return r33822967;
}

double f(double x, double y, double z) {
        double r33822968 = z;
        double r33822969 = 6.0;
        double r33822970 = y;
        double r33822971 = r33822969 * r33822970;
        double r33822972 = x;
        double r33822973 = fma(r33822968, r33822971, r33822972);
        double r33822974 = -r33822969;
        double r33822975 = r33822972 * r33822968;
        double r33822976 = r33822974 * r33822975;
        double r33822977 = r33822973 + r33822976;
        return r33822977;
}

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. Taylor expanded around inf 0.2

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

    \[\leadsto x + \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)}\]
  4. Using strategy rm
  5. Applied sub-neg0.2

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

    \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y + z \cdot \left(-x\right)\right)}\]
  7. Applied distribute-rgt-in0.2

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

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

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

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

Reproduce

herbie shell --seed 2019171 +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)))