Average Error: 6.1 → 0.1
Time: 9.4s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(x, x, \left(\left(y \cdot 4\right) \cdot t + \left(\left(y \cdot 4\right) \cdot z\right) \cdot \left(-z\right)\right) + \left(y \cdot 4\right) \cdot 0\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \left(\left(y \cdot 4\right) \cdot t + \left(\left(y \cdot 4\right) \cdot z\right) \cdot \left(-z\right)\right) + \left(y \cdot 4\right) \cdot 0\right)
double f(double x, double y, double z, double t) {
        double r715930 = x;
        double r715931 = r715930 * r715930;
        double r715932 = y;
        double r715933 = 4.0;
        double r715934 = r715932 * r715933;
        double r715935 = z;
        double r715936 = r715935 * r715935;
        double r715937 = t;
        double r715938 = r715936 - r715937;
        double r715939 = r715934 * r715938;
        double r715940 = r715931 - r715939;
        return r715940;
}

double f(double x, double y, double z, double t) {
        double r715941 = x;
        double r715942 = y;
        double r715943 = 4.0;
        double r715944 = r715942 * r715943;
        double r715945 = t;
        double r715946 = r715944 * r715945;
        double r715947 = z;
        double r715948 = r715944 * r715947;
        double r715949 = -r715947;
        double r715950 = r715948 * r715949;
        double r715951 = r715946 + r715950;
        double r715952 = 0.0;
        double r715953 = r715944 * r715952;
        double r715954 = r715951 + r715953;
        double r715955 = fma(r715941, r715941, r715954);
        return r715955;
}

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. Simplified6.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt35.3

    \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(\color{blue}{\sqrt{t} \cdot \sqrt{t}} - z \cdot z\right)\right)\]
  5. Applied prod-diff35.3

    \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{t}, \sqrt{t}, -z \cdot z\right) + \mathsf{fma}\left(-z, z, z \cdot z\right)\right)}\right)\]
  6. Applied distribute-lft-in35.3

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

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)} + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\]
  8. Using strategy rm
  9. Applied sub-neg6.1

    \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \color{blue}{\left(t + \left(-z \cdot z\right)\right)} + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\]
  10. Applied distribute-lft-in6.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(\left(y \cdot 4\right) \cdot t + \left(y \cdot 4\right) \cdot \left(-z \cdot z\right)\right)} + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\]
  11. Using strategy rm
  12. Applied distribute-rgt-neg-in6.1

    \[\leadsto \mathsf{fma}\left(x, x, \left(\left(y \cdot 4\right) \cdot t + \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot \left(-z\right)\right)}\right) + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\]
  13. Applied associate-*r*6.1

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

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

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

Reproduce

herbie shell --seed 2020027 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4) (- (* z z) t))))