Average Error: 11.6 → 2.0
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}\;\frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \le -2.201142637240148314027089242152906862485 \cdot 10^{-154}:\\ \;\;\;\;x - \frac{\frac{y \cdot 2}{\left(z \cdot 2\right) \cdot z - y \cdot t}}{\frac{1}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\ \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}\;\frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \le -2.201142637240148314027089242152906862485 \cdot 10^{-154}:\\
\;\;\;\;x - \frac{\frac{y \cdot 2}{\left(z \cdot 2\right) \cdot z - y \cdot t}}{\frac{1}{z}}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r469053 = x;
        double r469054 = y;
        double r469055 = 2.0;
        double r469056 = r469054 * r469055;
        double r469057 = z;
        double r469058 = r469056 * r469057;
        double r469059 = r469057 * r469055;
        double r469060 = r469059 * r469057;
        double r469061 = t;
        double r469062 = r469054 * r469061;
        double r469063 = r469060 - r469062;
        double r469064 = r469058 / r469063;
        double r469065 = r469053 - r469064;
        return r469065;
}

double f(double x, double y, double z, double t) {
        double r469066 = y;
        double r469067 = 2.0;
        double r469068 = r469066 * r469067;
        double r469069 = z;
        double r469070 = r469068 * r469069;
        double r469071 = r469069 * r469067;
        double r469072 = r469071 * r469069;
        double r469073 = t;
        double r469074 = r469066 * r469073;
        double r469075 = r469072 - r469074;
        double r469076 = r469070 / r469075;
        double r469077 = -2.2011426372401483e-154;
        bool r469078 = r469076 <= r469077;
        double r469079 = x;
        double r469080 = r469068 / r469075;
        double r469081 = 1.0;
        double r469082 = r469081 / r469069;
        double r469083 = r469080 / r469082;
        double r469084 = r469079 - r469083;
        double r469085 = r469067 * r469069;
        double r469086 = r469066 / r469069;
        double r469087 = r469073 * r469086;
        double r469088 = r469085 - r469087;
        double r469089 = r469068 / r469088;
        double r469090 = r469079 - r469089;
        double r469091 = r469078 ? r469084 : r469090;
        return r469091;
}

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.6
Target0.1
Herbie2.0
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t))) < -2.2011426372401483e-154

    1. Initial program 4.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*2.1

      \[\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-inv2.2

      \[\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 associate-/r*0.8

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

    if -2.2011426372401483e-154 < (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))

    1. Initial program 12.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*7.8

      \[\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 3.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \le -2.201142637240148314027089242152906862485 \cdot 10^{-154}:\\ \;\;\;\;x - \frac{\frac{y \cdot 2}{\left(z \cdot 2\right) \cdot z - y \cdot t}}{\frac{1}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot 2}{2 \cdot z - t \cdot \frac{y}{z}}\\ \end{array}\]

Reproduce

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