Average Error: 5.7 → 5.7
Time: 34.5s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(t - z \cdot z, 4 \cdot y, x \cdot x\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(t - z \cdot z, 4 \cdot y, x \cdot x\right)
double f(double x, double y, double z, double t) {
        double r29868922 = x;
        double r29868923 = r29868922 * r29868922;
        double r29868924 = y;
        double r29868925 = 4.0;
        double r29868926 = r29868924 * r29868925;
        double r29868927 = z;
        double r29868928 = r29868927 * r29868927;
        double r29868929 = t;
        double r29868930 = r29868928 - r29868929;
        double r29868931 = r29868926 * r29868930;
        double r29868932 = r29868923 - r29868931;
        return r29868932;
}

double f(double x, double y, double z, double t) {
        double r29868933 = t;
        double r29868934 = z;
        double r29868935 = r29868934 * r29868934;
        double r29868936 = r29868933 - r29868935;
        double r29868937 = 4.0;
        double r29868938 = y;
        double r29868939 = r29868937 * r29868938;
        double r29868940 = x;
        double r29868941 = r29868940 * r29868940;
        double r29868942 = fma(r29868936, r29868939, r29868941);
        return r29868942;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 5.7

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

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

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

Reproduce

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