Average Error: 11.7 → 3.1
Time: 13.6s
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}\;x - \frac{\left(2 \cdot y\right) \cdot z}{\left(z \cdot 2\right) \cdot z - t \cdot y} \le 6.699887162447185181796079741399604536537 \cdot 10^{61}:\\ \;\;\;\;x - \frac{\left(2 \cdot y\right) \cdot z}{\left(z \cdot 2\right) \cdot z - t \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{z \cdot 1 - 0.5 \cdot \frac{t}{\frac{z}{y}}} + x\\ \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}\;x - \frac{\left(2 \cdot y\right) \cdot z}{\left(z \cdot 2\right) \cdot z - t \cdot y} \le 6.699887162447185181796079741399604536537 \cdot 10^{61}:\\
\;\;\;\;x - \frac{\left(2 \cdot y\right) \cdot z}{\left(z \cdot 2\right) \cdot z - t \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{-y}{z \cdot 1 - 0.5 \cdot \frac{t}{\frac{z}{y}}} + x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r18767571 = x;
        double r18767572 = y;
        double r18767573 = 2.0;
        double r18767574 = r18767572 * r18767573;
        double r18767575 = z;
        double r18767576 = r18767574 * r18767575;
        double r18767577 = r18767575 * r18767573;
        double r18767578 = r18767577 * r18767575;
        double r18767579 = t;
        double r18767580 = r18767572 * r18767579;
        double r18767581 = r18767578 - r18767580;
        double r18767582 = r18767576 / r18767581;
        double r18767583 = r18767571 - r18767582;
        return r18767583;
}

double f(double x, double y, double z, double t) {
        double r18767584 = x;
        double r18767585 = 2.0;
        double r18767586 = y;
        double r18767587 = r18767585 * r18767586;
        double r18767588 = z;
        double r18767589 = r18767587 * r18767588;
        double r18767590 = r18767588 * r18767585;
        double r18767591 = r18767590 * r18767588;
        double r18767592 = t;
        double r18767593 = r18767592 * r18767586;
        double r18767594 = r18767591 - r18767593;
        double r18767595 = r18767589 / r18767594;
        double r18767596 = r18767584 - r18767595;
        double r18767597 = 6.699887162447185e+61;
        bool r18767598 = r18767596 <= r18767597;
        double r18767599 = -r18767586;
        double r18767600 = 1.0;
        double r18767601 = r18767588 * r18767600;
        double r18767602 = 0.5;
        double r18767603 = r18767588 / r18767586;
        double r18767604 = r18767592 / r18767603;
        double r18767605 = r18767602 * r18767604;
        double r18767606 = r18767601 - r18767605;
        double r18767607 = r18767599 / r18767606;
        double r18767608 = r18767607 + r18767584;
        double r18767609 = r18767598 ? r18767596 : r18767608;
        return r18767609;
}

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

Derivation

  1. Split input into 2 regimes
  2. if (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))) < 6.699887162447185e+61

    1. Initial program 3.9

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

    if 6.699887162447185e+61 < (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t))))

    1. Initial program 27.4

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

      \[\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. Using strategy rm
    4. Applied clear-num13.0

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{1 \cdot z - 0.5 \cdot \frac{t \cdot y}{z}}}, -y, x\right)\]
    6. Using strategy rm
    7. Applied *-un-lft-identity5.2

      \[\leadsto \mathsf{fma}\left(\frac{1}{1 \cdot z - 0.5 \cdot \frac{t \cdot y}{\color{blue}{1 \cdot z}}}, -y, x\right)\]
    8. Applied times-frac1.6

      \[\leadsto \mathsf{fma}\left(\frac{1}{1 \cdot z - 0.5 \cdot \color{blue}{\left(\frac{t}{1} \cdot \frac{y}{z}\right)}}, -y, x\right)\]
    9. Simplified1.6

      \[\leadsto \mathsf{fma}\left(\frac{1}{1 \cdot z - 0.5 \cdot \left(\color{blue}{t} \cdot \frac{y}{z}\right)}, -y, x\right)\]
    10. Using strategy rm
    11. Applied fma-udef1.6

      \[\leadsto \color{blue}{\frac{1}{1 \cdot z - 0.5 \cdot \left(t \cdot \frac{y}{z}\right)} \cdot \left(-y\right) + x}\]
    12. Simplified1.5

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

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

Reproduce

herbie shell --seed 2019179 +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)))))