# Tag Info

15

Juho's algorithm can be improved to an $O(N)$ algorithm using meet-in-the-middle. Go over all pairs $A,B \leq \sqrt{N}$; for each pair such that $M=A^2+B^2 \leq N$, store $(A,B)$ in some array $T$ of length $N$ (each position $M$ could contain several pairs, which might be stored in a linked list). Now go over pairs $M,N-M$ such that the corresponding cells ...

13

But infinity isn't an integer. Since there is no integer $n$ such that $n=n+1$, you're right that the set is empty.

12

Shoup (Section 3.3.5, Theorem 3.3, p. 62) gives a bound for computing the residue $r$ in time $O(n\log q)$ where $a = q\cdot p +r$ and $\log a = n$. I guess that if $p$ and $a$ are both roughly $n$ bit numbers, then $q$ (and hence $\log q$) should be rather small, giving $O(n)$. If $a$ is an $n$-bit number, and $p$ is relatively small, then the ...

12

Here are the three tests you're (implicitly) considering: Fermat: test whether $a^{n-1} \equiv 1 \pmod{n}$ Solovay-Strassen: test whether $a^{(n-1)/2} \equiv \left( \dfrac{a}{n} \right) \pmod{n}$ (where $\left( \dfrac{a}{n} \right)$ is a Jacobi symbol, which can be calculated using quadratic reciprocity via a GCD-like algorithm) Miller-Rabin: suppose $n-1 = ... 12 By using the fast Fourier transform, multiplications on$k$-bit numbers can be done in time$\tilde{O}(k)$(where the tilde signifies that we're ignoring polylogarithmic factors). By repeated squaring, we can compute$n^{n^2}$with$O(\log n)$multiplications, and each multiplication involves no number larger than$n^{n^2}$, which has roughly$n^2 \log_2 n$... 12 If the state of the PRNG is finite, then it has a finite period. (By finite, I mean the same as we mean when we say that a finite-state automaton is finite: the set of all possible states is finite. For instance, if the state always fits into$b$bits, for some fixed value of$b$, then its state is finite.) In practice, worrying about the period of the ... 12 Here I assume$0\in \mathbb N$. If you disagree start with$105$. Let$S$be the sequence of numbers of the form$3^i5^j7^k$. Our task is to generate these numbers in order. Apart from$1$each number added is of the form$3\cdot x$,$5\cdot y$or$7\cdot z$where$x,y,z$are previous numbers in the sequence. We can generate$S$by shifting$x,y,z$along ... 12 A simple answer is "binary search". Keep track of a lower bound (starts out with 1) and an upper bound (starts out with$n$). In each iteration compute the midpoint$m$. In polytime check if$m∗m=n$. If so, terminate. Otherwise, if$m∗m>n$reduce the upper bound to$m$, else increase the lower bound to$m$. If the upper bound and the lower bound become ... 10 The statement is about infinitely many numbers, but its demonstration (or refutation) would have to be a finite exercise. If possible. The surprise may come from the (false) assumption that finding BB(100) would be a "theoretically easier" problem, only made impossible for practical reasons - since there are so many machines, and they can run for such a ... 9 The idea from the author was that you can write a program in 100 lines (any fixed finite number here) which does the following: takes number x, tests conjecture. If not true then stop else continue on the next number. Knowing busy beaver number you can simulate this machine for that number of steps and then decide if it halts or not. From above, if it halts ... 8 The advantage in using base 2 is that we know all of the psp's base 2 up to$2^{64}$. It has been verified that none of these psp(2)'s passes a Lucas test when the parameters$P, Q$are chosen in accord with any of the methods in the Baillie/Wagstaff paper. If you choose a random base, there might be some composite$n$that passes both the Fermat and Lucas ... 7 Aaronson has recently expanded in detail on this musing/ idea here working with Yedidia. they find an explicit 4888 state machine for the Goldbachs conjecture. you can read the paper to see how it was constructed. TMs are rarely constructed but those that have been tend to be compiler-like based on high level languages and the compilers add many states. a ... 7 The function$\log^\ast$("log-star", iterated logarithm), which shows up in complexity theory, is exactly the number of applications of$\log$which reduce a number below some constant. (Confusingly, in information theory the same notation is used for the function$\log + \log\log + \log\log\log + \cdots$.) 6 Consider a weighted, directed graph, with a vertex$v_i$for$i\in\mathbb{N}$. There is an edge with weight$j-i$from$v_i$to$v_j$if$j\in\{3i,5i,7i\}$. Now run Dijkstra's shortest path algorithm. It will expand exactly the nodes from your sequence and do so in order. This gives an$n\log n$algorithm to enumerate the first$n$elements, since the graph ... 6 It's a standard intro theory exercise that for any$d\ge 0$there's a FA that accepts all and only those strings in$\{0, 1\}^*$that are the binary representations of integer multiples of$d$. Thus, the answer to your second question is "yes". For your third question, the answer is "no". Consider the regular language denoted by$1(10)^*0$. This language ... 6 It is possible to improve on your second algorithm by using better algorithms for integer factorization. There are two algorithms for integer factorization that are relevant here: GNFS can factor an integer$\le C$with running time$O(L_C[0.33,1.92])$. ECM can find a factors$\le n \log C$(if any exists) with running time$O(L_{n \log C}[0.5,1.41])$; ... 6 Your intuition is exactly right. Yes, that's equivalent to choosing a random polynomial over$\mathbb{F}_p$. The reason why it works is exactly the interpolation theorem for finite fields.$k$-wise independent basically means "it behaves like a perfect hash function, if you only feed it$k$inputs" or "it behaves like a perfect hash function, as far as ... 6 In short: we don't know :-) There is a ((very) little) chance that the Collatz sequence is Turing complete (with probably some caveats like in the case of Two-counter Machines); i.e. there is an algorithm which for every turing machine$M$outputs an$x$such that:$Collatz(x)$is on a divergent trajectory if and only if$M$doesn't halt on empty tape in ... 6 Here is a general solution for the following problem: Given a positive integer$m$, find positive integers$a,b \geq 2$such that$a^b$is as close as possible to$m$. Let$n$be the length of$m$in bits (so$n = \Theta(\log m)$). If$2^b > m$then there is no point to check any$b_0 > b$, hence we only need to check$O(\log m) = O(n)$many ... 6 As far as we know there is no efficient way to do that. Such a way would constitute a break of the DSA scheme, and no break of the DSA is known. In particular, DSA is believed to be secure, so it is believed that no efficient algorithm for this exists. If you only want to do it for small numbers, you can just use brute force and try all possible values of ... 6 Consider the language $$L = \{ 0^{m^k} : m \geq m_0 \}.$$ Since$m_0$and$m_0+1$are relatively prime, so are$m_0^k$and$(m_0+1)^k$. Hence every large enough integer is a non-negative integer combination of$m_0^k$and$(m_0+1)^k$, implying that $$L^* \supseteq \{ 0^m : m \geq M_0 \}$$ for some$M_0$, and so$L^*$is regular. Using the classical formula ... 5 The continued fraction algorithm is easy enough to implement. The first step is to compute the continued fraction of the input$x = [c_0;c_1,\ldots]$. You start with$x_0 = x$, and use the recurrence$c_i = \lfloor x_i \rfloor$,$x_{i+1} = 1/(x_i - c_i)$. You stop when$x_i - c_i$is "small enough". The next step is to compute the convergent of the continued ... 5 Your operation is multiplication of polynomials over$GF(2)$, i.e., multiplication in the polynomial ring$GF(2)[x]$. For instance, if$p=101$and$q=1101$, you can represent them as$p(x)=x^2+1$,$q(x)=x^3+x^2+1$, and their product as polynomials is$p(x) \times q(x) = x^5+x^4+x^3+1$, so$p \otimes q = 111001$. If$p,q$are$r$bits long, this polynomial ... 5 I think a$o(N^2)$time algorithm is not a trivial one and requires some insight if one exists. The obvious algorithm that runs in quadratic time enumerates all tuples$A,B,C,D \leq \sqrt[]{N}$. This can be done in four loops, so the total time complexity becomes$O(N^2)$. It also clearly enumerates all solutions. As relating algorithms, Rabin and Shallit [... 5 Solve a linear homogeneous recurrence to obtain the identity $$\sum_{K=0}^n\frac1{a^K}=\begin{cases}\frac{1-1/a^{n+1}}{1-1/a}&\text{if }a\neq1\pmod m\\n+1&\text{if }a=1\pmod m\end{cases}$$ and use efficient algorithms for multiplicative inversion and exponentiation mod$m$. 5 It is my uninformed belief that Rademacher's formula is faster in practice (and perhaps in theory also) than the Bruinier and Ono formula. While Rademacher's asymptotic expansion is an infinite sum, we know that$p(n)$is an integer, so if we have bounds on the tails of the expansion, we can use the formula to compute$p(n)$. According to Calkin et al., "the ... 5 Computation with large integers is one of the topics of Knuth's "Seminumerical Algorithms" (volume 2 of "The Art of Computer Programming"). Results in elementary number theory, like the properties of modular arithmetic, the Chinese Remainder Theorem, Fermat's little theorem/Euler's theorem are critical here. As commented, this operation is central in ... 5 Idea: Count explicitly how many factors$2$the numbers in$[1..n]$contribute to$n!$. Observe that every other number adds one (the even numbers), every fourth adds another (those divisible by four), every eighth another, and so on. Hence, the number$\#_2(n!)$of factors$2$in$n!$fulfills$\qquad\displaystyle\begin{align*} \#_2(n!) &\leq \sum_{...

5

You are completely right, and your algorithm is a randomized polynomial time algorithm for finding a quadratic non-residue modulo a prime. A major open question in algorithmic number theory is finding a quadratic non-residue deterministically in polynomial time. This is possible assuming the generalized Riemann hypothesis, but unknown unconditionally. It is ...

5

Let me start with a counterexample where your algorithm gives the wrong answer: i.e., where $N$ is composite but your algorithm concludes it is prime. Suppose $N=91$ and $a=9$. Then $a^{(N-1)/2} = 9^{45} \equiv 1 \pmod{91}$, so $a$ passes your check to be a QR. Also, $a^{(N+1)/4} = 9^{23} \equiv 81 \pmod{91}$ and $81^2 \equiv 9 \pmod{91}$, so this passes ...

Only top voted, non community-wiki answers of a minimum length are eligible