The CF Bracket facility exposes a slowly growing collection of specialized frrrApplets. Those in support of "Modular Square Roots" have their own section later in this chapter of the Frrraction Guide. Others are listed here.
keyword | action |
---|---|
Classifies an integer as prime or composite. Setup: m in active cell Fcell Action: Fflt announces "Fcell is (or is not) prime" | |
Calculates the smallest prime factor of integer x Setup: F=x/s where 1 ≤ s ≤ smallest prime factor of x Action: Replaces s by the true smallest prime factor of x, and inserts that factor as text immediately following the }} bracket. | |
Raises x to the integer power n Setup: F=n+x/1 where F is the active fraction Action: F becomes r+x/1 where r is the 32-bit nth power of x. The 64-bit r is shown in hNote. | |
Computes x^n=xn (mod p) — the nth power of x (mod p) Setup: activeF=n+x/p. n,x,p all >0; p prime. Action: F becomes r+x/p where r is the nth power of x (mod p). |
|
Raises the modular complex number z=x+v·y to the power n modulo prime p. w=v2=v^2 is the user-selected QNR square of the imaginary carrier v. Setup: F1=n+x/p, F2=w+y/p. Action: The fractions become F1=n+A/p, F2=w+B/p where z^n = A+B·v (mod p). | |
mn! | mn! and n!Modm are synonyms. They compute n factorial (mod m) Setup: activeF = 0+n/m Action: activeF = n!(mod m) + n/m Note: If you use pMAX for m, the result is the normal n! for 0 ≤ n ≤ 12. For n=13 and beyond, n! would cause 32-bit overflow (while n!Modm does not, of course). |
Frrraction offers a constellation of CF functions that address square roots in various forms:
Background of mSqrt: mSqrt is unsophisticated, and can be quite time-consuming when p is larger than a few million: It uses a brute force search method, checking all residues one at a time to see whether its square, reduced modulo p, is congruent to x. It was not Frrraction's first nor least-sophisticated modular square root solution, however. That one was based on the fact that √x mod p is always simply the integer square root of an integer perfect square that can be expressed in the form: k·p + x for some positive integer k. The method tried k-values one at a time, looking for the smallest for which k·p + x was an integer perfect square—which it recognized by its being the sum of the first j odd integers; having found such a value for k, voila!: j was √x. This approach works fine if the sought-after value of k is small, but bogs down otherwise. An example where k is too large to find comfortably by simple calculator operation is √7 mod 4567. In this case one finds that 111·4057 + 7 is an integer perfect square, and can easilty proceed from there to the desired square root—but nobody's patience would tolerate the manula search through 111 values of k in order to reach that point. |
TryIt: One of 6 or 7 has a square root modulo 4,567. Determine which one it is, and find the square root. Hint: It's not easy to do without software help. |