Average Error: 45.5 → 29.7
Time: 8.5s
Precision: 64
\[\frac{\sqrt{ti \cdot ti + 1} - 1}{ti}\]
\[\begin{array}{l} \mathbf{if}\;ti \le -1.34187617831678346445877735820560354144 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{ti} \cdot \frac{0.5}{ti} - \left(1 + \frac{1}{ti}\right)\\ \mathbf{elif}\;ti \le 1.262276509066718724924314765463795287351 \cdot 10^{-77}:\\ \;\;\;\;\frac{\sqrt{ti \cdot ti + 1}}{ti} - \frac{1}{ti}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{1}{ti}\right) + \frac{0.5}{ti \cdot ti}\\ \end{array}\]
\frac{\sqrt{ti \cdot ti + 1} - 1}{ti}
\begin{array}{l}
\mathbf{if}\;ti \le -1.34187617831678346445877735820560354144 \cdot 10^{154}:\\
\;\;\;\;\frac{-1}{ti} \cdot \frac{0.5}{ti} - \left(1 + \frac{1}{ti}\right)\\

\mathbf{elif}\;ti \le 1.262276509066718724924314765463795287351 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{ti \cdot ti + 1}}{ti} - \frac{1}{ti}\\

\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{1}{ti}\right) + \frac{0.5}{ti \cdot ti}\\

\end{array}
double f(double ti) {
        double r394755 = ti;
        double r394756 = r394755 * r394755;
        double r394757 = 1.0;
        double r394758 = r394756 + r394757;
        double r394759 = sqrt(r394758);
        double r394760 = r394759 - r394757;
        double r394761 = r394760 / r394755;
        return r394761;
}

double f(double ti) {
        double r394762 = ti;
        double r394763 = -1.3418761783167835e+154;
        bool r394764 = r394762 <= r394763;
        double r394765 = -1.0;
        double r394766 = r394765 / r394762;
        double r394767 = 0.5;
        double r394768 = r394767 / r394762;
        double r394769 = r394766 * r394768;
        double r394770 = 1.0;
        double r394771 = 1.0;
        double r394772 = r394771 / r394762;
        double r394773 = r394770 + r394772;
        double r394774 = r394769 - r394773;
        double r394775 = 1.2622765090667187e-77;
        bool r394776 = r394762 <= r394775;
        double r394777 = r394762 * r394762;
        double r394778 = r394777 + r394771;
        double r394779 = sqrt(r394778);
        double r394780 = r394779 / r394762;
        double r394781 = r394780 - r394772;
        double r394782 = r394770 - r394772;
        double r394783 = r394767 / r394777;
        double r394784 = r394782 + r394783;
        double r394785 = r394776 ? r394781 : r394784;
        double r394786 = r394764 ? r394774 : r394785;
        return r394786;
}

Error

Bits error versus ti

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if ti < -1.3418761783167835e+154

    1. Initial program 64.0

      \[\frac{\sqrt{ti \cdot ti + 1} - 1}{ti}\]
    2. Taylor expanded around -inf 0

      \[\leadsto \color{blue}{-\left(0.5 \cdot \frac{1}{{ti}^{2}} + \left(1 \cdot \frac{1}{ti} + 1\right)\right)}\]
    3. Simplified0

      \[\leadsto \color{blue}{\left(-\frac{0.5}{ti \cdot ti}\right) - \left(1 + \frac{1}{ti}\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0

      \[\leadsto \left(-\frac{\color{blue}{1 \cdot 0.5}}{ti \cdot ti}\right) - \left(1 + \frac{1}{ti}\right)\]
    6. Applied times-frac0

      \[\leadsto \left(-\color{blue}{\frac{1}{ti} \cdot \frac{0.5}{ti}}\right) - \left(1 + \frac{1}{ti}\right)\]

    if -1.3418761783167835e+154 < ti < 1.2622765090667187e-77

    1. Initial program 46.3

      \[\frac{\sqrt{ti \cdot ti + 1} - 1}{ti}\]
    2. Using strategy rm
    3. Applied div-sub46.3

      \[\leadsto \color{blue}{\frac{\sqrt{ti \cdot ti + 1}}{ti} - \frac{1}{ti}}\]

    if 1.2622765090667187e-77 < ti

    1. Initial program 36.6

      \[\frac{\sqrt{ti \cdot ti + 1} - 1}{ti}\]
    2. Taylor expanded around inf 12.0

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{1}{{ti}^{2}} + 1\right) - 1 \cdot \frac{1}{ti}}\]
    3. Simplified12.0

      \[\leadsto \color{blue}{\left(1 - \frac{1}{ti}\right) + \frac{0.5}{ti \cdot ti}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification29.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;ti \le -1.34187617831678346445877735820560354144 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{ti} \cdot \frac{0.5}{ti} - \left(1 + \frac{1}{ti}\right)\\ \mathbf{elif}\;ti \le 1.262276509066718724924314765463795287351 \cdot 10^{-77}:\\ \;\;\;\;\frac{\sqrt{ti \cdot ti + 1}}{ti} - \frac{1}{ti}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{1}{ti}\right) + \frac{0.5}{ti \cdot ti}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (ti)
  :name "(sqrt(ti*ti+1)-1)/ti"
  :precision binary64
  (/ (- (sqrt (+ (* ti ti) 1)) 1) ti))