Average Error: 0.0 → 0.0
Time: 1.9s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\]
x \cdot x + y \cdot y
\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)
double f(double x, double y) {
        double r178694 = x;
        double r178695 = r178694 * r178694;
        double r178696 = y;
        double r178697 = r178696 * r178696;
        double r178698 = r178695 + r178697;
        return r178698;
}

double f(double x, double y) {
        double r178699 = x;
        double r178700 = y;
        double r178701 = hypot(r178699, r178700);
        double r178702 = r178701 * r178701;
        return r178702;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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(x, y\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}\]
  6. Simplified0.0

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

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

Reproduce

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