1

I know this is a simple question but I cannot find an answer for it. I have two functions,

$$1:\ (1-e^a)^{(b^c)}$$

and

$$2:\ \frac{e^a \times a^b}{b!}$$

where $a,c$ are real numbers, $b=1,2,3,...$, $log(e)=1$ and $b!=b(b-1) ... 1$.

which one is more complex in computations for a machine (computer)?

Majid
  • 3,357
MyQ
  • 121

1 Answers1

1

Addition is fast compared to multiplication. To tackle this, let's first assume that a and c are also positive integers.

1: To calculate $e^a$ you need $a$ multiplications. To calculate $b^c$ it's $c$ multiplications. Then to raise the base (1-e^a) to the power of (b^c) you need $b^c$ multiplications. Total: $b^c + b + a$ multiplications.

2: In the same manner we get $a + 2b$ multiplications.

Having non-integer exponent is not so straightforward. But anyway I think it won't add much complexity. So it comes to deciding if $b^c>b$.

J Tim
  • 101
  • it should be a+c+b^c right? – MyQ Jul 17 '16 at 19:34
  • You don't need y multiplications to get $x^y$. You can use fast exponentiation which runs in $O((nlog(x))^k)$ time. Also, given the fact that the second option is viable, it's assumed that $b!$ should be small enough to fit in memory. In that case, b should be small (Relatively speaking from a computational point of view), and lookup tables can be used to find both b! and a^b, making both of those operations constant time. Only e^a would be difficult. – Aayush Agrawal Jul 17 '16 at 19:35
  • @AayushAgrawal can you explain your comment in an answer? – MyQ Jul 17 '16 at 19:38