{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Warning" -1 7 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 1 3 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Out put" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" -1 12 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 } {PSTYLE "Author" -1 19 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 48 "Applied Symbolic Computat ion (CS 300) Final Exam" }}{PARA 19 "" 0 "" {TEXT -1 27 "Instructor: \+ Jeremy Johnson" }}{PARA 256 "" 0 "" {TEXT -1 16 "Spring 2003-2004" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 5 "Name:" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 3 "ID:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 99 "By submit ting this exam, I swear that this is my work and I have followed the i nstructions below. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 13 "Instructions:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 344 "There are four questions, each worth 25 \+ points. Questions may have several parts. Do as much as you can. Pa rtial credit will be given; however, you should clearly state what you were able to do and what you did were not able to do. If you do not \+ know how to do a question, proceed to the next question. Finish as ma ny questions as you can." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 373 "All work must be done alone. You may use Maple h elp and the introductory Maple materials that come with Maple. You ma y also use any of the lecture notes and worksheets from class in addit ion to homework solutions and your notes from class. You may not cons ult any other sources. You may not consult anyone else. If you need \+ clarification on a question, you may ask me." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 56 "Question 1 - Probabili ty Generating Function [25 points]" }}{PARA 0 "" 0 "" {TEXT -1 112 "A \+ discrete probability generating function for a random variable X that \+ takes on non-negative integer values is " }{XPPEDIT 18 0 "G[X](z) = Su m(Pr(X = k)*z^k,k=0..infinity)" "6#/-&%\"GG6#%\"XG6#%\"zG-%$SumG6$*&-% #PrG6#/F(%\"kG\"\"\")F*F3F4/F3;\"\"!%)infinityG" }{TEXT -1 53 ". Give n a discrete probability generating function, " }{XPPEDIT 18 0 "G[X](z )" "6#-&%\"GG6#%\"XG6#%\"zG" }{TEXT -1 63 ", the expected value, E[X], of X is equal to the derivative of " }{XPPEDIT 18 0 "G[X](z)" "6#-&% \"GG6#%\"XG6#%\"zG" }{TEXT -1 17 " evaluated at 1, " }{XPPEDIT 18 0 "d iff(G[X](1),z);" "6#-%%diffG6$-&%\"GG6#%\"XG6#\"\"\"%\"zG" }{TEXT -1 46 ". Recall that the expected value is equal to " }{XPPEDIT 18 0 "Su m(k*Pr(X = k),k = 0 .. infinity);" "6#-%$SumG6$*&%\"kG\"\"\"-%#PrG6#/% \"XGF'F(/F';\"\"!%)infinityG" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 431 "Assume that you have a coin and that the proba bility of heads is p and the probability of tails is q (with p+q=1). \+ First determine the probability that it takes exactly n tosses to ob tain the first heads. Then determine the generating function for the \+ probability that n tosses are needed to obtain one heads. Use Maple's series function to verify that the generating function does indeed ge nerate the correct probabilities. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 177 "Determine the expected value f rom the above remarks about how to use probability generating function s to determine the expected value. Calculate the numeric value when p = 1/2." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 43 "Question 2 \+ - Carmichael Numbers [25 points]" }}{PARA 0 "" 0 "" {TEXT -1 81 "Recal l that Fermat's theorem states that Power(a,p-1) mod p = 1 for 0 <= a \+ < p. " }}{PARA 0 "" 0 "" {TEXT -1 77 "Thus if Power(a, n-1) mod n <> \+ 1 for any number a, then n can not be prime. " }}{PARA 0 "" 0 "" {TEXT -1 102 "However, it is possible to find integers a such that Pow er(a,n-1) mod n = 1, even when n is not prime." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "with(numtheo ry);" }}{PARA 7 "" 1 "" {TEXT -1 69 "Warning, the protected name order has been redefined and unprotected\n" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7Q%&GIgcdG%)bigomegaG%&cfracG%)cfracpolG%+cyclotomicG%)divisorsG%)f actorEQG%*factorsetG%'fermatG%)imagunitG%&indexG%/integral_basisG%)inv cfracG%'invphiG%*issqrfreeG%'jacobiG%*kroneckerG%'lambdaG%)legendreG%) mcombineG%)mersenneG%(migcdexG%*minkowskiG%(mipolysG%%mlogG%'mobiusG%& mrootG%&msqrtG%)nearestpG%*nthconverG%)nthdenomG%)nthnumerG%'nthpowG%& orderG%)pdexpandG%$phiG%#piG%*pprimrootG%)primrootG%(quadresG%+rootsun ityG%*safeprimeG%&sigmaG%*sq2factorG%(sum2sqrG%$tauG%%thueG" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 256 7 "Part a)" } {TEXT -1 91 " A number n is called a pseudoprime to base a if Power(a, n-1) mod n = 1 and n is not prime." }}{PARA 0 "" 0 "" {TEXT -1 74 "Fin d all of the numbers a such that n = 39 is a pseudoprime to the base a ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "n := 39;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"nG\"#R " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 193 "Write a Maple procedure, called CountPP(n::posint ), which returns the number of bases a such that gcd(a,n)= 1 and the i nput n is a pseudoprime to the base a. Make sure you test your proced ure." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 160 "If n is a prime what does CountPP(n) return? What is th e maximum value returned by CountPP(n) as a function of n? Provide ex amples to illustrate your answers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 169 "Compute the probability that a number a is a base of a pseudoprim e for n [only consider a's such that gcd(a,n) = 1] for n from 2 to 100 . What observations can you make?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 142 "A Carmichael number is a numbe r n which is not prime, yet is a pseudoprime for every base a such tha t gcd(a,n) = 1. Find a Carmichael number?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 42 "Question 3 - Modular Fractions [25 points ]" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 207 "Wri te a Maple procedure that generates all fractions a/b such that 1 <= a ,b <= n. Do not generate duplicates. Show the output for several sma ll values of n so that you can verify that your code is correct." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 142 " Determine the ratio of the number of reduced fractions a/b such that 1 <= a,b <= n and n^2. Does this ratio appear to be approaching a limi t?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 409 "A fraction a/b can be reduced mod p, by mapping a/b to a * (1/b) mod p. If a prime p is sufficiently large, then the fraction s a/b with 1 <= a,b <= n get mapped to different images mod p. Map th e fractions a/b with 1 <= a,b <= n to Z_p for different n [atleast n = 4] and different primes p. What do you observe? How big does p have to be for all of the fractions to get mapped to different values in Z _p." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 276 "It is possible to recover the fraction a/b from the modu lar image provided the numerator a and denominator b are sufficiently \+ small. The maple function iratrecon does this. Look at the help page for iratrecon and use it to recover the fractions that you reduced mo d p above." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 53 "Question \+ 4 - Evaluation and Interpolation [25 points]" }}{PARA 0 "" 0 "" {TEXT -1 125 "Let A(x) = x^4 + 3*x^3 + 2*x^2 + x - 1. Construct the Vanderm onde matrix, which corresponds to evaluating A(x) at the points" }} {PARA 0 "" 0 "" {TEXT -1 160 "0,1, -1, 2, -2. I.E. the Vandermonde ma trix applied to the vector of coefficients [-1,1,2,3,1] should return \+ the vector of values [A(0),A(1),A(-1),A(2),A(-2)]." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 194 "Verify that this is the \+ case, by multiplyint the Vandermonde matrix you constructed and the ve ctor of coefficients of A. Compare the result to the vector of values [A(0),A(1),A(-1),A(2),A(-2)]." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "A := x^4 + 3*x^3+2*x^2+x-1; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG,,*$)%\"xG\"\"%\"\"\"F**&\" \"$F*)F(F,F*F**&\"\"#F*)F(F/F*F*F(F*F*!\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "P := [0,1,-1,2,-2];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"PG7'\"\"!\"\"\"!\"\"\"\"#!\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "with(linalg);" }}{PARA 7 "" 1 "" {TEXT -1 80 "Warning , the protected names norm and trace have been redefined and unprotect ed\n" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7^r%.BlockDiagonalG%,GramSchmi dtG%,JordanBlockG%)LUdecompG%)QRdecompG%*WronskianG%'addcolG%'addrowG% $adjG%(adjointG%&angleG%(augmentG%(backsubG%%bandG%&basisG%'bezoutG%,b lockmatrixG%(charmatG%)charpolyG%)choleskyG%$colG%'coldimG%)colspaceG% (colspanG%*companionG%'concatG%%condG%)copyintoG%*crossprodG%%curlG%)d efiniteG%(delcolsG%(delrowsG%$detG%%diagG%(divergeG%(dotprodG%*eigenva lsG%,eigenvaluesG%-eigenvectorsG%+eigenvectsG%,entermatrixG%&equalG%,e xponentialG%'extendG%,ffgausselimG%*fibonacciG%+forwardsubG%*frobenius G%*gausselimG%*gaussjordG%(geneqnsG%*genmatrixG%%gradG%)hadamardG%(her miteG%(hessianG%(hilbertG%+htransposeG%)ihermiteG%*indexfuncG%*innerpr odG%)intbasisG%(inverseG%'ismithG%*issimilarG%'iszeroG%)jacobianG%'jor danG%'kernelG%*laplacianG%*leastsqrsG%)linsolveG%'mataddG%'matrixG%&mi norG%(minpolyG%'mulcolG%'mulrowG%)multiplyG%%normG%*normalizeG%*nullsp aceG%'orthogG%*permanentG%&pivotG%*potentialG%+randmatrixG%+randvector G%%rankG%(ratformG%$rowG%'rowdimG%)rowspaceG%(rowspanG%%rrefG%*scalarm ulG%-singularvalsG%&smithG%,stackmatrixG%*submatrixG%*subvectorG%)sumb asisG%(swapcolG%(swaprowG%*sylvesterG%)toeplitzG%&traceG%*transposeG%, vandermondeG%*vecpotentG%(vectdimG%'vectorG%*wronskianG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 441 "The polynomial A(x) can be rec overed from the vector of values [A(0),A(1),A(-1),A(2),A(-2)], by usin g interpolation. First use Maple's interp function to interpolate the polynomial A(x) from its values [A(0),A(1),A(-1),A(2),A(-2)]. Second compute the inverse of the corresponding Vandermonde matrix and show \+ that multiplying the vector of values [A(0),A(1),A(-1),A(2),A(-2)] by \+ the inverse matrix yields the vector of coefficients of A(x)." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 121 "If we know that a polyno mial C(x) is sparse that it is not necessary to invert the full Vander monde matrix. Assume that " }{XPPEDIT 18 0 "C(x) = c[4]*x^4 + c[2]*x^ 2 + c[0]" "6#/-%\"CG6#%\"xG,(*&&%\"cG6#\"\"%\"\"\"*$F'F-F.F.*&&F+6#\" \"#F.*$F'F3F.F.&F+6#\"\"!F." }{TEXT -1 20 " - the coefficients " } {XPPEDIT 18 0 "c[3]" "6#&%\"cG6#\"\"$" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "c[1]" "6#&%\"cG6#\"\"\"" }{TEXT -1 237 " are assumed to be equal to 0. Show how to recover the non-zero coefficients of C(x) from the values C(0) = 1, C(2) = 2, and C(3) = 3. Hint: set up a 3 X 3 matrix that corresponds to evaluating C(x) at x = 0, 1, 2. Verify your resu lt." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "4" 0 } {VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }