Average Error: 52.6 → 0.1
Time: 1.2m
Precision: 64
Internal Precision: 128
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0505090619620951:\\ \;\;\;\;\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.008582998481104578:\\ \;\;\;\;(\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(\sqrt{1^2 + x^2}^* + x\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.6
Target44.9
Herbie0.1
\[\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.0505090619620951

    1. Initial program 61.8

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

      \[\leadsto \color{blue}{\log \left(x + \sqrt{1^2 + x^2}^*\right)}\]
    3. 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)}\]
    4. Simplified0.2

      \[\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.0505090619620951 < x < 0.008582998481104578

    1. Initial program 58.9

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

      \[\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.008582998481104578 < x

    1. Initial program 30.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0505090619620951:\\ \;\;\;\;\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.008582998481104578:\\ \;\;\;\;(\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(\sqrt{1^2 + x^2}^* + x\right)\\ \end{array}\]

Reproduce

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