Average Error: 11.6 → 7.1
Time: 14.2s
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 -7.155484423493136172297234653917029205289 \cdot 10^{-54}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{\left(z \cdot 2\right) \cdot z - t \cdot y}{y}}{z \cdot 2}}\\ \mathbf{elif}\;y \le 1.488359269655058698602859488441319618704 \cdot 10^{-214}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{\left(z \cdot 2\right) \cdot z - t \cdot y}{y}}{z \cdot 2}}\\ \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 -7.155484423493136172297234653917029205289 \cdot 10^{-54}:\\
\;\;\;\;x - \frac{1}{\frac{\frac{\left(z \cdot 2\right) \cdot z - t \cdot y}{y}}{z \cdot 2}}\\

\mathbf{elif}\;y \le 1.488359269655058698602859488441319618704 \cdot 10^{-214}:\\
\;\;\;\;x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r20189638 = x;
        double r20189639 = y;
        double r20189640 = 2.0;
        double r20189641 = r20189639 * r20189640;
        double r20189642 = z;
        double r20189643 = r20189641 * r20189642;
        double r20189644 = r20189642 * r20189640;
        double r20189645 = r20189644 * r20189642;
        double r20189646 = t;
        double r20189647 = r20189639 * r20189646;
        double r20189648 = r20189645 - r20189647;
        double r20189649 = r20189643 / r20189648;
        double r20189650 = r20189638 - r20189649;
        return r20189650;
}

double f(double x, double y, double z, double t) {
        double r20189651 = y;
        double r20189652 = -7.155484423493136e-54;
        bool r20189653 = r20189651 <= r20189652;
        double r20189654 = x;
        double r20189655 = 1.0;
        double r20189656 = z;
        double r20189657 = 2.0;
        double r20189658 = r20189656 * r20189657;
        double r20189659 = r20189658 * r20189656;
        double r20189660 = t;
        double r20189661 = r20189660 * r20189651;
        double r20189662 = r20189659 - r20189661;
        double r20189663 = r20189662 / r20189651;
        double r20189664 = r20189663 / r20189658;
        double r20189665 = r20189655 / r20189664;
        double r20189666 = r20189654 - r20189665;
        double r20189667 = 1.4883592696550587e-214;
        bool r20189668 = r20189651 <= r20189667;
        double r20189669 = r20189668 ? r20189654 : r20189666;
        double r20189670 = r20189653 ? r20189666 : r20189669;
        return r20189670;
}

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

Derivation

  1. Split input into 2 regimes
  2. if y < -7.155484423493136e-54 or 1.4883592696550587e-214 < y

    1. Initial program 13.7

      \[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 clear-num13.7

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

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

    if -7.155484423493136e-54 < y < 1.4883592696550587e-214

    1. Initial program 6.1

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Simplified4.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot 2}{\mathsf{fma}\left(-y, t, \left(z \cdot 2\right) \cdot z\right)}, -y, x\right)}\]
    3. Taylor expanded around 0 7.2

      \[\leadsto \color{blue}{x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.1

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"

  :herbie-target
  (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))

  (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))