Average Error: 0.0 → 0.0
Time: 646.0ms
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 r176198 = x;
        double r176199 = r176198 * r176198;
        double r176200 = y;
        double r176201 = r176200 * r176200;
        double r176202 = r176199 + r176201;
        return r176202;
}

double f(double x, double y) {
        double r176203 = x;
        double r176204 = y;
        double r176205 = r176204 * r176204;
        double r176206 = fma(r176203, r176203, r176205);
        return r176206;
}

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(x, x, y \cdot y\right)}\]
  3. Final simplification0.0

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

Reproduce

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