Average Error: 52.3 → 29.7
Time: 51.6s
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.833327672762858 \cdot 10^{+152}:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right)\\ \mathbf{if}\;x \le 6031115.829667645:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{-1}{\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.3
Target44.7
Herbie29.7
\[\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 < -7.833327672762858e+152

    1. Initial program 63.6

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

      \[\leadsto \log \left(x + \color{blue}{\left(\frac{1}{8} \cdot \frac{1}{{x}^{3}} - \left(\frac{1}{2} \cdot \frac{1}{x} + x\right)\right)}\right)\]
    3. Applied simplify0.0

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

    if -7.833327672762858e+152 < x < 6031115.829667645

    1. Initial program 58.2

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied flip-+58.3

      \[\leadsto \log \color{blue}{\left(\frac{x \cdot x - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}{x - \sqrt{x \cdot x + 1}}\right)}\]
    4. Applied simplify46.9

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

    if 6031115.829667645 < x

    1. Initial program 30.9

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied flip-+62.0

      \[\leadsto \log \color{blue}{\left(\frac{x \cdot x - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}{x - \sqrt{x \cdot x + 1}}\right)}\]
    4. Applied simplify62.8

      \[\leadsto \log \left(\frac{\color{blue}{-1}}{x - \sqrt{x \cdot x + 1}}\right)\]
    5. Taylor expanded around inf 62.0

      \[\leadsto \log \left(\frac{-1}{x - \color{blue}{\left(\left(\frac{1}{2} \cdot \frac{1}{x} + x\right) - \frac{1}{8} \cdot \frac{1}{{x}^{3}}\right)}}\right)\]
    6. Applied simplify0.0

      \[\leadsto \color{blue}{\log \left(\frac{-1}{\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 51.6s)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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)))))