Average Error: 52.4 → 1.1
Time: 28.7s
Precision: 64
Internal Precision: 2432
\[\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 -536.0230928176488:\\
\;\;\;\;\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}\\
\mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 1.3496677481081412 \cdot 10^{-294}:\\
\;\;\;\;\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)\\
\mathbf{if}\;\frac{\frac{\frac{1}{8}}{x}}{x \cdot x} - \frac{\frac{1}{2}}{x} \le 1.245804171722264 \cdot 10^{-06}:\\
\;\;\;\;\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) - \frac{1}{6} \cdot {x}^{3}\\
\end{array}\]
Target
| Original | 52.4 |
|---|
| Target | 45.0 |
|---|
| Herbie | 1.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 (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < -536.0230928176488 or 1.245804171722264e-06 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x))
Initial program 58.3
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify58.3
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
Taylor expanded around 0 0.5
\[\leadsto \color{blue}{\left(\frac{3}{40} \cdot {x}^{5} + x\right) - \frac{1}{6} \cdot {x}^{3}}\]
if -536.0230928176488 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 1.3496677481081412e-294
Initial program 33.2
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify3.0
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
- Using strategy
rm Applied add-sqr-sqrt3.0
\[\leadsto \log \color{blue}{\left(\sqrt{\sqrt{1^2 + x^2}^* + x} \cdot \sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]
Applied log-prod3.0
\[\leadsto \color{blue}{\log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right) + \log \left(\sqrt{\sqrt{1^2 + x^2}^* + x}\right)}\]
if 1.3496677481081412e-294 < (- (/ (/ 1/8 x) (* x x)) (/ 1/2 x)) < 1.245804171722264e-06
Initial program 62.6
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
Applied simplify61.8
\[\leadsto \color{blue}{\log \left(\sqrt{1^2 + x^2}^* + x\right)}\]
Taylor expanded around -inf 61.8
\[\leadsto \log \left(\color{blue}{\left(\frac{1}{8} \cdot \frac{1}{{x}^{3}} - \left(\frac{1}{2} \cdot \frac{1}{x} + x\right)\right)} + x\right)\]
Applied simplify0
\[\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 '#(1070864556 424010669 783715395 1203517814 4070606583 4107618214)' +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)))))