Average Error: 0.0 → 0.0
Time: 7.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 r196203 = x;
        double r196204 = r196203 * r196203;
        double r196205 = y;
        double r196206 = r196205 * r196205;
        double r196207 = r196204 + r196206;
        return r196207;
}

double f(double x, double y) {
        double r196208 = x;
        double r196209 = y;
        double r196210 = r196209 * r196209;
        double r196211 = fma(r196208, r196208, r196210);
        return r196211;
}

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