Average Error: 52.4 → 0.2
Time: 18.9s
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0829411543110412:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \left(\frac{\frac{1}{2}}{x} + \frac{\frac{1}{16}}{{x}^{5}}\right)\right)\\ \mathbf{elif}\;x \le 0.009441822530657064:\\ \;\;\;\;(\left(x \cdot \frac{-1}{6}\right) \cdot \left(x \cdot x\right) + \left((\frac{3}{40} \cdot \left({x}^{5}\right) + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log \left((e^{\log \left(1 + \left(\sqrt{1^2 + x^2}^* + x\right)\right)} - 1)^*\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.4
Target44.5
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.0829411543110412

    1. Initial program 61.4

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Simplified60.6

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Taylor expanded around -inf 0.3

      \[\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)}\]
    4. Simplified0.3

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

    if -1.0829411543110412 < x < 0.009441822530657064

    1. Initial program 59.0

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Simplified59.0

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Taylor expanded around 0 0.1

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

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

    if 0.009441822530657064 < x

    1. Initial program 30.3

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Simplified0.1

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. Using strategy rm
    4. Applied expm1-log1p-u0.1

      \[\leadsto \log \color{blue}{\left((e^{\log_* (1 + \left(x + \sqrt{1^2 + x^2}^*\right))} - 1)^*\right)}\]
    5. Using strategy rm
    6. Applied log1p-udef0.1

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

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

Reproduce

herbie shell --seed 2019090 +o rules:numerics
(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)))))