Average Error: 6.0 → 0.1
Time: 17.0s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\left(t \cdot y\right) \cdot 4 + \mathsf{fma}\left(-z, \left(y \cdot z\right) \cdot 4, {x}^{2}\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\left(t \cdot y\right) \cdot 4 + \mathsf{fma}\left(-z, \left(y \cdot z\right) \cdot 4, {x}^{2}\right)
double f(double x, double y, double z, double t) {
        double r556094 = x;
        double r556095 = r556094 * r556094;
        double r556096 = y;
        double r556097 = 4.0;
        double r556098 = r556096 * r556097;
        double r556099 = z;
        double r556100 = r556099 * r556099;
        double r556101 = t;
        double r556102 = r556100 - r556101;
        double r556103 = r556098 * r556102;
        double r556104 = r556095 - r556103;
        return r556104;
}

double f(double x, double y, double z, double t) {
        double r556105 = t;
        double r556106 = y;
        double r556107 = r556105 * r556106;
        double r556108 = 4.0;
        double r556109 = r556107 * r556108;
        double r556110 = z;
        double r556111 = -r556110;
        double r556112 = r556106 * r556110;
        double r556113 = r556112 * r556108;
        double r556114 = x;
        double r556115 = 2.0;
        double r556116 = pow(r556114, r556115);
        double r556117 = fma(r556111, r556113, r556116);
        double r556118 = r556109 + r556117;
        return r556118;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 6.0

    \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
  2. Using strategy rm
  3. Applied sub-neg6.0

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

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

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

    \[\leadsto x \cdot x - \left(\left(\left(4 \cdot y\right) \cdot z\right) \cdot z + \color{blue}{4 \cdot \left(y \cdot \left(-t\right)\right)}\right)\]
  7. Using strategy rm
  8. Applied distribute-rgt-neg-out0.1

    \[\leadsto x \cdot x - \left(\left(\left(4 \cdot y\right) \cdot z\right) \cdot z + 4 \cdot \color{blue}{\left(-y \cdot t\right)}\right)\]
  9. Applied distribute-rgt-neg-out0.1

    \[\leadsto x \cdot x - \left(\left(\left(4 \cdot y\right) \cdot z\right) \cdot z + \color{blue}{\left(-4 \cdot \left(y \cdot t\right)\right)}\right)\]
  10. Applied unsub-neg0.1

    \[\leadsto x \cdot x - \color{blue}{\left(\left(\left(4 \cdot y\right) \cdot z\right) \cdot z - 4 \cdot \left(y \cdot t\right)\right)}\]
  11. Applied associate--r-0.1

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

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

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

Reproduce

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