Average Error: 6.1 → 5.8
Time: 14.7s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \le 4.1586096751525248895151859774550831747 \cdot 10^{293}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)\\ \end{array}\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \cdot z \le 4.1586096751525248895151859774550831747 \cdot 10^{293}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r451061 = x;
        double r451062 = r451061 * r451061;
        double r451063 = y;
        double r451064 = 4.0;
        double r451065 = r451063 * r451064;
        double r451066 = z;
        double r451067 = r451066 * r451066;
        double r451068 = t;
        double r451069 = r451067 - r451068;
        double r451070 = r451065 * r451069;
        double r451071 = r451062 - r451070;
        return r451071;
}

double f(double x, double y, double z, double t) {
        double r451072 = z;
        double r451073 = r451072 * r451072;
        double r451074 = 4.158609675152525e+293;
        bool r451075 = r451073 <= r451074;
        double r451076 = y;
        double r451077 = 4.0;
        double r451078 = r451076 * r451077;
        double r451079 = -r451072;
        double r451080 = t;
        double r451081 = fma(r451072, r451079, r451080);
        double r451082 = x;
        double r451083 = r451082 * r451082;
        double r451084 = fma(r451078, r451081, r451083);
        double r451085 = r451077 * r451080;
        double r451086 = fma(r451085, r451076, r451083);
        double r451087 = r451075 ? r451084 : r451086;
        return r451087;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (* z z) < 4.158609675152525e+293

    1. Initial program 0.1

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

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

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

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

    if 4.158609675152525e+293 < (* z z)

    1. Initial program 59.2

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

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

      \[\leadsto \color{blue}{{x}^{2} + 4 \cdot \left(t \cdot y\right)}\]
    4. Simplified55.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \le 4.1586096751525248895151859774550831747 \cdot 10^{293}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)\\ \end{array}\]

Reproduce

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