Average Error: 6.3 → 0.1
Time: 16.6s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(x, x, \left(-4\right) \cdot \left(z \cdot \left(y \cdot z\right)\right) + 4 \cdot \left(y \cdot t\right)\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \left(-4\right) \cdot \left(z \cdot \left(y \cdot z\right)\right) + 4 \cdot \left(y \cdot t\right)\right)
double f(double x, double y, double z, double t) {
        double r547899 = x;
        double r547900 = r547899 * r547899;
        double r547901 = y;
        double r547902 = 4.0;
        double r547903 = r547901 * r547902;
        double r547904 = z;
        double r547905 = r547904 * r547904;
        double r547906 = t;
        double r547907 = r547905 - r547906;
        double r547908 = r547903 * r547907;
        double r547909 = r547900 - r547908;
        return r547909;
}

double f(double x, double y, double z, double t) {
        double r547910 = x;
        double r547911 = 4.0;
        double r547912 = -r547911;
        double r547913 = z;
        double r547914 = y;
        double r547915 = r547914 * r547913;
        double r547916 = r547913 * r547915;
        double r547917 = r547912 * r547916;
        double r547918 = t;
        double r547919 = r547914 * r547918;
        double r547920 = r547911 * r547919;
        double r547921 = r547917 + r547920;
        double r547922 = fma(r547910, r547910, r547921);
        return r547922;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 6.3

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

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

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

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

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

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

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

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

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

Reproduce

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