Average Error: 0.0 → 0.0
Time: 8.2s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}\]
x \cdot x + y \cdot y
\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}
double f(double x, double y) {
        double r6784106 = x;
        double r6784107 = r6784106 * r6784106;
        double r6784108 = y;
        double r6784109 = r6784108 * r6784108;
        double r6784110 = r6784107 + r6784109;
        return r6784110;
}

double f(double x, double y) {
        double r6784111 = y;
        double r6784112 = x;
        double r6784113 = r6784112 * r6784112;
        double r6784114 = fma(r6784111, r6784111, r6784113);
        double r6784115 = sqrt(r6784114);
        double r6784116 = r6784115 * r6784115;
        return r6784116;
}

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. Using strategy rm
  4. Applied add-sqr-sqrt0.0

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

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

Reproduce

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