Average Error: 11.3 → 1.0
Time: 15.2s
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 r419503 = x;
        double r419504 = y;
        double r419505 = 2.0;
        double r419506 = r419504 * r419505;
        double r419507 = z;
        double r419508 = r419506 * r419507;
        double r419509 = r419507 * r419505;
        double r419510 = r419509 * r419507;
        double r419511 = t;
        double r419512 = r419504 * r419511;
        double r419513 = r419510 - r419512;
        double r419514 = r419508 / r419513;
        double r419515 = r419503 - r419514;
        return r419515;
}

double f(double x, double y, double z, double t) {
        double r419516 = 2.0;
        double r419517 = z;
        double r419518 = r419517 * r419516;
        double r419519 = y;
        double r419520 = t;
        double r419521 = r419520 / r419517;
        double r419522 = r419519 * r419521;
        double r419523 = r419518 - r419522;
        double r419524 = r419516 / r419523;
        double r419525 = -r419524;
        double r419526 = x;
        double r419527 = fma(r419525, r419519, r419526);
        return r419527;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 11.3

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

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

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

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

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

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

Reproduce

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