Average Error: 5.6 → 0.1
Time: 23.5s
Precision: 64
\[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(t, y \cdot 4.0, x \cdot x - \left(\left(y \cdot 4.0\right) \cdot z\right) \cdot z\right)\]
x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(t, y \cdot 4.0, x \cdot x - \left(\left(y \cdot 4.0\right) \cdot z\right) \cdot z\right)
double f(double x, double y, double z, double t) {
        double r29221817 = x;
        double r29221818 = r29221817 * r29221817;
        double r29221819 = y;
        double r29221820 = 4.0;
        double r29221821 = r29221819 * r29221820;
        double r29221822 = z;
        double r29221823 = r29221822 * r29221822;
        double r29221824 = t;
        double r29221825 = r29221823 - r29221824;
        double r29221826 = r29221821 * r29221825;
        double r29221827 = r29221818 - r29221826;
        return r29221827;
}

double f(double x, double y, double z, double t) {
        double r29221828 = t;
        double r29221829 = y;
        double r29221830 = 4.0;
        double r29221831 = r29221829 * r29221830;
        double r29221832 = x;
        double r29221833 = r29221832 * r29221832;
        double r29221834 = z;
        double r29221835 = r29221831 * r29221834;
        double r29221836 = r29221835 * r29221834;
        double r29221837 = r29221833 - r29221836;
        double r29221838 = fma(r29221828, r29221831, r29221837);
        return r29221838;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.6
Target5.5
Herbie0.1
\[x \cdot x - 4.0 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 5.6

    \[x \cdot x - \left(y \cdot 4.0\right) \cdot \left(z \cdot z - t\right)\]
  2. Taylor expanded around inf 5.5

    \[\leadsto \color{blue}{\left(4.0 \cdot \left(t \cdot y\right) + {x}^{2}\right) - 4.0 \cdot \left({z}^{2} \cdot y\right)}\]
  3. Simplified0.1

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

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

Reproduce

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