Average Error: 0.0 → 0.0
Time: 4.0s
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 r7050907 = x;
        double r7050908 = r7050907 * r7050907;
        double r7050909 = y;
        double r7050910 = r7050909 * r7050909;
        double r7050911 = r7050908 + r7050910;
        return r7050911;
}

double f(double x, double y) {
        double r7050912 = x;
        double r7050913 = y;
        double r7050914 = r7050913 * r7050913;
        double r7050915 = fma(r7050912, r7050912, r7050914);
        return r7050915;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{y}^{2} + {x}^{2}}\]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right)}\]
  5. Final simplification0.0

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

Reproduce

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