Average Error: 52.4 → 0.0
Time: 1.1m
Precision: 64
Internal Precision: 2432
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -0.6133087509099974:\\
\;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \left(\frac{\frac{1}{16}}{{x}^{5}} + \frac{\frac{1}{2}}{x}\right)\right)\\
\mathbf{if}\;x \le 28.914529720558605:\\
\;\;\;\;\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}\]
Target
| Original | 52.4 |
|---|
| Target | 44.9 |
|---|
| Herbie | 0.0 |
|---|
\[\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 < -0.6133087509099974
Initial program 61.9
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around -inf 0.0
\[\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.0
\[\leadsto \color{blue}{\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \left(\frac{\frac{1}{16}}{{x}^{5}} + \frac{\frac{1}{2}}{x}\right)\right)}\]
if -0.6133087509099974 < x < 28.914529720558605
Initial program 58.6
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}}\]
if 28.914529720558605 < x
Initial program 30.3
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around inf 0.0
\[\leadsto \log \color{blue}{\left(\left(\frac{1}{2} \cdot \frac{1}{x} + 2 \cdot x\right) - \frac{1}{8} \cdot \frac{1}{{x}^{3}}\right)}\]
Applied simplify0.0
\[\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)}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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)))))