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

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

\mathbf{else}:\\
\;\;\;\;\log 2 - \left(\frac{\frac{-1}{4}}{x \cdot x} - \left(\log x - \frac{\frac{3}{32}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}\right)\right)\\

\end{array}
double f(double x) {
        double r26044140 = x;
        double r26044141 = r26044140 * r26044140;
        double r26044142 = 1.0;
        double r26044143 = r26044141 + r26044142;
        double r26044144 = sqrt(r26044143);
        double r26044145 = r26044140 + r26044144;
        double r26044146 = log(r26044145);
        return r26044146;
}

double f(double x) {
        double r26044147 = x;
        double r26044148 = -1.043616525651111;
        bool r26044149 = r26044147 <= r26044148;
        double r26044150 = 0.125;
        double r26044151 = r26044150 / r26044147;
        double r26044152 = r26044151 / r26044147;
        double r26044153 = r26044152 / r26044147;
        double r26044154 = -0.5;
        double r26044155 = r26044154 / r26044147;
        double r26044156 = r26044153 + r26044155;
        double r26044157 = 0.0625;
        double r26044158 = 5.0;
        double r26044159 = pow(r26044147, r26044158);
        double r26044160 = r26044157 / r26044159;
        double r26044161 = r26044156 - r26044160;
        double r26044162 = log(r26044161);
        double r26044163 = 1.028068851045838;
        bool r26044164 = r26044147 <= r26044163;
        double r26044165 = 0.075;
        double r26044166 = r26044159 * r26044165;
        double r26044167 = r26044147 * r26044147;
        double r26044168 = -0.16666666666666666;
        double r26044169 = r26044167 * r26044168;
        double r26044170 = r26044147 * r26044169;
        double r26044171 = r26044147 + r26044170;
        double r26044172 = r26044166 + r26044171;
        double r26044173 = 2.0;
        double r26044174 = log(r26044173);
        double r26044175 = -0.25;
        double r26044176 = r26044175 / r26044167;
        double r26044177 = log(r26044147);
        double r26044178 = 0.09375;
        double r26044179 = r26044167 * r26044167;
        double r26044180 = r26044178 / r26044179;
        double r26044181 = r26044177 - r26044180;
        double r26044182 = r26044176 - r26044181;
        double r26044183 = r26044174 - r26044182;
        double r26044184 = r26044164 ? r26044172 : r26044183;
        double r26044185 = r26044149 ? r26044162 : r26044184;
        return r26044185;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.4
Target44.9
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.043616525651111

    1. Initial program 61.8

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

      \[\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.1

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

    if -1.043616525651111 < x < 1.028068851045838

    1. Initial program 58.7

      \[\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(\left(\left(x \cdot x\right) \cdot \frac{-1}{6}\right) \cdot x + x\right) + {x}^{5} \cdot \frac{3}{40}}\]

    if 1.028068851045838 < x

    1. Initial program 30.1

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

      \[\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.4

      \[\leadsto \log \left(x + \color{blue}{\left(\left(\frac{\frac{-1}{8}}{\left(x \cdot x\right) \cdot x} + x\right) + \frac{\frac{1}{2}}{x}\right)}\right)\]
    4. Taylor expanded around inf 0.4

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

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

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

Reproduce

herbie shell --seed 2019104 
(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)))))