CS 6104 : Solutions to Homework Assignment 1

June 5, 1998

CS 6104: Algorithmic Number Theory

Problem 1. [Solution courtesy of Nick Loehr]

Use the techniques in Chapter 2 to derive an asymptotic estimate for

eqnarray50

where tex2html_wrap_inline239 is an integer. For tex2html_wrap_inline241 and tex2html_wrap_inline243 , use Mathematicato compute h(x,k) precisely. Present these results in a table along with the values of your asymptotic estimates.


Recall Theorem 2.7.1, which states that for continuously differentiable functions g,

  equation53

where tex2html_wrap_inline249 . Fix an integer tex2html_wrap_inline239 , and set tex2html_wrap_inline253 . Then (1) becomes:

  equation60

First, let us estimate the integral tex2html_wrap_inline255 . We will use Theorem 2.6.1 with tex2html_wrap_inline257 . We have

displaymath229

We may take tex2html_wrap_inline259 in the theorem. Since tex2html_wrap_inline261 , we obtain

displaymath230

Knowing that tex2html_wrap_inline249 , it's obvious that the two error terms tex2html_wrap_inline265 and tex2html_wrap_inline267 are each tex2html_wrap_inline269 . Hence, we have

displaymath231

The following Mathematica code computes h(x,k) precisely for the given values of x and k:

In[1]:= h[x_,k_] := Module[
          {sum, i},
          sum=0; i=2;
          While[ i <= x,
            If[ PrimeQ[i], sum = sum + i^k, ];
            i = i + 1
          ];
          sum]
In[11]:= Table[h[10,k],{k,1,4}]
In[12]:= Table[h[50,k],{k,1,4}]
In[13]:= Table[h[100,k],{k,1,4}]
In[14]:= Table[h[200,k],{k,1,4}]

The following code computes approximations for h(x,k) using the formula just derived:

n[18]:= ah[x_,k_]:=N[x^(k+1)/((k+1)*Log[x])]
In[19]:= Table[ah[10,k],{k,1,4}]
In[20]:= Table[ah[50,k],{k,1,4}]
In[21]:= Table[ah[100,k],{k,1,4}]
In[22]:= Table[ah[200,k],{k,1,4}]

The exact results produced by Mathematica are as follows.

displaymath232

The approximations produced by Mathematica are as follows.

displaymath233


Problem 2. [Solution courtesy of Nick Loehr]

Let R be the ring tex2html_wrap_inline291 , and consider the polynomial ring R[X]. Let tex2html_wrap_inline295 be the polynomial

eqnarray105

Finally, let

eqnarray107

  1. Prove that I is an ideal in R[X].
  2. Let T=R[X]/I. How many elements does T have? What are they?
  3. Give addition and multiplication tables for T.
  4. Is T a field? Why or why not?


  1. Let tex2html_wrap_inline309 We claim that I=J. To see this, take any tex2html_wrap_inline313 . Letting g=p and h=1 in the definition of I shows that tex2html_wrap_inline321 . Similarly, for any tex2html_wrap_inline323 , note that g(x)f(x)h(x)=(g(x)h(x))f(x). Taking p(x)=g(x)h(x) shows that tex2html_wrap_inline329 .

    The proof that I is an ideal is now identical to the proof given in class that J is an ideal. We repeat that proof here for completeness.

    Certainly tex2html_wrap_inline335 , so J is non-empty.

    Suppose tex2html_wrap_inline339 and tex2html_wrap_inline341 are arbitrary elements in J. Then

    displaymath279

    using the distributive law and the fact that tex2html_wrap_inline345 . So J is closed under addition.

    Similarly, if tex2html_wrap_inline349 and tex2html_wrap_inline351 , then

    displaymath280

    using the associativity of multiplication and the fact that tex2html_wrap_inline353 . So J is closed under multiplication by elements of R[x]. Hence, J=I is an ideal in R[x].

  2. The factor ring T has nine elements, namely the equivalence classes

    displaymath281

    To see that these nine elements are distinct, observe that I consists of all multiples of tex2html_wrap_inline367 . Nonzero multiples of I will clearly have degree at least 2, since the coefficient ring tex2html_wrap_inline291 has no zero divisors. Thus, the difference of two distinct elements of the form tex2html_wrap_inline373 is not in I, since this difference is a nonzero polynomial of degree less than 2.

    Next, T does not have any additional elements. For, any polynomial of degree 2 or more is equivalent to one of the polynomials listed above, since we can reduce modulo f to replace tex2html_wrap_inline381 by -2=1, tex2html_wrap_inline385 by x, etc.

  3. The addition table for T is as follows: (Here, we write 0 for the equivalence class tex2html_wrap_inline393 , etc.)

    displaymath282

    This first table is easily computed by noting that 3=0 in the coefficient ring.

    The multiplication table for T is easily computed if we remember to replace tex2html_wrap_inline381 by 1 whenever it appears in a product. We get:

    displaymath283

  4. T is not a field since not all nonzero elements have multiplicative inverses. For example, x+1 has no multiplicative inverse, by inspection of the table above.


Problem 3. [Solution courtesy of Jeremy Rotter]

Chapter 3, Problem 8.

  1. Give pseudocode for your algorithm to solve f(x)=n. Analyze its worst case time complexity.
  2. Program your algorithm in Mathematicaor other symbolic computation system. Include the Mathematicacode in your solution.
  3. Use your algorithm to determine whether a solution exists to

    eqnarray132

    where f(x) is this polynomial

    displaymath134


  1. The following is pseudocode for an algorithm which will determine whether there exists a positive integer x such that f(x) = n, and if there is, it will return that integer. Otherwise it will return FALSE.

    The problem specification did not require a proof on why this works, so I haven't provided one! In a nutshell, however, this algorithm works because when x ;SPMgt; 0, tex2html_wrap_inline417 . This means that when x ;SPMgt; 0, the function is increasing, and hence we can rely on the fact that, if f(a) ;SPMlt; n, then f(x) ;SPMlt; n for all tex2html_wrap_inline425 . Similarly, if f(a) ;SPMgt; n, then f(x) ;SPMgt; n for all tex2html_wrap_inline431 . This allows us to use a binary search to find the solution.

    tabular140

    This algorithm, in the worst case, is clearly tex2html_wrap_inline467 , since all it does is start with a search range of [0,n], and then it uses a binary search to repeatedly half the range until it either finds an x such that f(x) = n or it reduces the search range to a single integer. Everything outside of the while loop in the program will run in constant time. The tex2html_wrap_inline467 represents the worst case number of calls to the function f, which I am assuming also runs in a constant amount of time.

  2. The following is the Mathematica code to solve f(x) = n:

    (************************************************************************
     Function DiophantineSolve takes as parameters a function f and an
       integer n, and returns either a non-negative integer x such that
       f(x) = n or -1 if no such non-negative integer exists.
    ************************************************************************)
    
    DiophantineSolve[f_, n_] := Module[{},
    
        (* Set the range of integers in which we will find our answer *)
        rbegin = 0;
        rend = n;
    
        (* Choose our initial guess *)
        index = Floor[(rend+rbegin)/2];
        val = f[index];
    
        (* Search until we find an answer or run out of integers *)
        While[(rbegin != rend)&&(val != n),
    
            (* If the search range was of length 1, make it length 0 *)
            If[(rend-rbegin) == 1, rbegin = rend,
                If[ val > n, rend = index - 1, rbegin = index + 1]
            ];
            index = Floor[(rend+rbegin)/2];
            val = f[index];
        ];
    
        (* Set -1 as the return value if no answer was found *)
        If[ val != n, index = -1];
        index
    ]
  3. Here are the commands I gave to Mathematica to find the solution for the given n:

    (* Here we define f *)
    f[x_] := 14x^17 + 99x^7 + 3x^2 + 94
    
    (* Now we can solve part C on the homework *)
    DiophantineSolve[f, 33110401974639861466556783753600023154051803888587048939300]
    The Mathematica function found the solution:

    displaymath164




cs6104 class account
Fri Jun 5 16:21:45 EDT 1998