Average Error: 52.6 → 0.2
Time: 17.6s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.333142796118209:\\ \;\;\;\;\log \left(\frac{\frac{-1}{2}}{x}\right)\\ \mathbf{elif}\;x \le 0.005853433712893995:\\ \;\;\;\;(\left(x \cdot \frac{-1}{6}\right) \cdot \left(x \cdot x\right) + \left((\frac{3}{40} \cdot \left({x}^{5}\right) + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log \left((\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x}\right) + \left(\sqrt{1^2 + x^2}^*\right))_*\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original52.6
Target45.0
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.333142796118209

    1. Initial program 62.1

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

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

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

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

      \[\leadsto \log \color{blue}{\left(-\frac{1}{2} \cdot \frac{1}{x}\right)}\]
    7. Simplified0.4

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

    if -1.333142796118209 < x < 0.005853433712893995

    1. Initial program 58.7

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

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

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

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

    if 0.005853433712893995 < x

    1. Initial program 30.9

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

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

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

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

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

Reproduce

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