Average Error: 52.9 → 0.2
Time: 1.1m
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.1969359827567199:\\ \;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right)\\ \mathbf{if}\;x \le 0.8987929272862484:\\ \;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\frac{\frac{1}{2}}{x} + \left(x + x\right)\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.9
Target45.4
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.1969359827567199

    1. Initial program 61.6

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Taylor expanded around -inf 61.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.3

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

    if -1.1969359827567199 < x < 0.8987929272862484

    1. Initial program 58.7

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

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

    if 0.8987929272862484 < x

    1. Initial program 33.2

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

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1063313015 2771194459 1594909340 1344785158 2223560818 546365448)' 
(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)))))