Average Error: 11.7 → 1.1
Time: 11.0s
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 - y \cdot \frac{t}{z}}, 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 - y \cdot \frac{t}{z}}, y, x\right)
double f(double x, double y, double z, double t) {
        double r362982 = x;
        double r362983 = y;
        double r362984 = 2.0;
        double r362985 = r362983 * r362984;
        double r362986 = z;
        double r362987 = r362985 * r362986;
        double r362988 = r362986 * r362984;
        double r362989 = r362988 * r362986;
        double r362990 = t;
        double r362991 = r362983 * r362990;
        double r362992 = r362989 - r362991;
        double r362993 = r362987 / r362992;
        double r362994 = r362982 - r362993;
        return r362994;
}

double f(double x, double y, double z, double t) {
        double r362995 = 2.0;
        double r362996 = z;
        double r362997 = r362996 * r362995;
        double r362998 = y;
        double r362999 = t;
        double r363000 = r362999 / r362996;
        double r363001 = r362998 * r363000;
        double r363002 = r362997 - r363001;
        double r363003 = r362995 / r363002;
        double r363004 = -r363003;
        double r363005 = x;
        double r363006 = fma(r363004, r362998, r363005);
        return r363006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 11.7

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

    \[\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 *-un-lft-identity2.9

    \[\leadsto \mathsf{fma}\left(-\frac{2}{z \cdot 2 - \frac{y \cdot t}{\color{blue}{1 \cdot z}}}, y, x\right)\]
  5. Applied times-frac1.1

    \[\leadsto \mathsf{fma}\left(-\frac{2}{z \cdot 2 - \color{blue}{\frac{y}{1} \cdot \frac{t}{z}}}, y, x\right)\]
  6. Simplified1.1

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

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

Reproduce

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