Average Error: 6.3 → 0.1
Time: 18.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 \cdot y\right) \cdot t + \left(\left(4 \cdot y\right) \cdot z\right) \cdot \left(-z\right)\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \left(4 \cdot y\right) \cdot t + \left(\left(4 \cdot y\right) \cdot z\right) \cdot \left(-z\right)\right)
double f(double x, double y, double z, double t) {
        double r27973120 = x;
        double r27973121 = r27973120 * r27973120;
        double r27973122 = y;
        double r27973123 = 4.0;
        double r27973124 = r27973122 * r27973123;
        double r27973125 = z;
        double r27973126 = r27973125 * r27973125;
        double r27973127 = t;
        double r27973128 = r27973126 - r27973127;
        double r27973129 = r27973124 * r27973128;
        double r27973130 = r27973121 - r27973129;
        return r27973130;
}

double f(double x, double y, double z, double t) {
        double r27973131 = x;
        double r27973132 = 4.0;
        double r27973133 = y;
        double r27973134 = r27973132 * r27973133;
        double r27973135 = t;
        double r27973136 = r27973134 * r27973135;
        double r27973137 = z;
        double r27973138 = r27973134 * r27973137;
        double r27973139 = -r27973137;
        double r27973140 = r27973138 * r27973139;
        double r27973141 = r27973136 + r27973140;
        double r27973142 = fma(r27973131, r27973131, r27973141);
        return r27973142;
}

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, \left(t - z \cdot z\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(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\right)}\]
  5. Using strategy rm
  6. Applied sub-neg6.3

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

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

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

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

    \[\leadsto \mathsf{fma}\left(x, x, \left(4 \cdot y\right) \cdot t + \left(\left(4 \cdot y\right) \cdot z\right) \cdot \left(-z\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))))