Average Error: 12.0 → 2.6
Time: 4.4s
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}\;y \le 6.41298001160430249 \cdot 10^{168} \lor \neg \left(y \le 1.7509518152818834 \cdot 10^{246}\right):\\ \;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\ \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}\;y \le 6.41298001160430249 \cdot 10^{168} \lor \neg \left(y \le 1.7509518152818834 \cdot 10^{246}\right):\\
\;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\

\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 r507405 = x;
        double r507406 = y;
        double r507407 = 2.0;
        double r507408 = r507406 * r507407;
        double r507409 = z;
        double r507410 = r507408 * r507409;
        double r507411 = r507409 * r507407;
        double r507412 = r507411 * r507409;
        double r507413 = t;
        double r507414 = r507406 * r507413;
        double r507415 = r507412 - r507414;
        double r507416 = r507410 / r507415;
        double r507417 = r507405 - r507416;
        return r507417;
}

double f(double x, double y, double z, double t) {
        double r507418 = y;
        double r507419 = 6.4129800116043025e+168;
        bool r507420 = r507418 <= r507419;
        double r507421 = 1.7509518152818834e+246;
        bool r507422 = r507418 <= r507421;
        double r507423 = !r507422;
        bool r507424 = r507420 || r507423;
        double r507425 = x;
        double r507426 = 2.0;
        double r507427 = r507418 * r507426;
        double r507428 = z;
        double r507429 = r507426 * r507428;
        double r507430 = t;
        double r507431 = r507418 / r507428;
        double r507432 = r507430 * r507431;
        double r507433 = r507429 - r507432;
        double r507434 = r507427 / r507433;
        double r507435 = r507425 - r507434;
        double r507436 = r507428 * r507426;
        double r507437 = r507436 * r507428;
        double r507438 = r507418 * r507430;
        double r507439 = r507437 - r507438;
        double r507440 = r507418 / r507439;
        double r507441 = r507440 * r507436;
        double r507442 = r507425 - r507441;
        double r507443 = r507424 ? r507435 : r507442;
        return r507443;
}

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

Original12.0
Target0.1
Herbie2.6
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}\]

Derivation

  1. Split input into 2 regimes
  2. if y < 6.4129800116043025e+168 or 1.7509518152818834e+246 < y

    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. Using strategy rm
    3. Applied associate-/l*6.3

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    4. Taylor expanded around 0 2.6

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

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

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

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

    if 6.4129800116043025e+168 < y < 1.7509518152818834e+246

    1. Initial program 22.0

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

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

      \[\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-frac9.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 6.41298001160430249 \cdot 10^{168} \lor \neg \left(y \le 1.7509518152818834 \cdot 10^{246}\right):\\ \;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\ \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 2020060 +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)))))