Average Error: 0.0 → 0.0
Time: 692.0ms
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 r182553 = x;
        double r182554 = r182553 * r182553;
        double r182555 = y;
        double r182556 = r182555 * r182555;
        double r182557 = r182554 + r182556;
        return r182557;
}

double f(double x, double y) {
        double r182558 = x;
        double r182559 = y;
        double r182560 = hypot(r182558, r182559);
        double r182561 = r182560 * r182560;
        return r182561;
}

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