Average Error: 11.7 → 6.4
Time: 16.7s
Precision: 64
\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
\[\mathsf{fma}\left(z \cdot \frac{2}{\mathsf{fma}\left(-y, t, \left(z \cdot 2\right) \cdot z\right)}, -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(z \cdot \frac{2}{\mathsf{fma}\left(-y, t, \left(z \cdot 2\right) \cdot z\right)}, -y, x\right)
double f(double x, double y, double z, double t) {
        double r23368939 = x;
        double r23368940 = y;
        double r23368941 = 2.0;
        double r23368942 = r23368940 * r23368941;
        double r23368943 = z;
        double r23368944 = r23368942 * r23368943;
        double r23368945 = r23368943 * r23368941;
        double r23368946 = r23368945 * r23368943;
        double r23368947 = t;
        double r23368948 = r23368940 * r23368947;
        double r23368949 = r23368946 - r23368948;
        double r23368950 = r23368944 / r23368949;
        double r23368951 = r23368939 - r23368950;
        return r23368951;
}

double f(double x, double y, double z, double t) {
        double r23368952 = z;
        double r23368953 = 2.0;
        double r23368954 = y;
        double r23368955 = -r23368954;
        double r23368956 = t;
        double r23368957 = r23368952 * r23368953;
        double r23368958 = r23368957 * r23368952;
        double r23368959 = fma(r23368955, r23368956, r23368958);
        double r23368960 = r23368953 / r23368959;
        double r23368961 = r23368952 * r23368960;
        double r23368962 = x;
        double r23368963 = fma(r23368961, r23368955, r23368962);
        return r23368963;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original11.7
Target0.1
Herbie6.4
\[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. Simplified6.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot 2}{\mathsf{fma}\left(-y, t, \left(z \cdot 2\right) \cdot z\right)}, -y, x\right)}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity6.1

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

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

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

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

Reproduce

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

  :herbie-target
  (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))

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