Average Error: 52.6 → 0.2
Time: 14.2s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0681179944727555:\\ \;\;\;\;\log \left(\left(\frac{\frac{-1}{2}}{x} + \frac{\frac{1}{8}}{\left(x \cdot x\right) \cdot x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)\\ \mathbf{elif}\;x \le 0.9612525386224373:\\ \;\;\;\;\left(x + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{6}\right) + {x}^{5} \cdot \frac{3}{40}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\frac{\frac{-1}{8}}{\left(x \cdot x\right) \cdot x} + \left(\frac{\frac{1}{2}}{x} + x\right)\right) + x\right)\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.0681179944727555:\\
\;\;\;\;\log \left(\left(\frac{\frac{-1}{2}}{x} + \frac{\frac{1}{8}}{\left(x \cdot x\right) \cdot x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)\\

\mathbf{elif}\;x \le 0.9612525386224373:\\
\;\;\;\;\left(x + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{6}\right) + {x}^{5} \cdot \frac{3}{40}\\

\mathbf{else}:\\
\;\;\;\;\log \left(\left(\frac{\frac{-1}{8}}{\left(x \cdot x\right) \cdot x} + \left(\frac{\frac{1}{2}}{x} + x\right)\right) + x\right)\\

\end{array}
double f(double x) {
        double r8592012 = x;
        double r8592013 = r8592012 * r8592012;
        double r8592014 = 1.0;
        double r8592015 = r8592013 + r8592014;
        double r8592016 = sqrt(r8592015);
        double r8592017 = r8592012 + r8592016;
        double r8592018 = log(r8592017);
        return r8592018;
}

double f(double x) {
        double r8592019 = x;
        double r8592020 = -1.0681179944727555;
        bool r8592021 = r8592019 <= r8592020;
        double r8592022 = -0.5;
        double r8592023 = r8592022 / r8592019;
        double r8592024 = 0.125;
        double r8592025 = r8592019 * r8592019;
        double r8592026 = r8592025 * r8592019;
        double r8592027 = r8592024 / r8592026;
        double r8592028 = r8592023 + r8592027;
        double r8592029 = 0.0625;
        double r8592030 = 5.0;
        double r8592031 = pow(r8592019, r8592030);
        double r8592032 = r8592029 / r8592031;
        double r8592033 = r8592028 - r8592032;
        double r8592034 = log(r8592033);
        double r8592035 = 0.9612525386224373;
        bool r8592036 = r8592019 <= r8592035;
        double r8592037 = -0.16666666666666666;
        double r8592038 = r8592026 * r8592037;
        double r8592039 = r8592019 + r8592038;
        double r8592040 = 0.075;
        double r8592041 = r8592031 * r8592040;
        double r8592042 = r8592039 + r8592041;
        double r8592043 = -0.125;
        double r8592044 = r8592043 / r8592026;
        double r8592045 = 0.5;
        double r8592046 = r8592045 / r8592019;
        double r8592047 = r8592046 + r8592019;
        double r8592048 = r8592044 + r8592047;
        double r8592049 = r8592048 + r8592019;
        double r8592050 = log(r8592049);
        double r8592051 = r8592036 ? r8592042 : r8592050;
        double r8592052 = r8592021 ? r8592034 : r8592051;
        return r8592052;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.6
Target44.8
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt 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.0681179944727555

    1. Initial program 61.7

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

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

      \[\leadsto \log \color{blue}{\left(\left(\frac{\frac{1}{8}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{-1}{2}}{x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)}\]

    if -1.0681179944727555 < x < 0.9612525386224373

    1. Initial program 58.6

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

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

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

    if 0.9612525386224373 < x

    1. Initial program 30.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0681179944727555:\\ \;\;\;\;\log \left(\left(\frac{\frac{-1}{2}}{x} + \frac{\frac{1}{8}}{\left(x \cdot x\right) \cdot x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)\\ \mathbf{elif}\;x \le 0.9612525386224373:\\ \;\;\;\;\left(x + \left(\left(x \cdot x\right) \cdot x\right) \cdot \frac{-1}{6}\right) + {x}^{5} \cdot \frac{3}{40}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\frac{\frac{-1}{8}}{\left(x \cdot x\right) \cdot x} + \left(\frac{\frac{1}{2}}{x} + x\right)\right) + x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 
(FPCore (x)
  :name "Hyperbolic arcsine"

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

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