Average Error: 0.0 → 0.0
Time: 5.3s
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 r8395451 = x;
        double r8395452 = r8395451 * r8395451;
        double r8395453 = y;
        double r8395454 = r8395453 * r8395453;
        double r8395455 = r8395452 + r8395454;
        return r8395455;
}

double f(double x, double y) {
        double r8395456 = x;
        double r8395457 = y;
        double r8395458 = r8395457 * r8395457;
        double r8395459 = fma(r8395456, r8395456, r8395458);
        return r8395459;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{y}^{2} + {x}^{2}}\]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right)}\]
  5. Final simplification0.0

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

Reproduce

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