Average Error: 5.9 → 5.9
Time: 14.7s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x \cdot x\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x \cdot x\right)
double f(double x, double y, double z, double t) {
        double r851367 = x;
        double r851368 = r851367 * r851367;
        double r851369 = y;
        double r851370 = 4.0;
        double r851371 = r851369 * r851370;
        double r851372 = z;
        double r851373 = r851372 * r851372;
        double r851374 = t;
        double r851375 = r851373 - r851374;
        double r851376 = r851371 * r851375;
        double r851377 = r851368 - r851376;
        return r851377;
}

double f(double x, double y, double z, double t) {
        double r851378 = y;
        double r851379 = 4.0;
        double r851380 = r851378 * r851379;
        double r851381 = z;
        double r851382 = -r851381;
        double r851383 = t;
        double r851384 = fma(r851381, r851382, r851383);
        double r851385 = x;
        double r851386 = r851385 * r851385;
        double r851387 = fma(r851380, r851384, r851386);
        return r851387;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.9
Target5.9
Herbie5.9
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 5.9

    \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
  2. Simplified5.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)}\]
  3. Taylor expanded around 0 5.9

    \[\leadsto \mathsf{fma}\left(y \cdot 4, \color{blue}{t - {z}^{2}}, x \cdot x\right)\]
  4. Simplified5.9

    \[\leadsto \mathsf{fma}\left(y \cdot 4, \color{blue}{\mathsf{fma}\left(z, -z, t\right)}, x \cdot x\right)\]
  5. Final simplification5.9

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

Reproduce

herbie shell --seed 2019350 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4) (- (* z z) t))))