Average Error: 0.0 → 0.0
Time: 4.2s
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 r107248 = x;
        double r107249 = r107248 * r107248;
        double r107250 = y;
        double r107251 = r107250 * r107250;
        double r107252 = r107249 + r107251;
        return r107252;
}

double f(double x, double y) {
        double r107253 = x;
        double r107254 = y;
        double r107255 = r107254 * r107254;
        double r107256 = fma(r107253, r107253, r107255);
        return r107256;
}

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