Average Error: 12.0 → 2.7
Time: 3.5s
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}{1 \cdot \left(2 \cdot z - t \cdot \frac{y}{z}\right)}\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{2 \cdot {z}^{2} - t \cdot y}\\ \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}{1 \cdot \left(2 \cdot z - t \cdot \frac{y}{z}\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r532058 = x;
        double r532059 = y;
        double r532060 = 2.0;
        double r532061 = r532059 * r532060;
        double r532062 = z;
        double r532063 = r532061 * r532062;
        double r532064 = r532062 * r532060;
        double r532065 = r532064 * r532062;
        double r532066 = t;
        double r532067 = r532059 * r532066;
        double r532068 = r532065 - r532067;
        double r532069 = r532063 / r532068;
        double r532070 = r532058 - r532069;
        return r532070;
}

double f(double x, double y, double z, double t) {
        double r532071 = y;
        double r532072 = 6.4129800116043025e+168;
        bool r532073 = r532071 <= r532072;
        double r532074 = 1.7509518152818834e+246;
        bool r532075 = r532071 <= r532074;
        double r532076 = !r532075;
        bool r532077 = r532073 || r532076;
        double r532078 = x;
        double r532079 = 2.0;
        double r532080 = r532071 * r532079;
        double r532081 = 1.0;
        double r532082 = z;
        double r532083 = r532079 * r532082;
        double r532084 = t;
        double r532085 = r532071 / r532082;
        double r532086 = r532084 * r532085;
        double r532087 = r532083 - r532086;
        double r532088 = r532081 * r532087;
        double r532089 = r532080 / r532088;
        double r532090 = r532078 - r532089;
        double r532091 = 2.0;
        double r532092 = pow(r532082, r532091);
        double r532093 = r532079 * r532092;
        double r532094 = r532084 * r532071;
        double r532095 = r532093 - r532094;
        double r532096 = r532082 / r532095;
        double r532097 = r532080 * r532096;
        double r532098 = r532078 - r532097;
        double r532099 = r532077 ? r532090 : r532098;
        return r532099;
}

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.7
\[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 *-un-lft-identity6.3

      \[\leadsto x - \frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{\color{blue}{1 \cdot z}}}\]
    6. Applied *-un-lft-identity6.3

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

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{\frac{1}{1} \cdot \frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    8. Simplified6.3

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

      \[\leadsto x - \frac{y \cdot 2}{1 \cdot \color{blue}{\left(2 \cdot z - \frac{t \cdot y}{z}\right)}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity2.6

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

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

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

    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 *-un-lft-identity22.0

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

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

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

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

    \[\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}{1 \cdot \left(2 \cdot z - t \cdot \frac{y}{z}\right)}\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{2 \cdot {z}^{2} - t \cdot y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020060 
(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)))))