Average Error: 0.0 → 0.0
Time: 7.9s
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 r7559332 = x;
        double r7559333 = r7559332 * r7559332;
        double r7559334 = y;
        double r7559335 = r7559334 * r7559334;
        double r7559336 = r7559333 + r7559335;
        return r7559336;
}

double f(double x, double y) {
        double r7559337 = x;
        double r7559338 = y;
        double r7559339 = r7559338 * r7559338;
        double r7559340 = fma(r7559337, r7559337, r7559339);
        return r7559340;
}

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