Average Error: 52.4 → 1.1
Time: 28.7s
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le -536.0230928176488:\\ \;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\ \mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 1.3496677481081412 \cdot 10^{-294}:\\ \;\;\;\;\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)\\ \mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 1.245804171722264 \cdot 10^{-06}:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\ \end{array}\]

Error

Bits error versus x

Target

Original52.4
Target45.0
Herbie1.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 (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < -536.0230928176488 or 1.245804171722264e-06 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x))

    1. Initial program 58.3

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

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

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

    if -536.0230928176488 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 1.3496677481081412e-294

    1. Initial program 33.2

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

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

      \[\leadsto \log \color{blue}{\left(\sqrt{\sqrt{1^2 + x^2}^* + x} \cdot \sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]
    5. Applied log-prod3.0

      \[\leadsto \color{blue}{\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]

    if 1.3496677481081412e-294 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 1.245804171722264e-06

    1. Initial program 62.6

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

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

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

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

Runtime

Time bar (total: 28.7s)Debug logProfile

herbie shell --seed '#(1070864556 424010669 783715395 1203517814 4070606583 4107618214)' +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)))))