Average Error: 0.0 → 0
Time: 4.3s
Precision: 64
\[x - y \cdot y\]
\[\mathsf{fma}\left(y, -y, x\right)\]
x - y \cdot y
\mathsf{fma}\left(y, -y, x\right)
double f(double x, double y) {
        double r99212 = x;
        double r99213 = y;
        double r99214 = r99213 * r99213;
        double r99215 = r99212 - r99214;
        return r99215;
}

double f(double x, double y) {
        double r99216 = y;
        double r99217 = -r99216;
        double r99218 = x;
        double r99219 = fma(r99216, r99217, r99218);
        return r99219;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[x - y \cdot y\]
  2. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{x - {y}^{2}}\]
  3. Simplified0

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

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

Reproduce

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