Average Error: 0.0 → 0.0
Time: 4.4s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot x\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(y, y, x \cdot x\right)
double f(double x, double y) {
        double r216549 = x;
        double r216550 = r216549 * r216549;
        double r216551 = y;
        double r216552 = r216551 * r216551;
        double r216553 = r216550 + r216552;
        return r216553;
}

double f(double x, double y) {
        double r216554 = y;
        double r216555 = x;
        double r216556 = r216555 * r216555;
        double r216557 = fma(r216554, r216554, r216556);
        return r216557;
}

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

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

    \[\leadsto \color{blue}{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}\]
  6. Simplified0.0

    \[\leadsto \mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\mathsf{hypot}\left(y, x\right)}\]
  7. Taylor expanded around 0 0.0

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

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

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

Reproduce

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