Average Error: 52.2 → 0.2
Time: 57.6s
Precision: 64
Internal Precision: 2368
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.0740806814635735:\\
\;\;\;\;\log \left((\left(\frac{1}{x}\right) \cdot \left((\left(\frac{1}{x}\right) \cdot \left(\frac{\frac{1}{8}}{x}\right) + \left(-\frac{1}{2}\right))_*\right) + \left(\frac{-\frac{1}{16}}{{x}^{5}}\right))_*\right)\\
\mathbf{if}\;x \le 0.004985663317943214:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \log \left(e^{\frac{1}{6} \cdot {x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \left(\log \left(\sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}}\right) + \log \left(\sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}}\right)\right)\\
\end{array}\]
Target
| Original | 52.2 |
|---|
| Target | 44.9 |
|---|
| 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.0740806814635735
Initial program 61.8
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify61.0
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
Taylor expanded around -inf 0.1
\[\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.1
\[\leadsto \color{blue}{\log \left((\left(\frac{1}{x}\right) \cdot \left((\left(\frac{1}{x}\right) \cdot \left(\frac{\frac{1}{8}}{x}\right) + \left(-\frac{1}{2}\right))_*\right) + \left(\frac{-\frac{1}{16}}{{x}^{5}}\right))_*\right)}\]
if -1.0740806814635735 < x < 0.004985663317943214
Initial program 58.6
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify58.6
\[\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}}\]
- Using strategy
rm Applied add-log-exp0.3
\[\leadsto \left(\frac{3}{40} \cdot {x}^{5} + x\right) - \color{blue}{\log \left(e^{\frac{1}{6} \cdot {x}^{3}}\right)}\]
if 0.004985663317943214 < x
Initial program 30.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)}\]
- Using strategy
rm Applied add-sqr-sqrt0.2
\[\leadsto \log \color{blue}{\left(\sqrt{\sqrt{1^2 + x^2}^* + x} \cdot \sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]
Applied log-prod0.2
\[\leadsto \color{blue}{\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]
- Using strategy
rm Applied add-sqr-sqrt0.2
\[\leadsto \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\color{blue}{\sqrt{\sqrt{1^2 + x^2}^* + x} \cdot \sqrt{\sqrt{1^2 + x^2}^* + x}}}\right)\]
Applied sqrt-prod0.2
\[\leadsto \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \color{blue}{\left(\sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}} \cdot \sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}}\right)}\]
Applied log-prod0.2
\[\leadsto \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \color{blue}{\left(\log \left(\sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}}\right) + \log \left(\sqrt{\sqrt{\sqrt{1^2 + x^2}^* + x}}\right)\right)}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2018193 +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)))))