0

I am looking for the fastest algorithm to calculate the $$C^n$$ where the $C$ is some algebraic constant.

For example it can be $$C=\frac{\sqrt3-1}{2}$$ or one of the root of $$x^5+x^2-1=0$$

If $$C=2$$ the algorithm is very simple and it has complexity $O(\ln n)$. The same is for any other natural number I assume.

  • 1
    Depends on what you mean by "calculate," but yes, the $O(\log n)$ approach (the method of repeated squaring) will work in most cases. – Thomas Andrews Jul 14 '17 at 22:40
  • 2
    Exactly, if you know $p(x)$, the minimal polynomial of $C$, then $C^n$ can be computed by applying repeat squaring in $\mathbb{K}[x]/(p(x))$. – Jack D'Aurizio Jul 14 '17 at 22:45
  • 1
    About Fibonacci numbers, for instance: https://math.stackexchange.com/a/2081266/44121 – Jack D'Aurizio Jul 14 '17 at 22:46
  • Thanks just spend time on reading of https://en.wikipedia.org/wiki/Exponentiation_by_squaring article based on comments. It may be helpful for others as well: – Gevorg Hmayakyan Jul 15 '17 at 07:10
  • And also many thanks for the Fibonacci numbers article. I was looking for the similar thing. – Gevorg Hmayakyan Jul 15 '17 at 07:11
  • excuse me but how exactly are you computing $2^n$ in $O(\log n)$ steps if it takes $O(n)$ steps to write the result ? – mercio Jul 16 '17 at 10:07
  • Actually here we made an assumption that each number is a single symbol. And only operation count is calculated on those symbols. But complexity of writing of number is a different task and it depends on many factors including the base etc. – Gevorg Hmayakyan Jul 23 '17 at 12:29

0 Answers0