Average Error: 0.0 → 0.0
Time: 6.8s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot x\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(y, y, x \cdot x\right)
double f(double x, double y) {
        double r6637020 = x;
        double r6637021 = r6637020 * r6637020;
        double r6637022 = y;
        double r6637023 = r6637022 * r6637022;
        double r6637024 = r6637021 + r6637023;
        return r6637024;
}

double f(double x, double y) {
        double r6637025 = y;
        double r6637026 = x;
        double r6637027 = r6637026 * r6637026;
        double r6637028 = fma(r6637025, r6637025, r6637027);
        return r6637028;
}

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(y, y, x \cdot x\right)}\]
  3. Final simplification0.0

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

Reproduce

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