Average Error: 6.0 → 5.2
Time: 14.8s
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.779323173656371328095136162218814029535 \cdot 10^{308}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, 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 1.779323173656371328095136162218814029535 \cdot 10^{308}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, 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 r380197 = x;
        double r380198 = r380197 * r380197;
        double r380199 = y;
        double r380200 = 4.0;
        double r380201 = r380199 * r380200;
        double r380202 = z;
        double r380203 = r380202 * r380202;
        double r380204 = t;
        double r380205 = r380203 - r380204;
        double r380206 = r380201 * r380205;
        double r380207 = r380198 - r380206;
        return r380207;
}

double f(double x, double y, double z, double t) {
        double r380208 = z;
        double r380209 = r380208 * r380208;
        double r380210 = 1.7793231736563713e+308;
        bool r380211 = r380209 <= r380210;
        double r380212 = y;
        double r380213 = 4.0;
        double r380214 = r380212 * r380213;
        double r380215 = t;
        double r380216 = r380215 - r380209;
        double r380217 = x;
        double r380218 = r380217 * r380217;
        double r380219 = fma(r380214, r380216, r380218);
        double r380220 = r380213 * r380215;
        double r380221 = fma(r380220, r380212, r380218);
        double r380222 = r380211 ? r380219 : r380221;
        return r380222;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.0
Target6.0
Herbie5.2
\[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.7793231736563713e+308

    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.7793231736563713e+308 < (* z z)

    1. Initial program 64.0

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

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

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

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

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

Reproduce

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