Average Error: 5.4 → 5.4
Time: 22.6s
Precision: 64
\[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(t - z \cdot z, y \cdot 4.0, x \cdot x\right)\]
x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(t - z \cdot z, y \cdot 4.0, x \cdot x\right)
double f(double x, double y, double z, double t) {
        double r28916197 = x;
        double r28916198 = r28916197 * r28916197;
        double r28916199 = y;
        double r28916200 = 4.0;
        double r28916201 = r28916199 * r28916200;
        double r28916202 = z;
        double r28916203 = r28916202 * r28916202;
        double r28916204 = t;
        double r28916205 = r28916203 - r28916204;
        double r28916206 = r28916201 * r28916205;
        double r28916207 = r28916198 - r28916206;
        return r28916207;
}

double f(double x, double y, double z, double t) {
        double r28916208 = t;
        double r28916209 = z;
        double r28916210 = r28916209 * r28916209;
        double r28916211 = r28916208 - r28916210;
        double r28916212 = y;
        double r28916213 = 4.0;
        double r28916214 = r28916212 * r28916213;
        double r28916215 = x;
        double r28916216 = r28916215 * r28916215;
        double r28916217 = fma(r28916211, r28916214, r28916216);
        return r28916217;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.4
Target5.4
Herbie5.4
\[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. Simplified5.4

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

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

Reproduce

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