Average Error: 52.7 → 0.1
Time: 28.9s
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.2280481890437729:\\
\;\;\;\;\log \left(\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)\\
\mathbf{if}\;x \le 0.0070439057703083705:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left((\left(\sqrt{\sqrt{1^2 + x^2}^*}\right) \cdot \left(\sqrt{\sqrt{1^2 + x^2}^*}\right) + x)_*\right)\\
\end{array}\]
Target
| Original | 52.7 |
|---|
| Target | 44.8 |
|---|
| Herbie | 0.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
- Split input into 3 regimes
if x < -1.2280481890437729
Initial program 61.5
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify60.8
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
Taylor expanded around -inf 0.3
\[\leadsto \log \color{blue}{\left(\frac{1}{8} \cdot \frac{1}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{1}{{x}^{5}} + \frac{1}{2} \cdot \frac{1}{x}\right)\right)}\]
Applied simplify0.3
\[\leadsto \color{blue}{\log \left(\left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right) - \frac{\frac{1}{16}}{{x}^{5}}\right)}\]
if -1.2280481890437729 < x < 0.0070439057703083705
Initial program 58.7
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify58.7
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}}\]
if 0.0070439057703083705 < x
Initial program 31.1
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify0.0
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
- Using strategy
rm Applied add-sqr-sqrt0.1
\[\leadsto \log \left(\color{blue}{\sqrt{\sqrt{1^2 + x^2}^*} \cdot \sqrt{\sqrt{1^2 + x^2}^*}} + x\right)\]
Applied fma-def0.1
\[\leadsto \log \color{blue}{\left((\left(\sqrt{\sqrt{1^2 + x^2}^*}\right) \cdot \left(\sqrt{\sqrt{1^2 + x^2}^*}\right) + x)_*\right)}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070258749 1877548225 2229079127 1588002776 3179087814 1886870650)' +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)))))