Average Error: 52.3 → 0.2
Time: 24.4s
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.0700427558809735:\\
\;\;\;\;\left(\frac{\frac{3}{32}}{{x}^{4}} + \log \frac{1}{2}\right) + \left(\log \left(\frac{-1}{x}\right) - \frac{\frac{\frac{1}{4}}{x}}{x}\right)\\
\mathbf{if}\;x \le 0.006949973394836614:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1^2 + x^2}^* + x\right)\\
\end{array}\]
Target
| Original | 52.3 |
|---|
| Target | 44.7 |
|---|
| Herbie | 0.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
- Split input into 3 regimes
if x < -1.0700427558809735
Initial program 61.6
\[\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.4
\[\leadsto \color{blue}{\left(\log \frac{1}{2} + \left(\log \left(\frac{-1}{x}\right) + \frac{3}{32} \cdot \frac{1}{{x}^{4}}\right)\right) - \frac{1}{4} \cdot \frac{1}{{x}^{2}}}\]
Applied simplify0.4
\[\leadsto \color{blue}{\left(\frac{\frac{3}{32}}{{x}^{4}} + \log \frac{1}{2}\right) + \left(\log \left(\frac{-1}{x}\right) - \frac{\frac{\frac{1}{4}}{x}}{x}\right)}\]
if -1.0700427558809735 < x < 0.006949973394836614
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.006949973394836614 < x
Initial program 31.0
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify0.1
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' +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)))))