Average Error: 11.7 → 2.8
Time: 3.8s
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}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\ \;\;\;\;x - \frac{1}{\frac{2 \cdot z - t \cdot \frac{y}{z}}{y \cdot 2}}\\ \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}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\
\;\;\;\;x - \frac{1}{\frac{2 \cdot z - t \cdot \frac{y}{z}}{y \cdot 2}}\\

\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 r541883 = x;
        double r541884 = y;
        double r541885 = 2.0;
        double r541886 = r541884 * r541885;
        double r541887 = z;
        double r541888 = r541886 * r541887;
        double r541889 = r541887 * r541885;
        double r541890 = r541889 * r541887;
        double r541891 = t;
        double r541892 = r541884 * r541891;
        double r541893 = r541890 - r541892;
        double r541894 = r541888 / r541893;
        double r541895 = r541883 - r541894;
        return r541895;
}

double f(double x, double y, double z, double t) {
        double r541896 = z;
        double r541897 = -7.171100663984459e-219;
        bool r541898 = r541896 <= r541897;
        double r541899 = 3.8725642139486444e-297;
        bool r541900 = r541896 <= r541899;
        double r541901 = !r541900;
        bool r541902 = r541898 || r541901;
        double r541903 = x;
        double r541904 = 1.0;
        double r541905 = 2.0;
        double r541906 = r541905 * r541896;
        double r541907 = t;
        double r541908 = y;
        double r541909 = r541908 / r541896;
        double r541910 = r541907 * r541909;
        double r541911 = r541906 - r541910;
        double r541912 = r541908 * r541905;
        double r541913 = r541911 / r541912;
        double r541914 = r541904 / r541913;
        double r541915 = r541903 - r541914;
        double r541916 = r541896 * r541905;
        double r541917 = r541916 * r541896;
        double r541918 = r541908 * r541907;
        double r541919 = r541917 - r541918;
        double r541920 = r541908 / r541919;
        double r541921 = r541920 * r541916;
        double r541922 = r541903 - r541921;
        double r541923 = r541902 ? r541915 : r541922;
        return r541923;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -7.171100663984459e-219 or 3.8725642139486444e-297 < z

    1. Initial program 11.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*6.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 2.7

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

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

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

      \[\leadsto x - \frac{y \cdot 2}{2 \cdot z - \color{blue}{t} \cdot \frac{y}{z}}\]
    9. Using strategy rm
    10. Applied clear-num2.4

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

    if -7.171100663984459e-219 < z < 3.8725642139486444e-297

    1. Initial program 8.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*9.0

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

      \[\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-frac7.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -7.171100663984459355007048421675672411978 \cdot 10^{-219} \lor \neg \left(z \le 3.872564213948644371271891665727232128317 \cdot 10^{-297}\right):\\ \;\;\;\;x - \frac{1}{\frac{2 \cdot z - t \cdot \frac{y}{z}}{y \cdot 2}}\\ \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 2019362 
(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)))))