Average Error: 5.8 → 0.1
Time: 17.0s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(4 \cdot y, t, \left(\left(4 \cdot y\right) \cdot z\right) \cdot \left(-z\right)\right)\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \mathsf{fma}\left(4 \cdot y, t, \left(\left(4 \cdot y\right) \cdot z\right) \cdot \left(-z\right)\right)\right)
double f(double x, double y, double z, double t) {
        double r27645122 = x;
        double r27645123 = r27645122 * r27645122;
        double r27645124 = y;
        double r27645125 = 4.0;
        double r27645126 = r27645124 * r27645125;
        double r27645127 = z;
        double r27645128 = r27645127 * r27645127;
        double r27645129 = t;
        double r27645130 = r27645128 - r27645129;
        double r27645131 = r27645126 * r27645130;
        double r27645132 = r27645123 - r27645131;
        return r27645132;
}

double f(double x, double y, double z, double t) {
        double r27645133 = x;
        double r27645134 = 4.0;
        double r27645135 = y;
        double r27645136 = r27645134 * r27645135;
        double r27645137 = t;
        double r27645138 = z;
        double r27645139 = r27645136 * r27645138;
        double r27645140 = -r27645138;
        double r27645141 = r27645139 * r27645140;
        double r27645142 = fma(r27645136, r27645137, r27645141);
        double r27645143 = fma(r27645133, r27645133, r27645142);
        return r27645143;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 5.8

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

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

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

    \[\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-neg5.8

    \[\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-in5.8

    \[\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-in5.8

    \[\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. Using strategy rm
  12. Applied fma-def0.1

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

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

Reproduce

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