Average Error: 11.7 → 2.8
Time: 5.3s
Precision: 64
\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\ \;\;\;\;x - \frac{1}{\frac{z \cdot 2 - t \cdot \frac{y}{z}}{y \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\left(z \cdot 2\right) \cdot z - y \cdot t} \cdot \left(z \cdot 2\right)\\ \end{array}\]
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\begin{array}{l}
\mathbf{if}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\
\;\;\;\;x - \frac{1}{\frac{z \cdot 2 - t \cdot \frac{y}{z}}{y \cdot 2}}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\left(z \cdot 2\right) \cdot z - y \cdot t} \cdot \left(z \cdot 2\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r562309 = x;
        double r562310 = y;
        double r562311 = 2.0;
        double r562312 = r562310 * r562311;
        double r562313 = z;
        double r562314 = r562312 * r562313;
        double r562315 = r562313 * r562311;
        double r562316 = r562315 * r562313;
        double r562317 = t;
        double r562318 = r562310 * r562317;
        double r562319 = r562316 - r562318;
        double r562320 = r562314 / r562319;
        double r562321 = r562309 - r562320;
        return r562321;
}

double f(double x, double y, double z, double t) {
        double r562322 = z;
        double r562323 = -7.171100663984459e-219;
        bool r562324 = r562322 <= r562323;
        double r562325 = 3.8725642139486444e-297;
        bool r562326 = r562322 <= r562325;
        double r562327 = !r562326;
        bool r562328 = r562324 || r562327;
        double r562329 = x;
        double r562330 = 1.0;
        double r562331 = 2.0;
        double r562332 = r562322 * r562331;
        double r562333 = t;
        double r562334 = y;
        double r562335 = r562334 / r562322;
        double r562336 = r562333 * r562335;
        double r562337 = r562332 - r562336;
        double r562338 = r562334 * r562331;
        double r562339 = r562337 / r562338;
        double r562340 = r562330 / r562339;
        double r562341 = r562329 - r562340;
        double r562342 = r562332 * r562322;
        double r562343 = r562334 * r562333;
        double r562344 = r562342 - r562343;
        double r562345 = r562334 / r562344;
        double r562346 = r562345 * r562332;
        double r562347 = r562329 - r562346;
        double r562348 = r562328 ? r562341 : r562347;
        return r562348;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if z < -7.171100663984459e-219 or 3.8725642139486444e-297 < z

    1. Initial program 11.9

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Using strategy rm
    3. Applied associate-/l*6.8

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    4. Using strategy rm
    5. Applied div-sub6.8

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{\frac{\left(z \cdot 2\right) \cdot z}{z} - \frac{y \cdot t}{z}}}\]
    6. Simplified2.7

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{z \cdot 2} - \frac{y \cdot t}{z}}\]
    7. Simplified2.7

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t \cdot y}{z}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity2.7

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \frac{t \cdot y}{\color{blue}{1 \cdot z}}}\]
    10. Applied times-frac2.3

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t}{1} \cdot \frac{y}{z}}}\]
    11. Simplified2.3

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{t} \cdot \frac{y}{z}}\]
    12. Using strategy rm
    13. Applied clear-num2.4

      \[\leadsto x - \color{blue}{\frac{1}{\frac{z \cdot 2 - t \cdot \frac{y}{z}}{y \cdot 2}}}\]

    if -7.171100663984459e-219 < z < 3.8725642139486444e-297

    1. Initial program 8.8

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Using strategy rm
    3. Applied associate-/l*9.0

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    4. Using strategy rm
    5. Applied div-inv9.0

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

      \[\leadsto x - \color{blue}{\frac{y}{\left(z \cdot 2\right) \cdot z - y \cdot t} \cdot \frac{2}{\frac{1}{z}}}\]
    7. Simplified7.5

      \[\leadsto x - \frac{y}{\left(z \cdot 2\right) \cdot z - y \cdot t} \cdot \color{blue}{\left(z \cdot 2\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\ \;\;\;\;x - \frac{1}{\frac{z \cdot 2 - t \cdot \frac{y}{z}}{y \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\left(z \cdot 2\right) \cdot z - y \cdot t} \cdot \left(z \cdot 2\right)\\ \end{array}\]

Reproduce

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