Average Error: 0.0 → 0.0
Time: 1.4s
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 r2794681 = x;
        double r2794682 = r2794681 * r2794681;
        double r2794683 = y;
        double r2794684 = r2794683 * r2794683;
        double r2794685 = r2794682 + r2794684;
        return r2794685;
}

double f(double x, double y) {
        double r2794686 = y;
        double r2794687 = x;
        double r2794688 = r2794687 * r2794687;
        double r2794689 = fma(r2794686, r2794686, r2794688);
        return r2794689;
}

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