Average Error: 52.2 → 1.7
Time: 59.5s
Precision: 64
Internal Precision: 2368
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le -5.494590308109969 \cdot 10^{-24}:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \log \left(e^{\frac{1}{6} \cdot {x}^{3}}\right)\\
\mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 7.084021811928732 \cdot 10^{-306}:\\
\;\;\;\;\log \left(\left(\left(x + x\right) + \frac{\frac{1}{2}}{x}\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)\\
\mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 0.13128748121120157:\\
\;\;\;\;\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \log \left(e^{\frac{1}{6} \cdot {x}^{3}}\right)\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 52.2 |
|---|
| Target | 44.9 |
|---|
| Herbie | 1.7 |
|---|
\[\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 (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < -5.494590308109969e-24 or 0.13128748121120157 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x))
Initial program 56.2
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around 0 2.4
\[\leadsto \color{blue}{\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}}\]
- Using strategy
rm Applied add-log-exp2.7
\[\leadsto \left(\frac{3}{40} \cdot {x}^{5} + x\right) - \color{blue}{\log \left(e^{\frac{1}{6} \cdot {x}^{3}}\right)}\]
if -5.494590308109969e-24 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 7.084021811928732e-306
Initial program 33.2
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around inf 0.9
\[\leadsto \log \left(x + \color{blue}{\left(\left(\frac{1}{2} \cdot \frac{1}{x} + x\right) - \frac{1}{8} \cdot \frac{1}{{x}^{3}}\right)}\right)\]
Applied simplify0.9
\[\leadsto \color{blue}{\log \left(\left(\left(x + x\right) + \frac{\frac{1}{2}}{x}\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right)}\]
if 7.084021811928732e-306 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 0.13128748121120157
Initial program 61.9
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Taylor expanded around -inf 61.1
\[\leadsto \log \left(x + \color{blue}{\left(\frac{1}{8} \cdot \frac{1}{{x}^{3}} - \left(\frac{1}{2} \cdot \frac{1}{x} + x\right)\right)}\right)\]
Applied simplify0.2
\[\leadsto \color{blue}{\log \left(\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x}\right)}\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2018193
(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)))))