Average Error: 11.4 → 1.0
Time: 13.6s
Precision: 64
\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
\[\mathsf{fma}\left(-\frac{2}{z \cdot 2 - \frac{y}{\frac{z}{t}}}, y, x\right)\]
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\mathsf{fma}\left(-\frac{2}{z \cdot 2 - \frac{y}{\frac{z}{t}}}, y, x\right)
double f(double x, double y, double z, double t) {
        double r314850 = x;
        double r314851 = y;
        double r314852 = 2.0;
        double r314853 = r314851 * r314852;
        double r314854 = z;
        double r314855 = r314853 * r314854;
        double r314856 = r314854 * r314852;
        double r314857 = r314856 * r314854;
        double r314858 = t;
        double r314859 = r314851 * r314858;
        double r314860 = r314857 - r314859;
        double r314861 = r314855 / r314860;
        double r314862 = r314850 - r314861;
        return r314862;
}

double f(double x, double y, double z, double t) {
        double r314863 = 2.0;
        double r314864 = z;
        double r314865 = r314864 * r314863;
        double r314866 = y;
        double r314867 = t;
        double r314868 = r314864 / r314867;
        double r314869 = r314866 / r314868;
        double r314870 = r314865 - r314869;
        double r314871 = r314863 / r314870;
        double r314872 = -r314871;
        double r314873 = x;
        double r314874 = fma(r314872, r314866, r314873);
        return r314874;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original11.4
Target0.1
Herbie1.0
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}\]

Derivation

  1. Initial program 11.4

    \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
  2. Simplified2.8

    \[\leadsto \color{blue}{\mathsf{fma}\left(-\frac{2}{z \cdot 2 - \frac{y \cdot t}{z}}, y, x\right)}\]
  3. Using strategy rm
  4. Applied associate-/l*1.0

    \[\leadsto \mathsf{fma}\left(-\frac{2}{z \cdot 2 - \color{blue}{\frac{y}{\frac{z}{t}}}}, y, x\right)\]
  5. Final simplification1.0

    \[\leadsto \mathsf{fma}\left(-\frac{2}{z \cdot 2 - \frac{y}{\frac{z}{t}}}, y, x\right)\]

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"
  :precision binary64

  :herbie-target
  (- x (/ 1 (- (/ z y) (/ (/ t 2) z))))

  (- x (/ (* (* y 2) z) (- (* (* z 2) z) (* y t)))))