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 r131790 = x;
        double r131791 = r131790 * r131790;
        double r131792 = y;
        double r131793 = r131792 * r131792;
        double r131794 = r131791 + r131793;
        return r131794;
}

double f(double x, double y) {
        double r131795 = x;
        double r131796 = y;
        double r131797 = r131796 * r131796;
        double r131798 = fma(r131795, r131795, r131797);
        return r131798;
}

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