Average Error: 0.0 → 0.0
Time: 1.5s
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 r145317 = x;
        double r145318 = r145317 * r145317;
        double r145319 = y;
        double r145320 = r145319 * r145319;
        double r145321 = r145318 + r145320;
        return r145321;
}

double f(double x, double y) {
        double r145322 = x;
        double r145323 = y;
        double r145324 = r145323 * r145323;
        double r145325 = fma(r145322, r145322, r145324);
        return r145325;
}

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