11

My question is the following:

Is there a polytime non-numerical algorithm for computing square root of perfect square integers?

The more elementary the algorithm is, the better!


EDIT: This is probably the most silly question I ever asked (I hope!). As pointed out by picakhu, since the input integer $n$ is perfect square, we can simply do a binary search to find the number whose square equals to $n$.

Dai
  • 243
  • 3
    What's a non-numerical algorithm? And by "computing", do you mean "iteratively approximating by rational numbers"? If not, what do you mean? – joriki Apr 21 '11 at 04:51
  • 5
    No idea if this is relevant, but you could do a binary search – picakhu Apr 21 '11 at 04:53
  • Did you peruse the results of Googling "fast integer square root"? – Bill Dubuque Apr 21 '11 at 04:57
  • 1
    @Joriki: Numerical are algorithms that use numerical approximation (as opposed to general symbolic manipulations). So I prefer symbolic manipulation. But picakhu's answer sounds right! That's clever! It's a shame that I didn't think of that. Picakhu, could you please make it an answer? – Dai Apr 21 '11 at 04:57
  • 1
    I can imagine an $O(\sqrt n)$ time algorithm -- checking every number from 0 until you reach one that squares to your number. – Justin L. Apr 21 '11 at 04:57
  • @Justin: binary search is much better. When $n$ is large, $\sqrt{n}$ is not small. – Dai Apr 21 '11 at 05:01
  • @all: Sorry, I meant "perfect square" in my question. – Dai Apr 21 '11 at 05:03
  • I understand neither @Dai Le's answer to my comment, nor Justin L.'s comment. The question is about square roots of square-free integers. These are irrational numbers. What would it mean to "compute" one of these with symbolic manipulation and without numerical approximation? And how would checking every number (I presume you mean integer?) help if we know by definition none of them squares to the square-free integer? Was the question intended to ask about perfect squares instead? – joriki Apr 21 '11 at 05:04
  • @joriki: that's my typo, I meant "perfect square". The question on the title was the right one. Sorry again! – Dai Apr 21 '11 at 05:05
  • @Dai, Im not sure your condition on "non-numerical" even makes sense. The square root of a perfect square, n, is sqrt(n). Or, if you prefer, m is the square root of the perfect square m^2. That is as symbolic as you can get. If you have a real value to start, like 345,355,748, then any root will be numerical. – CogitoErgoCogitoSum Mar 15 '14 at 03:47

1 Answers1

11

The following should suffice, from Cohen: A course in computational algebraic number theory. enter image description here enter image description here

Bill Dubuque
  • 272,048