Average Error: 0.0 → 0.0
Time: 2.6s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(y, y, {x}^{2}\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(y, y, {x}^{2}\right)
double f(double x, double y) {
        double r152037 = x;
        double r152038 = r152037 * r152037;
        double r152039 = y;
        double r152040 = r152039 * r152039;
        double r152041 = r152038 + r152040;
        return r152041;
}

double f(double x, double y) {
        double r152042 = y;
        double r152043 = x;
        double r152044 = 2.0;
        double r152045 = pow(r152043, r152044);
        double r152046 = fma(r152042, r152042, r152045);
        return r152046;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[x \cdot x + y \cdot y\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt0.0

    \[\leadsto \color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}\]
  4. Simplified0.0

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

    \[\leadsto \mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}\]
  6. Using strategy rm
  7. Applied hypot-udef0.0

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

    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right)}} \cdot \mathsf{hypot}\left(x, y\right)\]
  9. Using strategy rm
  10. Applied add-cube-cbrt1.2

    \[\leadsto \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, y\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(x, y\right)}\right)}\]
  11. Applied associate-*r*1.2

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \left(\sqrt[3]{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(x, y\right)}\right)\right) \cdot \sqrt[3]{\mathsf{hypot}\left(x, y\right)}}\]
  12. Simplified1.2

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

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

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

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

Reproduce

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