What's a numerically stable way to compute $$ \frac{2^{1/n}}{2^{1/n}-1} $$ for large (integer) $n$?
Asked
Active
Viewed 114 times
0
1 Answers
1
In the same spirit as Winter's comment, you can use Taylor series and get $$\frac{2^{1/n}}{2^{1/n}-1}=\frac{n}{\log (2)}+\frac{1}{2}+\frac{\log (2)}{12 n}-\frac{\log ^3(2)}{720 n^3}+O\left(\frac{1}{n^4}\right)$$ For $n=100$, the exact value would be $$144.77008171108427365$$ while the above approximation would give $$144.77008171108427312$$
Claude Leibovici
- 289,558
expm1or something similar, which implements $e^x-1$ avoiding cancellation when $x\approx 0$. Then $2^{1/n}-1$ isexpm1(x * log (2)). There is no numerical problem with the numerator. – May 12 '16 at 02:14