Average Error: 0.0 → 0.0
Time: 1.2s
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 r9296531 = x;
        double r9296532 = r9296531 * r9296531;
        double r9296533 = y;
        double r9296534 = r9296533 * r9296533;
        double r9296535 = r9296532 + r9296534;
        return r9296535;
}

double f(double x, double y) {
        double r9296536 = y;
        double r9296537 = x;
        double r9296538 = r9296537 * r9296537;
        double r9296539 = fma(r9296536, r9296536, r9296538);
        return r9296539;
}

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 2019163 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rasterific.Linear:$cquadrance from Rasterific-0.6.1"
  (+ (* x x) (* y y)))