Average Error: 6.1 → 3.9
Time: 5.6s
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.2800532743869097 \cdot 10^{275}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right) + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(\left(y \cdot 4\right) \cdot \left(\sqrt{t} + z\right)\right) \cdot \left(\sqrt{t} - z\right)\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.2800532743869097 \cdot 10^{275}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right) + \left(y \cdot 4\right) \cdot \mathsf{fma}\left(-z, z, z \cdot z\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r621503 = x;
        double r621504 = r621503 * r621503;
        double r621505 = y;
        double r621506 = 4.0;
        double r621507 = r621505 * r621506;
        double r621508 = z;
        double r621509 = r621508 * r621508;
        double r621510 = t;
        double r621511 = r621509 - r621510;
        double r621512 = r621507 * r621511;
        double r621513 = r621504 - r621512;
        return r621513;
}

double f(double x, double y, double z, double t) {
        double r621514 = z;
        double r621515 = r621514 * r621514;
        double r621516 = 1.2800532743869097e+275;
        bool r621517 = r621515 <= r621516;
        double r621518 = x;
        double r621519 = y;
        double r621520 = 4.0;
        double r621521 = r621519 * r621520;
        double r621522 = t;
        double r621523 = r621522 - r621515;
        double r621524 = r621521 * r621523;
        double r621525 = -r621514;
        double r621526 = fma(r621525, r621514, r621515);
        double r621527 = r621521 * r621526;
        double r621528 = r621524 + r621527;
        double r621529 = fma(r621518, r621518, r621528);
        double r621530 = sqrt(r621522);
        double r621531 = r621530 + r621514;
        double r621532 = r621521 * r621531;
        double r621533 = r621530 - r621514;
        double r621534 = r621532 * r621533;
        double r621535 = fma(r621518, r621518, r621534);
        double r621536 = r621517 ? r621529 : r621535;
        return r621536;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target6.1
Herbie3.9
\[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.2800532743869097e+275

    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(x, x, \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt32.2

      \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(\color{blue}{\sqrt{t} \cdot \sqrt{t}} - z \cdot z\right)\right)\]
    5. Applied prod-diff32.2

      \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{t}, \sqrt{t}, -z \cdot z\right) + \mathsf{fma}\left(-z, z, z \cdot z\right)\right)}\right)\]
    6. Applied distribute-lft-in32.1

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

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

    if 1.2800532743869097e+275 < (* z z)

    1. Initial program 52.0

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

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

      \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(\color{blue}{\sqrt{t} \cdot \sqrt{t}} - z \cdot z\right)\right)\]
    5. Applied difference-of-squares58.4

      \[\leadsto \mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \color{blue}{\left(\left(\sqrt{t} + z\right) \cdot \left(\sqrt{t} - z\right)\right)}\right)\]
    6. Applied associate-*r*32.9

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(\left(y \cdot 4\right) \cdot \left(\sqrt{t} + z\right)\right) \cdot \left(\sqrt{t} - z\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.9

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

Reproduce

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