Solving $2^a - 2^b = 2^x$ for extremely large $a$ and $b$

93 Views Asked by At

I want to solve the equation
$$2^a - 2^b = 2^x,$$

where $a$ and $b$ are extremely large numbers, for example $a =10^{10000 G}$, $B=10^{100G}$ with $G=10^{10^{100}}$, and I don't want to calculate the value of 2 to the power of $a$ or $b$ while solving the equation.

I hope this is the right place for my question, because I asked the same question here, but they said it is off-topic.

2

There are 2 best solutions below

6
On BEST ANSWER

Unless $a$ is close to $b$, $2^a>>2^b$ and the $2^b$ term can be dropped (and $x\approx a$) unless you need an exact answer.

In which case.

$2^a - 2^b = 2^b(2^{a-b} - 1) = 2^x\\ \log 2^b + \log (2^{a-b} - 1) = \log 2^x$

$b\log 2 + \log (2^{a-b} - 1) = x\log 2\\ x-b = \frac {\log (2^{a-b} - 1)}{\log 2}\\ x = \frac {\log(2^{a-b} - 1)}{\log 2} + b$

Log base 2 ($\lg$) might make this a little bit nicer as $\lg 2 = 1$

$x = \lg(2^{a-b} - 1) + b$

0
On

Consider that you look for the zero of function $$f(x)=2^x-(2^a - 2^b) \qquad \text{with}\qquad a > b$$ Write it better as $$g(x)=x\log(2)-\log(2^a - 2^b)=x\log(2)-a\log(2)-\log(1-\epsilon)$$ with $\color{red}{\epsilon=2^{b-a}}$. This gives $$x=a+\frac{\log (1-\epsilon )}{\log (2)}\sim a-\frac{2^{b-a}}{\log (2)}$$

For $a=7$ and $b=5$, this gives $x=6.63933$ while the solution is $6.58496$.

Make it better using Taylor series which will write $$x=a-\frac{1}{\log (2)}\sum_{n=1}^\infty \frac {\epsilon^n} n$$

For the above example, using $p$ terms in the summation

$$\left( \begin{array}{cc} p & x_{(p)} \\ 1 & 6.63933 \\ 2 & 6.59424 \\ 3 & 6.58673 \\ 4 & 6.58532 \\ 5 & 6.58504 \\ \end{array} \right)$$

and you will need less and less terms to add when $(a-b)$ will be larger and larger.

You can even make it better if, instead of Taylor series, you use the $[n+1,n]$ Padé approximant $P_n$ of $\log (1-\epsilon )$.

For example $$P_2=-\frac{\epsilon \left(\epsilon ^2-21 \epsilon +30\right)}{9 \epsilon ^2-36 \epsilon +30}$$ whose error is $\frac{\epsilon ^6}{600}$ would give $x=6.58496$ (which is the solution).