Average Error: 6.1 → 0.1
Time: 18.5s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(4 \cdot y, t, x \cdot x - \left(z \cdot \left(4 \cdot y\right)\right) \cdot z\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(4 \cdot y, t, x \cdot x - \left(z \cdot \left(4 \cdot y\right)\right) \cdot z\right)
double f(double x, double y, double z, double t) {
        double r28053196 = x;
        double r28053197 = r28053196 * r28053196;
        double r28053198 = y;
        double r28053199 = 4.0;
        double r28053200 = r28053198 * r28053199;
        double r28053201 = z;
        double r28053202 = r28053201 * r28053201;
        double r28053203 = t;
        double r28053204 = r28053202 - r28053203;
        double r28053205 = r28053200 * r28053204;
        double r28053206 = r28053197 - r28053205;
        return r28053206;
}

double f(double x, double y, double z, double t) {
        double r28053207 = 4.0;
        double r28053208 = y;
        double r28053209 = r28053207 * r28053208;
        double r28053210 = t;
        double r28053211 = x;
        double r28053212 = r28053211 * r28053211;
        double r28053213 = z;
        double r28053214 = r28053213 * r28053209;
        double r28053215 = r28053214 * r28053213;
        double r28053216 = r28053212 - r28053215;
        double r28053217 = fma(r28053209, r28053210, r28053216);
        return r28053217;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target6.1
Herbie0.1
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 6.1

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

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

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

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

Reproduce

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