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

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.

• Are these meant to be integers? If so, then if $a>b$ we can rewrite the left hand to be $2^b(2^{a-b}-1)=2^x$ so we must have $b=x$. Or did you mean something else?
– lulu
Sep 28, 2023 at 18:28
• No, A can be a decimal number, and A is always greater than B. Sep 28, 2023 at 18:32
• You should edit to explain that, it's not obvious from what you wrote. What's wrong with the answers you got on the Mathematica site?
– lulu
Sep 28, 2023 at 18:34
• @lulu, it doesn't avoid the calculation 2^b or 2^(a-b) Sep 28, 2023 at 18:35
• @lulu,your answer is like that answers and it doesn't avoid the calculation 2^b or 2^(a-b) Sep 28, 2023 at 18:37

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$$

• WOW, let me try it with some numbers. Sep 28, 2023 at 18:38
• @Maria, this is the same as one of the answers you got on the Mathematica site. Sep 28, 2023 at 18:49
• @Peter, thanks, I will try that one again too. Sep 28, 2023 at 18:52
• even if you calculate this small numbers : a=5.257, b=5 with your answer it will get wrong result. the correct result is x=2.584. Sep 28, 2023 at 21:28
• $2^{5.257} - 2^5 = 38.24-32 = 6.24 = 2^{2.64}$ Sep 28, 2023 at 22:21

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).