Average Error: 53.2 → 0.2
Time: 15.6s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.026591513399979893605973302328493446112:\\ \;\;\;\;\log \left(\frac{0.125}{\left(x \cdot x\right) \cdot x} - \left(\frac{0.5}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.8907247814494133608675952018529642373323:\\ \;\;\;\;\left(\frac{x}{\sqrt{1}} + \log \left(\sqrt{1}\right)\right) - \frac{\frac{1}{6} \cdot \left(x \cdot \left(x \cdot x\right)\right)}{\sqrt{1} \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \left(\left(x + \frac{0.5}{x}\right) - \frac{0.125}{\left(x \cdot x\right) \cdot x}\right)\right)\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.026591513399979893605973302328493446112:\\
\;\;\;\;\log \left(\frac{0.125}{\left(x \cdot x\right) \cdot x} - \left(\frac{0.5}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\log \left(x + \left(\left(x + \frac{0.5}{x}\right) - \frac{0.125}{\left(x \cdot x\right) \cdot x}\right)\right)\\

\end{array}
double f(double x) {
        double r7337867 = x;
        double r7337868 = r7337867 * r7337867;
        double r7337869 = 1.0;
        double r7337870 = r7337868 + r7337869;
        double r7337871 = sqrt(r7337870);
        double r7337872 = r7337867 + r7337871;
        double r7337873 = log(r7337872);
        return r7337873;
}

double f(double x) {
        double r7337874 = x;
        double r7337875 = -1.02659151339998;
        bool r7337876 = r7337874 <= r7337875;
        double r7337877 = 0.125;
        double r7337878 = r7337874 * r7337874;
        double r7337879 = r7337878 * r7337874;
        double r7337880 = r7337877 / r7337879;
        double r7337881 = 0.5;
        double r7337882 = r7337881 / r7337874;
        double r7337883 = 0.0625;
        double r7337884 = 5.0;
        double r7337885 = pow(r7337874, r7337884);
        double r7337886 = r7337883 / r7337885;
        double r7337887 = r7337882 + r7337886;
        double r7337888 = r7337880 - r7337887;
        double r7337889 = log(r7337888);
        double r7337890 = 0.8907247814494134;
        bool r7337891 = r7337874 <= r7337890;
        double r7337892 = 1.0;
        double r7337893 = sqrt(r7337892);
        double r7337894 = r7337874 / r7337893;
        double r7337895 = log(r7337893);
        double r7337896 = r7337894 + r7337895;
        double r7337897 = 0.16666666666666666;
        double r7337898 = r7337874 * r7337878;
        double r7337899 = r7337897 * r7337898;
        double r7337900 = r7337893 * r7337892;
        double r7337901 = r7337899 / r7337900;
        double r7337902 = r7337896 - r7337901;
        double r7337903 = r7337874 + r7337882;
        double r7337904 = r7337903 - r7337880;
        double r7337905 = r7337874 + r7337904;
        double r7337906 = log(r7337905);
        double r7337907 = r7337891 ? r7337902 : r7337906;
        double r7337908 = r7337876 ? r7337889 : r7337907;
        return r7337908;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.2
Target45.0
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.02659151339998

    1. Initial program 63.0

      \[\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.0625 \cdot \frac{1}{{x}^{5}} + 0.5 \cdot \frac{1}{x}\right)\right)}\]
    3. Simplified0.2

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

    if -1.02659151339998 < x < 0.8907247814494134

    1. Initial program 58.6

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

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

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

    if 0.8907247814494134 < x

    1. Initial program 32.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.026591513399979893605973302328493446112:\\ \;\;\;\;\log \left(\frac{0.125}{\left(x \cdot x\right) \cdot x} - \left(\frac{0.5}{x} + \frac{0.0625}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.8907247814494133608675952018529642373323:\\ \;\;\;\;\left(\frac{x}{\sqrt{1}} + \log \left(\sqrt{1}\right)\right) - \frac{\frac{1}{6} \cdot \left(x \cdot \left(x \cdot x\right)\right)}{\sqrt{1} \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \left(\left(x + \frac{0.5}{x}\right) - \frac{0.125}{\left(x \cdot x\right) \cdot x}\right)\right)\\ \end{array}\]

Reproduce

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

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

  (log (+ x (sqrt (+ (* x x) 1.0)))))