Average Error: 0.0 → 0.0
Time: 7.6s
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 r7600162 = x;
        double r7600163 = r7600162 * r7600162;
        double r7600164 = y;
        double r7600165 = r7600164 * r7600164;
        double r7600166 = r7600163 + r7600165;
        return r7600166;
}

double f(double x, double y) {
        double r7600167 = y;
        double r7600168 = x;
        double r7600169 = r7600168 * r7600168;
        double r7600170 = fma(r7600167, r7600167, r7600169);
        return r7600170;
}

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