Average Error: 0.0 → 0.0
Time: 1.6s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot y\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(x, x, y \cdot y\right)
double f(double x, double y) {
        double r130932 = x;
        double r130933 = r130932 * r130932;
        double r130934 = y;
        double r130935 = r130934 * r130934;
        double r130936 = r130933 + r130935;
        return r130936;
}

double f(double x, double y) {
        double r130937 = x;
        double r130938 = y;
        double r130939 = r130938 * r130938;
        double r130940 = fma(r130937, r130937, r130939);
        return r130940;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[x \cdot x + y \cdot y\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020024 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rasterific.Linear:$cquadrance from Rasterific-0.6.1"
  :precision binary64
  (+ (* x x) (* y y)))