Average Error: 52.5 → 0.2
Time: 16.5s
Precision: 64
Internal Precision: 2368
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.2363951592590932:\\ \;\;\;\;\log \left((e^{(\left(\frac{1}{x \cdot x}\right) \cdot \left(\frac{\frac{1}{12}}{x} - \frac{1}{8}\right) + \left(\frac{\frac{-1}{2}}{x}\right))_*} - 1)^*\right)\\ \mathbf{elif}\;x \le 0.0077457790480143516:\\ \;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} - {x}^{3} \cdot \frac{1}{6}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{1^2 + x^2}^* + x\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.5
Target44.8
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.2363951592590932

    1. Initial program 61.7

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

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

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

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

      \[\leadsto \log \left((e^{\color{blue}{(\left(\frac{1}{x \cdot x}\right) \cdot \left(\frac{\frac{1}{12}}{x} - \frac{1}{8}\right) + \left(\frac{\frac{-1}{2}}{x}\right))_*}} - 1)^*\right)\]

    if -1.2363951592590932 < x < 0.0077457790480143516

    1. Initial program 58.7

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

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

      \[\leadsto \color{blue}{\left(x + \frac{3}{40} \cdot {x}^{5}\right) - \frac{1}{6} \cdot {x}^{3}}\]
    4. Using strategy rm
    5. Applied associate--l+0.2

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

    if 0.0077457790480143516 < x

    1. Initial program 31.0

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

      \[\leadsto \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 expm1-log1p0.1

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

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

Runtime

Time bar (total: 16.5s)Debug logProfile

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