1

Let $x$ be a positive integer and let $y$ be a real number such that $$y=\sqrt{x}$$

Objectives:

  1. If $y$ is an integer, find it in polynomial time.

  2. If $y$ is not an integer, prove that there is no integer solution in polynomial time.

Is there any algorithm which can do that?

Fejwin
  • 155
  • 2
    If you can find the integer square root in polynomial time, the you can prove the 2nd objective at the cost of 1 multiplication & 1 comparison: $\lfloor \sqrt{x} \rfloor^2 \stackrel{?}{=} x$. Check the book:$\ $ A Course in Computational Algebraic Number Theory by H. Cohen. There might be an algorithm for computing the integer square root. –  Sep 01 '12 at 16:13
  • 1
    Apparently this post http://math.stackexchange.com/questions/34235/algorithm-for-computing-square-root-of-a-perfect-square-integer –  Sep 01 '12 at 16:14
  • 1
    Don't you want polynomial in $\ln(x)$? – i. m. soloveichik Sep 01 '12 at 16:25

2 Answers2

3

You could implement some sort of digit-by-digit algorithm. If $n=\log x$, this should involve $O(n)$ arithmetic operations, none of which involve numbers larger than $x$. So the time required will be no worse than $O(n^3)$ or thereabouts; certainly it'll be polynomial in $n$.

Micah
  • 38,733
0

Simply testing if $x=k^2$ for $k=0, 1, \ldots$ until you hit or exceed $x$. has time $O(\sqrt x)$.

  • Please, take into account that the input is stored in bits and one multiplication is not one step, but already a polynomial of steps, depending on the input size. – Fejwin Sep 01 '12 at 16:07
  • ... and not forgetting that "polynomial" here should mean "polynomial evaluated at $\log x$" or "polynomial in the number of digits of $x$" – Jyrki Lahtonen Sep 01 '12 at 19:22