Average Error: 6.0 → 5.1
Time: 22.3s
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 1.74167072786424358840619269190592420354 \cdot 10^{306}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot y, 4, 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 1.74167072786424358840619269190592420354 \cdot 10^{306}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r478980 = x;
        double r478981 = r478980 * r478980;
        double r478982 = y;
        double r478983 = 4.0;
        double r478984 = r478982 * r478983;
        double r478985 = z;
        double r478986 = r478985 * r478985;
        double r478987 = t;
        double r478988 = r478986 - r478987;
        double r478989 = r478984 * r478988;
        double r478990 = r478981 - r478989;
        return r478990;
}

double f(double x, double y, double z, double t) {
        double r478991 = z;
        double r478992 = r478991 * r478991;
        double r478993 = 1.7416707278642436e+306;
        bool r478994 = r478992 <= r478993;
        double r478995 = y;
        double r478996 = 4.0;
        double r478997 = r478995 * r478996;
        double r478998 = t;
        double r478999 = r478998 - r478992;
        double r479000 = x;
        double r479001 = r479000 * r479000;
        double r479002 = fma(r478997, r478999, r479001);
        double r479003 = r478998 * r478995;
        double r479004 = fma(r479003, r478996, r479001);
        double r479005 = r478994 ? r479002 : r479004;
        return r479005;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.0
Target6.0
Herbie5.1
\[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) < 1.7416707278642436e+306

    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)}\]

    if 1.7416707278642436e+306 < (* z z)

    1. Initial program 63.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt63.4

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

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

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

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

Reproduce

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