6
$\begingroup$

I was working with some code involving exponents in an environment where exponents can only be calculated if the base of the exponent is an integer. I needed a good fast way to approximate this without causing overflow issues. I accidentally stumbled upon an incredible approximation method and I'm not sure why it works.

Suppose you have an exponent in the form of $x^y$ where $x$ is not an integer and you want to approximate the value using only exponents which have integers for their base-values.

Break $x$ into two parts, an integer part, and an additive. For example $3.7\to 3 + 0.7$.

Therefor, $x\to(a+b)$ where $a$ is an integer part.

The approximation formula is:

$$(a+b)^c \approx a^{c-bc} (a+1)^{cb}$$

Or in my original form:

$$(a+b)^c \approx ((a+b)-b)^{c(1-b)} ((a+b)+(1-b))^{cb}$$

It's remarkably close to the right solution seemingly every time. Granted I've only been able to check about 100 cases, but I'm fascinated.

For example:

$$37.5^{28} ≈ 37^{14}\cdot38^{14}$$

And sure enough, if we divide both parts, the ratio is 1.002 which is very close.

Edit: Thanks to RayDansh pointing out in the comments, this is accurate IFF $a+b$ is big. In fact, the larger $a$ gets the more accurate this approximation seems to get.

Can anyone shed some light as to why this approximation method I've stumbled upon works?

$\endgroup$
  • $\begingroup$ Well, here's your intuition. The exponent terms you've discovered are such that whichever of $a$ and $a+1$ are closer to $a+b$, those will be weighted more than the other term. And both happen to be remarkably close to $a+b$. Hence your discovery. $\endgroup$ – Don Thousand Aug 14 '18 at 23:48
  • 2
    $\begingroup$ What about $1.5^{100}≈1^{50}*2^{50}$? Quite inaccurate. $\endgroup$ – RayDansh Aug 14 '18 at 23:48
  • $\begingroup$ Just trying to show how the approximation loses accuracy as $x$ decreases and $y$ increases. $\endgroup$ – RayDansh Aug 14 '18 at 23:49
  • 1
    $\begingroup$ @RayDansh I think the point is that it improves for large $a$. $\endgroup$ – Ian Aug 14 '18 at 23:49
  • $\begingroup$ @RayDansh Right you are; I was only testing with large numbers. Seems to get 100% accurate as a approached infinity. How odd $\endgroup$ – Albert Renshaw Aug 14 '18 at 23:50
18
$\begingroup$

Write your approximation $$a^{c-bc} \cdot (a+1)^{cb}=a^c\left(1+\frac 1a\right)^{bc}$$ and your approximation is $$\left(1+\frac 1a\right)^{b}\approx 1+\frac ba$$ Which is the first two terms of the binomial expansion. It will be reasonably accurate when $\frac ba \ll 1$ The next term is $\frac {b(b-1)}{2a^2}$

$\endgroup$
  • 2
    $\begingroup$ Doesn't get clearer than this +1 $\endgroup$ – user159517 Aug 15 '18 at 0:31
6
$\begingroup$

As a general rule, if you see a lot of products and exponents it may clear things up to take logs. In your case,

$$(a+b)^c ≈ a^{c-bc} \cdot (a+1)^{cb}$$

becomes

$$c \log(a+b) \approx c(1-b) \log(a) + cb \log(a+1)$$

or just

$$\log(a+b) \approx (1-b) \log(a) + b \log(a+1).$$

This is equivalent to doing a linear interpolation of $\log x$ between the points $a$ and $a+1$. This will be pretty accurate when $a$ is large because $\log x$ will be close to linear between $a$ and $a+1$.

$\endgroup$
1
$\begingroup$

The answer is obvious. If we expand both sides of the formula by the binomial theorem, we get for the first two: $(a+b)^c=a^c+cba^{c-1}+ ...$ for both forms of the equation. Now, it is immediately apparent that this approximation will improve as a gets larger because the discarded terms become less significant. That is, for larger a, $a^n>>a^{n-1}$.

$\endgroup$
  • $\begingroup$ Of course it improves, but why is it significantly better than just keeping $a^c$? $\endgroup$ – Ian Aug 14 '18 at 23:58
  • $\begingroup$ Look at the rest of the binomial expansion terms that are omitted above $\endgroup$ – user553944 Aug 15 '18 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.