Average Error: 5.4 → 0.1
Time: 25.6s
Precision: 64
\[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(4.0 \cdot y, t, x \cdot x - \left(z \cdot \left(4.0 \cdot y\right)\right) \cdot z\right)\]
x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(4.0 \cdot y, t, x \cdot x - \left(z \cdot \left(4.0 \cdot y\right)\right) \cdot z\right)
double f(double x, double y, double z, double t) {
        double r31288256 = x;
        double r31288257 = r31288256 * r31288256;
        double r31288258 = y;
        double r31288259 = 4.0;
        double r31288260 = r31288258 * r31288259;
        double r31288261 = z;
        double r31288262 = r31288261 * r31288261;
        double r31288263 = t;
        double r31288264 = r31288262 - r31288263;
        double r31288265 = r31288260 * r31288264;
        double r31288266 = r31288257 - r31288265;
        return r31288266;
}

double f(double x, double y, double z, double t) {
        double r31288267 = 4.0;
        double r31288268 = y;
        double r31288269 = r31288267 * r31288268;
        double r31288270 = t;
        double r31288271 = x;
        double r31288272 = r31288271 * r31288271;
        double r31288273 = z;
        double r31288274 = r31288273 * r31288269;
        double r31288275 = r31288274 * r31288273;
        double r31288276 = r31288272 - r31288275;
        double r31288277 = fma(r31288269, r31288270, r31288276);
        return r31288277;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 5.4

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

    \[\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. Taylor expanded around inf 5.4

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

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

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

Reproduce

herbie shell --seed 2019164 +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))))