Average Error: 0.0 → 0.0
Time: 560.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 r144569 = x;
        double r144570 = r144569 * r144569;
        double r144571 = y;
        double r144572 = r144571 * r144571;
        double r144573 = r144570 + r144572;
        return r144573;
}

double f(double x, double y) {
        double r144574 = x;
        double r144575 = y;
        double r144576 = r144575 * r144575;
        double r144577 = fma(r144574, r144574, r144576);
        return r144577;
}

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