Average Error: 0.4 → 0.2
Time: 18.4s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[\mathsf{fma}\left(-x, 3, y \cdot 4\right) + \left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(-x, 3, y \cdot 4\right) + \left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
double f(double x, double y, double z) {
        double r202006 = x;
        double r202007 = y;
        double r202008 = r202007 - r202006;
        double r202009 = 6.0;
        double r202010 = r202008 * r202009;
        double r202011 = 2.0;
        double r202012 = 3.0;
        double r202013 = r202011 / r202012;
        double r202014 = z;
        double r202015 = r202013 - r202014;
        double r202016 = r202010 * r202015;
        double r202017 = r202006 + r202016;
        return r202017;
}

double f(double x, double y, double z) {
        double r202018 = x;
        double r202019 = -r202018;
        double r202020 = 3.0;
        double r202021 = y;
        double r202022 = 4.0;
        double r202023 = r202021 * r202022;
        double r202024 = fma(r202019, r202020, r202023);
        double r202025 = z;
        double r202026 = -r202025;
        double r202027 = r202021 - r202018;
        double r202028 = 6.0;
        double r202029 = r202027 * r202028;
        double r202030 = r202026 * r202029;
        double r202031 = r202024 + r202030;
        return r202031;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.4

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

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

    \[\leadsto x + \color{blue}{\left(\frac{2}{3} \cdot \left(\left(y - x\right) \cdot 6\right) + \left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)\right)}\]
  5. Applied associate-+r+0.4

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \frac{2}{3}, x\right)} + \left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)\]
  7. Taylor expanded around 0 0.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(-x, 3, y \cdot 4\right)} + \left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)\]
  9. Using strategy rm
  10. Applied *-un-lft-identity0.2

    \[\leadsto \mathsf{fma}\left(-x, 3, y \cdot 4\right) + \color{blue}{\left(1 \cdot \left(-z\right)\right)} \cdot \left(\left(y - x\right) \cdot 6\right)\]
  11. Applied associate-*l*0.2

    \[\leadsto \mathsf{fma}\left(-x, 3, y \cdot 4\right) + \color{blue}{1 \cdot \left(\left(-z\right) \cdot \left(\left(y - x\right) \cdot 6\right)\right)}\]
  12. Simplified0.2

    \[\leadsto \mathsf{fma}\left(-x, 3, y \cdot 4\right) + 1 \cdot \color{blue}{\left(\left(\left(y - x\right) \cdot z\right) \cdot \left(-6\right)\right)}\]
  13. Using strategy rm
  14. Applied distribute-rgt-neg-out0.2

    \[\leadsto \mathsf{fma}\left(-x, 3, y \cdot 4\right) + 1 \cdot \color{blue}{\left(-\left(\left(y - x\right) \cdot z\right) \cdot 6\right)}\]
  15. Simplified0.2

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

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))