Average Error: 5.9 → 0.1
Time: 43.0s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(t, 4 \cdot y, x \cdot x - \left(\left(4 \cdot y\right) \cdot z\right) \cdot z\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(t, 4 \cdot y, x \cdot x - \left(\left(4 \cdot y\right) \cdot z\right) \cdot z\right)
double f(double x, double y, double z, double t) {
        double r29350086 = x;
        double r29350087 = r29350086 * r29350086;
        double r29350088 = y;
        double r29350089 = 4.0;
        double r29350090 = r29350088 * r29350089;
        double r29350091 = z;
        double r29350092 = r29350091 * r29350091;
        double r29350093 = t;
        double r29350094 = r29350092 - r29350093;
        double r29350095 = r29350090 * r29350094;
        double r29350096 = r29350087 - r29350095;
        return r29350096;
}

double f(double x, double y, double z, double t) {
        double r29350097 = t;
        double r29350098 = 4.0;
        double r29350099 = y;
        double r29350100 = r29350098 * r29350099;
        double r29350101 = x;
        double r29350102 = r29350101 * r29350101;
        double r29350103 = z;
        double r29350104 = r29350100 * r29350103;
        double r29350105 = r29350104 * r29350103;
        double r29350106 = r29350102 - r29350105;
        double r29350107 = fma(r29350097, r29350100, r29350106);
        return r29350107;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 5.9

    \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
  2. Using strategy rm
  3. Applied fma-neg5.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, -\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)}\]
  4. Taylor expanded around inf 5.9

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

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

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

Reproduce

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