Average Error: 0.1 → 0.1
Time: 6.4s
Precision: 64
\[x \cdot x - \left(y \cdot 4.0\right) \cdot z\]
\[\mathsf{fma}\left(-z, y \cdot 4.0, z \cdot \left(y \cdot 4.0\right)\right) + \left(x \cdot x - z \cdot \left(y \cdot 4.0\right)\right)\]
x \cdot x - \left(y \cdot 4.0\right) \cdot z
\mathsf{fma}\left(-z, y \cdot 4.0, z \cdot \left(y \cdot 4.0\right)\right) + \left(x \cdot x - z \cdot \left(y \cdot 4.0\right)\right)
double f(double x, double y, double z) {
        double r8269756 = x;
        double r8269757 = r8269756 * r8269756;
        double r8269758 = y;
        double r8269759 = 4.0;
        double r8269760 = r8269758 * r8269759;
        double r8269761 = z;
        double r8269762 = r8269760 * r8269761;
        double r8269763 = r8269757 - r8269762;
        return r8269763;
}

double f(double x, double y, double z) {
        double r8269764 = z;
        double r8269765 = -r8269764;
        double r8269766 = y;
        double r8269767 = 4.0;
        double r8269768 = r8269766 * r8269767;
        double r8269769 = r8269764 * r8269768;
        double r8269770 = fma(r8269765, r8269768, r8269769);
        double r8269771 = x;
        double r8269772 = r8269771 * r8269771;
        double r8269773 = r8269772 - r8269769;
        double r8269774 = r8269770 + r8269773;
        return r8269774;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.1

    \[x \cdot x - \left(y \cdot 4.0\right) \cdot z\]
  2. Using strategy rm
  3. Applied prod-diff0.1

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

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

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

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rasterific.QuadraticFormula:discriminant from Rasterific-0.6.1"
  (- (* x x) (* (* y 4.0) z)))