Average Error: 6.1 → 5.8
Time: 16.9s
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 r407130 = x;
        double r407131 = r407130 * r407130;
        double r407132 = y;
        double r407133 = 4.0;
        double r407134 = r407132 * r407133;
        double r407135 = z;
        double r407136 = r407135 * r407135;
        double r407137 = t;
        double r407138 = r407136 - r407137;
        double r407139 = r407134 * r407138;
        double r407140 = r407131 - r407139;
        return r407140;
}

double f(double x, double y, double z, double t) {
        double r407141 = z;
        double r407142 = r407141 * r407141;
        double r407143 = 4.158609675152525e+293;
        bool r407144 = r407142 <= r407143;
        double r407145 = y;
        double r407146 = 4.0;
        double r407147 = r407145 * r407146;
        double r407148 = -r407141;
        double r407149 = t;
        double r407150 = fma(r407141, r407148, r407149);
        double r407151 = x;
        double r407152 = r407151 * r407151;
        double r407153 = fma(r407147, r407150, r407152);
        double r407154 = r407146 * r407149;
        double r407155 = fma(r407154, r407145, r407152);
        double r407156 = r407144 ? r407153 : r407155;
        return r407156;
}

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))))