Average Error: 6.2 → 3.3
Time: 23.5s
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 8.492390771886926299590046168507855606141 \cdot 10^{288}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(\left(y \cdot \left(\sqrt{t} + z\right)\right) \cdot \left(\sqrt{t} - z\right)\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 8.492390771886926299590046168507855606141 \cdot 10^{288}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot \left(t - z \cdot z\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r397550 = x;
        double r397551 = r397550 * r397550;
        double r397552 = y;
        double r397553 = 4.0;
        double r397554 = r397552 * r397553;
        double r397555 = z;
        double r397556 = r397555 * r397555;
        double r397557 = t;
        double r397558 = r397556 - r397557;
        double r397559 = r397554 * r397558;
        double r397560 = r397551 - r397559;
        return r397560;
}

double f(double x, double y, double z, double t) {
        double r397561 = z;
        double r397562 = r397561 * r397561;
        double r397563 = 8.492390771886926e+288;
        bool r397564 = r397562 <= r397563;
        double r397565 = x;
        double r397566 = 4.0;
        double r397567 = y;
        double r397568 = t;
        double r397569 = r397568 - r397562;
        double r397570 = r397567 * r397569;
        double r397571 = r397566 * r397570;
        double r397572 = fma(r397565, r397565, r397571);
        double r397573 = sqrt(r397568);
        double r397574 = r397573 + r397561;
        double r397575 = r397567 * r397574;
        double r397576 = r397573 - r397561;
        double r397577 = r397575 * r397576;
        double r397578 = r397566 * r397577;
        double r397579 = fma(r397565, r397565, r397578);
        double r397580 = r397564 ? r397572 : r397579;
        return r397580;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.2
Target6.2
Herbie3.3
\[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) < 8.492390771886926e+288

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
    2. Using strategy rm
    3. Applied fma-neg0.1

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

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

    if 8.492390771886926e+288 < (* z z)

    1. Initial program 56.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
    2. Using strategy rm
    3. Applied fma-neg56.1

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

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

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

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

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

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

Reproduce

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