Average Error: 53.0 → 0.2
Time: 6.2s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.01387741767328587:\\ \;\;\;\;\log \left(\frac{0.125}{{x}^{3}} - \left(\frac{0.5}{x} - \frac{-0.0625}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.00115853365225229515:\\ \;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \log \left(x + \mathsf{hypot}\left(x, \sqrt{1}\right)\right) + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.01387741767328587:\\
\;\;\;\;\log \left(\frac{0.125}{{x}^{3}} - \left(\frac{0.5}{x} - \frac{-0.0625}{{x}^{5}}\right)\right)\\

\mathbf{elif}\;x \le 0.00115853365225229515:\\
\;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \log \left(x + \mathsf{hypot}\left(x, \sqrt{1}\right)\right) + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\\

\end{array}
double f(double x) {
        double r154193 = x;
        double r154194 = r154193 * r154193;
        double r154195 = 1.0;
        double r154196 = r154194 + r154195;
        double r154197 = sqrt(r154196);
        double r154198 = r154193 + r154197;
        double r154199 = log(r154198);
        return r154199;
}

double f(double x) {
        double r154200 = x;
        double r154201 = -1.0138774176732859;
        bool r154202 = r154200 <= r154201;
        double r154203 = 0.125;
        double r154204 = 3.0;
        double r154205 = pow(r154200, r154204);
        double r154206 = r154203 / r154205;
        double r154207 = 0.5;
        double r154208 = r154207 / r154200;
        double r154209 = 0.0625;
        double r154210 = -r154209;
        double r154211 = 5.0;
        double r154212 = pow(r154200, r154211);
        double r154213 = r154210 / r154212;
        double r154214 = r154208 - r154213;
        double r154215 = r154206 - r154214;
        double r154216 = log(r154215);
        double r154217 = 0.0011585336522522951;
        bool r154218 = r154200 <= r154217;
        double r154219 = 1.0;
        double r154220 = sqrt(r154219);
        double r154221 = log(r154220);
        double r154222 = r154200 / r154220;
        double r154223 = r154221 + r154222;
        double r154224 = 0.16666666666666666;
        double r154225 = pow(r154220, r154204);
        double r154226 = r154205 / r154225;
        double r154227 = r154224 * r154226;
        double r154228 = r154223 - r154227;
        double r154229 = 0.5;
        double r154230 = hypot(r154200, r154220);
        double r154231 = r154200 + r154230;
        double r154232 = log(r154231);
        double r154233 = r154229 * r154232;
        double r154234 = sqrt(r154231);
        double r154235 = log(r154234);
        double r154236 = r154233 + r154235;
        double r154237 = r154218 ? r154228 : r154236;
        double r154238 = r154202 ? r154216 : r154237;
        return r154238;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.0
Target44.8
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt 0.0:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \sqrt{x \cdot x + 1}\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.0138774176732859

    1. Initial program 62.9

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Taylor expanded around -inf 0.2

      \[\leadsto \log \color{blue}{\left(0.125 \cdot \frac{1}{{x}^{3}} - \left(0.5 \cdot \frac{1}{x} + 0.0625 \cdot \frac{1}{{x}^{5}}\right)\right)}\]
    3. Simplified0.2

      \[\leadsto \log \color{blue}{\left(\frac{0.125}{{x}^{3}} - \left(\frac{0.5}{x} - \frac{-0.0625}{{x}^{5}}\right)\right)}\]

    if -1.0138774176732859 < x < 0.0011585336522522951

    1. Initial program 58.9

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}}\]

    if 0.0011585336522522951 < x

    1. Initial program 31.7

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt31.7

      \[\leadsto \log \left(x + \sqrt{x \cdot x + \color{blue}{\sqrt{1} \cdot \sqrt{1}}}\right)\]
    4. Applied hypot-def0.2

      \[\leadsto \log \left(x + \color{blue}{\mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.2

      \[\leadsto \log \color{blue}{\left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)} \cdot \sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)}\]
    7. Applied log-prod0.2

      \[\leadsto \color{blue}{\log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right) + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)}\]
    8. Using strategy rm
    9. Applied pow1/20.2

      \[\leadsto \log \color{blue}{\left({\left(x + \mathsf{hypot}\left(x, \sqrt{1}\right)\right)}^{\frac{1}{2}}\right)} + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\]
    10. Applied log-pow0.2

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \log \left(x + \mathsf{hypot}\left(x, \sqrt{1}\right)\right)} + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.01387741767328587:\\ \;\;\;\;\log \left(\frac{0.125}{{x}^{3}} - \left(\frac{0.5}{x} - \frac{-0.0625}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.00115853365225229515:\\ \;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \log \left(x + \mathsf{hypot}\left(x, \sqrt{1}\right)\right) + \log \left(\sqrt{x + \mathsf{hypot}\left(x, \sqrt{1}\right)}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arcsine"
  :precision binary64

  :herbie-target
  (if (< x 0.0) (log (/ -1 (- x (sqrt (+ (* x x) 1))))) (log (+ x (sqrt (+ (* x x) 1)))))

  (log (+ x (sqrt (+ (* x x) 1)))))