Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I need to implement a function $a+b\cdot 2^x$ in a highly resource constrained device. a and b are constants and x is a variable. How do I go about finding a simplified version of this expression so that I can get a value almost equal to it, without having to do multiplication, division or exponentiation? the result does not have to be exact, and I can find the new values for a and b empirically. Please help. Thank you

PS: please suggest some new tags for this question, I cannot think of any that are available currently

share|cite|improve this question
I'm not really sure what context you're doing this in, but you can try to round $x$ up or down to the nearest integer in which case the exponentiation becomes a bit-shift. Don't know if this helps you. – user38355 Nov 22 '12 at 15:47
I was thinking more along the lines pf using logarithms or something, to reduce the exponentiation and multiplication – user13267 Nov 22 '12 at 16:05
@user13267: it seems strange to be willing to take logs but not be willing to multiply. They are usually much slower. – Ross Millikan Jun 25 '13 at 23:21
when I was working on this it was for a DSP IC which has a fast logarithm operation. It's not as fast as multiplication, but if I converted all my operations in to logarithms including this one, I was hoping to simplify other parts of the overall program – user13267 Jun 26 '13 at 0:35

Here's one way of doing it (in C). LOG2_B is $\log_2b$. 0.5 is to make it round to the nearest int, instead of the flooring. The conversion to int, though, required to do the bit shift, might cause an unacceptable loss of precision.

A + 2 << (int)(LOG2_B + x + 0.5)

Here's a plot of the function (blue) and the above approximation (red) for $a=0, b=1$:

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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