Average Error: 0.0 → 0.0
Time: 1.8s
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 r10067853 = x;
        double r10067854 = r10067853 * r10067853;
        double r10067855 = y;
        double r10067856 = r10067855 * r10067855;
        double r10067857 = r10067854 + r10067856;
        return r10067857;
}

double f(double x, double y) {
        double r10067858 = y;
        double r10067859 = x;
        double r10067860 = r10067859 * r10067859;
        double r10067861 = fma(r10067858, r10067858, r10067860);
        return r10067861;
}

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