Average Error: 6.0 → 0.4
Time: 14.4s
Precision: 64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\mathsf{fma}\left(x, x, \left(\left(\sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)} \cdot \sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)}\right) \cdot 4\right) \cdot \sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)} + \left(y \cdot t\right) \cdot 4\right)\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(x, x, \left(\left(\sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)} \cdot \sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)}\right) \cdot 4\right) \cdot \sqrt[3]{\left(-z\right) \cdot \left(z \cdot y\right)} + \left(y \cdot t\right) \cdot 4\right)
double f(double x, double y, double z, double t) {
        double r534492 = x;
        double r534493 = r534492 * r534492;
        double r534494 = y;
        double r534495 = 4.0;
        double r534496 = r534494 * r534495;
        double r534497 = z;
        double r534498 = r534497 * r534497;
        double r534499 = t;
        double r534500 = r534498 - r534499;
        double r534501 = r534496 * r534500;
        double r534502 = r534493 - r534501;
        return r534502;
}

double f(double x, double y, double z, double t) {
        double r534503 = x;
        double r534504 = z;
        double r534505 = -r534504;
        double r534506 = y;
        double r534507 = r534504 * r534506;
        double r534508 = r534505 * r534507;
        double r534509 = cbrt(r534508);
        double r534510 = r534509 * r534509;
        double r534511 = 4.0;
        double r534512 = r534510 * r534511;
        double r534513 = r534512 * r534509;
        double r534514 = t;
        double r534515 = r534506 * r534514;
        double r534516 = r534515 * r534511;
        double r534517 = r534513 + r534516;
        double r534518 = fma(r534503, r534503, r534517);
        return r534518;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.0
Target6.0
Herbie0.4
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]

Derivation

  1. Initial program 6.0

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

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

    \[\leadsto \color{blue}{\left(4 \cdot \left(t \cdot y\right) + {x}^{2}\right) - 4 \cdot \left({z}^{2} \cdot y\right)}\]
  4. Simplified6.0

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

    \[\leadsto \mathsf{fma}\left(x, x, \left(4 \cdot y\right) \cdot \color{blue}{\left(z \cdot \left(-z\right) + t\right)}\right)\]
  7. Applied distribute-lft-in6.0

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(\left(\sqrt[3]{\left(-y \cdot z\right) \cdot z} \cdot \sqrt[3]{\left(-y \cdot z\right) \cdot z}\right) \cdot 4\right)} \cdot \sqrt[3]{-\left(y \cdot z\right) \cdot z} + 4 \cdot \left(y \cdot t\right)\right)\]
  14. Final simplification0.4

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

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))