Average Error: 52.5 → 0.4
Time: 1.1m
Precision: 64
Internal Precision: 2368
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{16}}{{x}^{5}}\right) - \frac{\frac{1}{2}}{x} \le -4.721610511497892 \cdot 10^{-05}:\\ \;\;\;\;\left(x + \frac{3}{40} \cdot {x}^{5}\right) - \frac{1}{6} \cdot {x}^{3}\\ \mathbf{if}\;\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{16}}{{x}^{5}}\right) - \frac{\frac{1}{2}}{x} \le 3.974532887590845 \cdot 10^{-308}:\\ \;\;\;\;\log \left(\left(\frac{\frac{1}{2}}{x} + x \cdot 2\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\\ \mathbf{if}\;\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{16}}{{x}^{5}}\right) - \frac{\frac{1}{2}}{x} \le 0.1753549293090203:\\ \;\;\;\;\log \left(\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{16}}{{x}^{5}}\right) - \frac{\frac{1}{2}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{3}{40} \cdot {x}^{5}\right) - \frac{1}{6} \cdot {x}^{3}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.5
Target45.0
Herbie0.4
\[\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/16 (pow x 5))) (/ 1/2 x)) < -4.721610511497892e-05 or 0.1753549293090203 < (- (- (/ (/ 1/8 x) (* x x)) (/ 1/16 (pow x 5))) (/ 1/2 x))

    1. Initial program 58.4

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

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

    if -4.721610511497892e-05 < (- (- (/ (/ 1/8 x) (* x x)) (/ 1/16 (pow x 5))) (/ 1/2 x)) < 3.974532887590845e-308

    1. Initial program 31.3

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

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

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

    if 3.974532887590845e-308 < (- (- (/ (/ 1/8 x) (* x x)) (/ 1/16 (pow x 5))) (/ 1/2 x)) < 0.1753549293090203

    1. Initial program 61.8

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

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed 2020178 
(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)))))