Average Error: 12.0 → 2.6
Time: 4.1s
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}{z \cdot 2 - 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}{z \cdot 2 - 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 r515083 = x;
        double r515084 = y;
        double r515085 = 2.0;
        double r515086 = r515084 * r515085;
        double r515087 = z;
        double r515088 = r515086 * r515087;
        double r515089 = r515087 * r515085;
        double r515090 = r515089 * r515087;
        double r515091 = t;
        double r515092 = r515084 * r515091;
        double r515093 = r515090 - r515092;
        double r515094 = r515088 / r515093;
        double r515095 = r515083 - r515094;
        return r515095;
}

double f(double x, double y, double z, double t) {
        double r515096 = y;
        double r515097 = 6.4129800116043025e+168;
        bool r515098 = r515096 <= r515097;
        double r515099 = 1.7509518152818834e+246;
        bool r515100 = r515096 <= r515099;
        double r515101 = !r515100;
        bool r515102 = r515098 || r515101;
        double r515103 = x;
        double r515104 = 2.0;
        double r515105 = r515096 * r515104;
        double r515106 = z;
        double r515107 = r515106 * r515104;
        double r515108 = t;
        double r515109 = r515096 / r515106;
        double r515110 = r515108 * r515109;
        double r515111 = r515107 - r515110;
        double r515112 = r515105 / r515111;
        double r515113 = r515103 - r515112;
        double r515114 = r515107 * r515106;
        double r515115 = r515096 * r515108;
        double r515116 = r515114 - r515115;
        double r515117 = r515096 / r515116;
        double r515118 = r515117 * r515107;
        double r515119 = r515103 - r515118;
        double r515120 = r515102 ? r515113 : r515119;
        return r515120;
}

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. Using strategy rm
    5. Applied div-sub6.3

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

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

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

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

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

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \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}{z \cdot 2 - 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)))))