number theory assignment

2
1/2 Assignment # 3 Q1 Implement a subroutine that takes three positive integer arguments (a, b, n) and returns the value of (a b mod n), where the arguments are represented by about 100 decimal digits. Compare the execution time of that subroutine implementation using the four different approaches discussed at the lecture. Draw a 2D line chart for the fours implementations, where the x-axis represents the integer size and the y-axis represents the execution time. Q1 Implement the extended Euclid’s algorithm that finds the multiplicative inverse of a mod n, where a and n are positive integers that are relatively prime (i.e. gcd(a, n) =1). The multiplicative inverse b is a positive integer that is uniquely determined such that (ab) mod n = 1. Q3 Implement the unique mapping of Chinese Remainder Theorem that is stated as follows: Let M = m 1 x m 2 …. x m k , such that for every i ≠ j gcd(m i , m j ) =1 (i.e relatively prime) there is a bijection A ↔ (a 1 , a 2 , …., a k ) where A ϵ Z M and the k-tuple (a 1 , a 2 , …., a k ) ϵ Z m1 x Z m2 …. x Z mk The mapping from A to (a 1 , a 2 , …., a k ) is such that a i = A mod m i For the reverse mapping from (a 1 , a 2 , …., a k ) to A A = sum i k ( a i M i M i -1 mod M), where Computer and Systems Engineering Dept. Faculty of Engineering Alexandria University Discrete Mathematics Second Year, Fall 2012 Assigned Nov. 29 th 2012 Due: Dec. 13 th 2012

Upload: mohamed-hegazy

Post on 25-Nov-2015

5 views

Category:

Documents


1 download

DESCRIPTION

very very important

TRANSCRIPT

  • 1/2

    Assignment # 3 Q1 Implement a subroutine that takes three positive integer arguments (a, b, n) and returns the value of (ab mod n), where the arguments are represented by about 100 decimal digits. Compare the execution time of that subroutine implementation using the four different approaches discussed at the lecture. Draw a 2D line chart for the fours implementations, where the x-axis represents the integer size and the y-axis represents the execution time. Q1 Implement the extended Euclids algorithm that finds the multiplicative inverse of a mod n, where a and n are positive integers that are relatively prime (i.e. gcd(a, n) =1). The multiplicative inverse b is a positive integer that is uniquely determined such that (ab) mod n = 1. Q3 Implement the unique mapping of Chinese Remainder Theorem that is stated as follows: Let M = m1 x m2 . x mk , such that for every i j gcd(mi, mj) =1 (i.e relatively prime) there is a bijection A (a1, a2, ., ak) where A ZM and the k-tuple (a1, a2, ., ak) Zm1 x Zm2 . x Zmk The mapping from A to (a1, a2, ., ak) is such that ai = A mod mi For the reverse mapping from (a1, a2, ., ak) to A A = sumik( ai Mi Mi-1 mod M), where

    Computer and Systems Engineering Dept. Faculty of Engineering Alexandria University

    Discrete Mathematics Second Year, Fall 2012 Assigned Nov. 29th 2012 Due: Dec. 13th 2012

  • 2/2

    Mi = m1 x m2 x mi-1 x mi+1 x ... x mk Mi-1 = multiplicative inverse of Mi mod mi (use implementation of Q2) Compare the execution time of addition and multiplication in the two domains (ZM , Zm1 x Zm2 . x Zmk). Similarly, draw a 2D line chart of the integer size versus the execution time in the two cases. Assume M factoring to m1 x m2 . x mk is given.

    Dr. Sahar M. Ghanem