0
$\begingroup$

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.

$\endgroup$
8
  • 2
    $\begingroup$ 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? $\endgroup$
    – lulu
    Sep 28, 2023 at 18:28
  • $\begingroup$ No, A can be a decimal number, and A is always greater than B. $\endgroup$
    – Maria
    Sep 28, 2023 at 18:32
  • $\begingroup$ 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? $\endgroup$
    – lulu
    Sep 28, 2023 at 18:34
  • $\begingroup$ @lulu, it doesn't avoid the calculation 2^b or 2^(a-b) $\endgroup$
    – Maria
    Sep 28, 2023 at 18:35
  • $\begingroup$ @lulu,your answer is like that answers and it doesn't avoid the calculation 2^b or 2^(a-b) $\endgroup$
    – Maria
    Sep 28, 2023 at 18:37

2 Answers 2

1
$\begingroup$

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$

$\endgroup$
6
  • $\begingroup$ WOW, let me try it with some numbers. $\endgroup$
    – Maria
    Sep 28, 2023 at 18:38
  • 1
    $\begingroup$ @Maria, this is the same as one of the answers you got on the Mathematica site. $\endgroup$ Sep 28, 2023 at 18:49
  • $\begingroup$ @Peter, thanks, I will try that one again too. $\endgroup$
    – Maria
    Sep 28, 2023 at 18:52
  • $\begingroup$ 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. $\endgroup$
    – Maria
    Sep 28, 2023 at 21:28
  • $\begingroup$ $2^{5.257} - 2^5 = 38.24-32 = 6.24 = 2^{2.64}$ $\endgroup$
    – user317176
    Sep 28, 2023 at 22:21
1
$\begingroup$

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .