Average Error: 6.1 → 3.6
Time: 20.1s
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.115603923917577888101985386124792974105 \cdot 10^{283}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - {z}^{2}\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 8.115603923917577888101985386124792974105 \cdot 10^{283}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - {z}^{2}\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 r374752 = x;
        double r374753 = r374752 * r374752;
        double r374754 = y;
        double r374755 = 4.0;
        double r374756 = r374754 * r374755;
        double r374757 = z;
        double r374758 = r374757 * r374757;
        double r374759 = t;
        double r374760 = r374758 - r374759;
        double r374761 = r374756 * r374760;
        double r374762 = r374753 - r374761;
        return r374762;
}

double f(double x, double y, double z, double t) {
        double r374763 = z;
        double r374764 = r374763 * r374763;
        double r374765 = 8.115603923917578e+283;
        bool r374766 = r374764 <= r374765;
        double r374767 = x;
        double r374768 = y;
        double r374769 = 4.0;
        double r374770 = r374768 * r374769;
        double r374771 = t;
        double r374772 = 2.0;
        double r374773 = pow(r374763, r374772);
        double r374774 = r374771 - r374773;
        double r374775 = r374770 * r374774;
        double r374776 = fma(r374767, r374767, r374775);
        double r374777 = sqrt(r374771);
        double r374778 = r374777 + r374763;
        double r374779 = r374770 * r374778;
        double r374780 = r374777 - r374763;
        double r374781 = r374779 * r374780;
        double r374782 = fma(r374767, r374767, r374781);
        double r374783 = r374766 ? r374776 : r374782;
        return r374783;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.1
Target6.0
Herbie3.6
\[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.115603923917578e+283

    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}{\left(y \cdot 4\right) \cdot \left(t - {z}^{2}\right)}\right)\]

    if 8.115603923917578e+283 < (* z z)

    1. Initial program 55.6

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

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

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

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

      \[\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)\]
    8. Applied difference-of-squares59.3

      \[\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)\]
    9. Applied associate-*r*32.2

      \[\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.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \le 8.115603923917577888101985386124792974105 \cdot 10^{283}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot \left(t - {z}^{2}\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 2019347 +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))))