Average Error: 5.5 → 0.1
Time: 22.7s
Precision: 64
\[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(y \cdot t, 4.0, x \cdot x - z \cdot \left(\left(4.0 \cdot y\right) \cdot z\right)\right)\]
x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(y \cdot t, 4.0, x \cdot x - z \cdot \left(\left(4.0 \cdot y\right) \cdot z\right)\right)
double f(double x, double y, double z, double t) {
        double r21830306 = x;
        double r21830307 = r21830306 * r21830306;
        double r21830308 = y;
        double r21830309 = 4.0;
        double r21830310 = r21830308 * r21830309;
        double r21830311 = z;
        double r21830312 = r21830311 * r21830311;
        double r21830313 = t;
        double r21830314 = r21830312 - r21830313;
        double r21830315 = r21830310 * r21830314;
        double r21830316 = r21830307 - r21830315;
        return r21830316;
}

double f(double x, double y, double z, double t) {
        double r21830317 = y;
        double r21830318 = t;
        double r21830319 = r21830317 * r21830318;
        double r21830320 = 4.0;
        double r21830321 = x;
        double r21830322 = r21830321 * r21830321;
        double r21830323 = z;
        double r21830324 = r21830320 * r21830317;
        double r21830325 = r21830324 * r21830323;
        double r21830326 = r21830323 * r21830325;
        double r21830327 = r21830322 - r21830326;
        double r21830328 = fma(r21830319, r21830320, r21830327);
        return r21830328;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.5
Target5.5
Herbie0.1
\[x \cdot x - 4.0 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 5.5

    \[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
  2. Taylor expanded around inf 5.5

    \[\leadsto \color{blue}{\left(4.0 \cdot \left(t \cdot y\right) + {x}^{2}\right) - 4.0 \cdot \left({z}^{2} \cdot y\right)}\]
  3. Simplified0.1

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

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

Reproduce

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

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

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