Average Error: 0.0 → 0.0
Time: 5.5s
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 r7492733 = x;
        double r7492734 = r7492733 * r7492733;
        double r7492735 = y;
        double r7492736 = r7492735 * r7492735;
        double r7492737 = r7492734 + r7492736;
        return r7492737;
}

double f(double x, double y) {
        double r7492738 = y;
        double r7492739 = x;
        double r7492740 = r7492739 * r7492739;
        double r7492741 = fma(r7492738, r7492738, r7492740);
        return r7492741;
}

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