Average Error: 5.9 → 5.9
Time: 18.3s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)
double f(double x, double y, double z, double t) {
        double r419021 = x;
        double r419022 = r419021 * r419021;
        double r419023 = y;
        double r419024 = 4.0;
        double r419025 = r419023 * r419024;
        double r419026 = z;
        double r419027 = r419026 * r419026;
        double r419028 = t;
        double r419029 = r419027 - r419028;
        double r419030 = r419025 * r419029;
        double r419031 = r419022 - r419030;
        return r419031;
}

double f(double x, double y, double z, double t) {
        double r419032 = y;
        double r419033 = 4.0;
        double r419034 = r419032 * r419033;
        double r419035 = t;
        double r419036 = z;
        double r419037 = r419036 * r419036;
        double r419038 = r419035 - r419037;
        double r419039 = x;
        double r419040 = r419039 * r419039;
        double r419041 = fma(r419034, r419038, r419040);
        return r419041;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.9
Target5.9
Herbie5.9
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 5.9

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

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

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

Reproduce

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