Average Error: 53.2 → 0.1
Time: 6.2s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.03894491375018272:\\ \;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\ \mathbf{elif}\;x \le 9.30940902558543963 \cdot 10^{-4}:\\ \;\;\;\;\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}:\\ \;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.03894491375018272:\\
\;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\

\mathbf{elif}\;x \le 9.30940902558543963 \cdot 10^{-4}:\\
\;\;\;\;\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}:\\
\;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\

\end{array}
double f(double x) {
        double r152304 = x;
        double r152305 = r152304 * r152304;
        double r152306 = 1.0;
        double r152307 = r152305 + r152306;
        double r152308 = sqrt(r152307);
        double r152309 = r152304 + r152308;
        double r152310 = log(r152309);
        return r152310;
}

double f(double x) {
        double r152311 = x;
        double r152312 = -1.0389449137501827;
        bool r152313 = r152311 <= r152312;
        double r152314 = 1.0;
        double r152315 = 1.0;
        double r152316 = r152315 * r152315;
        double r152317 = 0.125;
        double r152318 = r152316 * r152317;
        double r152319 = 3.0;
        double r152320 = pow(r152311, r152319);
        double r152321 = r152318 / r152320;
        double r152322 = 0.0625;
        double r152323 = sqrt(r152315);
        double r152324 = 6.0;
        double r152325 = pow(r152323, r152324);
        double r152326 = 5.0;
        double r152327 = pow(r152311, r152326);
        double r152328 = r152325 / r152327;
        double r152329 = r152322 * r152328;
        double r152330 = 0.5;
        double r152331 = -r152330;
        double r152332 = r152315 / r152311;
        double r152333 = r152331 * r152332;
        double r152334 = r152329 - r152333;
        double r152335 = r152321 - r152334;
        double r152336 = r152314 * r152335;
        double r152337 = log(r152336);
        double r152338 = 0.000930940902558544;
        bool r152339 = r152311 <= r152338;
        double r152340 = log(r152323);
        double r152341 = r152311 / r152323;
        double r152342 = r152340 + r152341;
        double r152343 = 0.16666666666666666;
        double r152344 = pow(r152323, r152319);
        double r152345 = r152320 / r152344;
        double r152346 = r152343 * r152345;
        double r152347 = r152342 - r152346;
        double r152348 = hypot(r152311, r152323);
        double r152349 = r152348 + r152311;
        double r152350 = r152314 * r152349;
        double r152351 = log(r152350);
        double r152352 = r152339 ? r152347 : r152351;
        double r152353 = r152313 ? r152337 : r152352;
        return r152353;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.2
Target45.6
Herbie0.1
\[\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.0389449137501827

    1. Initial program 63.0

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied *-un-lft-identity63.0

      \[\leadsto \log \left(x + \color{blue}{1 \cdot \sqrt{x \cdot x + 1}}\right)\]
    4. Applied *-un-lft-identity63.0

      \[\leadsto \log \left(\color{blue}{1 \cdot x} + 1 \cdot \sqrt{x \cdot x + 1}\right)\]
    5. Applied distribute-lft-out63.0

      \[\leadsto \log \color{blue}{\left(1 \cdot \left(x + \sqrt{x \cdot x + 1}\right)\right)}\]
    6. Simplified63.0

      \[\leadsto \log \left(1 \cdot \color{blue}{\left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)}\right)\]
    7. Taylor expanded around -inf 0.2

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

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

    if -1.0389449137501827 < x < 0.000930940902558544

    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.000930940902558544 < x

    1. Initial program 31.5

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied *-un-lft-identity31.5

      \[\leadsto \log \left(x + \color{blue}{1 \cdot \sqrt{x \cdot x + 1}}\right)\]
    4. Applied *-un-lft-identity31.5

      \[\leadsto \log \left(\color{blue}{1 \cdot x} + 1 \cdot \sqrt{x \cdot x + 1}\right)\]
    5. Applied distribute-lft-out31.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.03894491375018272:\\ \;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\ \mathbf{elif}\;x \le 9.30940902558543963 \cdot 10^{-4}:\\ \;\;\;\;\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}:\\ \;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020062 +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)))))