Average Error: 6.1 → 0.1
Time: 3.5s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot t + \left(\left(y \cdot 4\right) \cdot \left(-z\right)\right) \cdot z\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot t + \left(\left(y \cdot 4\right) \cdot \left(-z\right)\right) \cdot z\right)
double f(double x, double y, double z, double t) {
        double r612348 = x;
        double r612349 = r612348 * r612348;
        double r612350 = y;
        double r612351 = 4.0;
        double r612352 = r612350 * r612351;
        double r612353 = z;
        double r612354 = r612353 * r612353;
        double r612355 = t;
        double r612356 = r612354 - r612355;
        double r612357 = r612352 * r612356;
        double r612358 = r612349 - r612357;
        return r612358;
}

double f(double x, double y, double z, double t) {
        double r612359 = x;
        double r612360 = y;
        double r612361 = 4.0;
        double r612362 = r612360 * r612361;
        double r612363 = t;
        double r612364 = r612362 * r612363;
        double r612365 = z;
        double r612366 = -r612365;
        double r612367 = r612362 * r612366;
        double r612368 = r612367 * r612365;
        double r612369 = r612364 + r612368;
        double r612370 = fma(r612359, r612359, r612369);
        return r612370;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target6.0
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 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)}\right)\]
  5. Applied distribute-lft-in6.1

    \[\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)\]
  6. Using strategy rm
  7. Applied distribute-lft-neg-in6.1

    \[\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)\]
  8. 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)\]
  9. Final simplification0.1

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

Reproduce

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