Lu 1-la/b]]-L 4700 The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd(a,b): while (b): [a b]=[a b][/b] return a [m11 m121 If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] [m21 m22] 212] is the result of the matrix multiplications after several iterations: [m11 m121 where M = [m21 m22] M = m11 m -- m12] Lm21 m22] = 1 1 a/b/b] 1 Since m11*N + m21*x = 1, we have m21*x % N = 1, that is, m21 is the multiplicative inverse of x modulo N. Then, the program to compute the matrix M is proposed as mul inverse (N, x | N and x are coprime): [a b] = [N_x] M = · 66 9 while (be): M = M* M*[1₁ab] [a b] = [a b][/b] return M[2,1] Prove the correctness of the program by axiomatic semantics. Problem 2. The multiplicative inverse of an integer x modulo N where x and N are coprime (mutually prime), is an integer m < N such that mx % N = 1. A function prototype is given as: Input: unsigned int x, unsigned int N, where x and N are coprime. Output: unsigned int m, where m < N and mx % N = 1. Mathematically, mx % N = 1 is equivalent to mx + kN = 1 = gcd (x, N). The problem of finding multiplicative inverse becomes an application of the gcd problem. Recall that the gcd is solved by the Euclid's algorithm: Base case: gcd (a,b) = a, if b = 0 Recursion: gcd (a,b) = gcd (b, a%b) otherwise و A student realized that the gcd can be computed iteratively, using the property 1 [a b] [ab]] = [b_ab] The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd (a,b): while (b): ab=a bab return a If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] where M = m11 m12 Lm21 m22] [m11 m12] [m21 m22] is the result of the matrix multiplications after several iterations: m12 Lm21 m22] M = [m11 m²] = [1 a/b₁ab]-[1 1 -lak/bk]]
Lu 1-la/b]]-L 4700 The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd(a,b): while (b): [a b]=[a b][/b] return a [m11 m121 If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] [m21 m22] 212] is the result of the matrix multiplications after several iterations: [m11 m121 where M = [m21 m22] M = m11 m -- m12] Lm21 m22] = 1 1 a/b/b] 1 Since m11*N + m21*x = 1, we have m21*x % N = 1, that is, m21 is the multiplicative inverse of x modulo N. Then, the program to compute the matrix M is proposed as mul inverse (N, x | N and x are coprime): [a b] = [N_x] M = · 66 9 while (be): M = M* M*[1₁ab] [a b] = [a b][/b] return M[2,1] Prove the correctness of the program by axiomatic semantics. Problem 2. The multiplicative inverse of an integer x modulo N where x and N are coprime (mutually prime), is an integer m < N such that mx % N = 1. A function prototype is given as: Input: unsigned int x, unsigned int N, where x and N are coprime. Output: unsigned int m, where m < N and mx % N = 1. Mathematically, mx % N = 1 is equivalent to mx + kN = 1 = gcd (x, N). The problem of finding multiplicative inverse becomes an application of the gcd problem. Recall that the gcd is solved by the Euclid's algorithm: Base case: gcd (a,b) = a, if b = 0 Recursion: gcd (a,b) = gcd (b, a%b) otherwise و A student realized that the gcd can be computed iteratively, using the property 1 [a b] [ab]] = [b_ab] The loop stops when it gets to [gcd (a, b) 0]. He proposed the following program: gcd (a,b): while (b): ab=a bab return a If the inputs are the coprime N and x, the gcd() will satisfy: [10] = [N x] where M = m11 m12 Lm21 m22] [m11 m12] [m21 m22] is the result of the matrix multiplications after several iterations: m12 Lm21 m22] M = [m11 m²] = [1 a/b₁ab]-[1 1 -lak/bk]]
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter14: Numerical Methods
Section: Chapter Questions
Problem 1PP
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning