Songklanakarin Journal of Science and Technology SJST R1 KANYAMEE. Numerical methods for finding multiplicative inverses of a modulo N

Similar documents
Notes on Systems of Linear Congruences

arxiv: v2 [math.nt] 29 Jul 2017

Elementary Number Theory. Franz Luef

PAijpam.eu THE PERIOD MODULO PRODUCT OF CONSECUTIVE FIBONACCI NUMBERS

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Solving Higher-Order p-adic Polynomial Equations via Newton-Raphson Method

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

CSE 20 DISCRETE MATH. Winter

Modular Arithmetic Instructor: Marizza Bailey Name:

Basic elements of number theory

Basic elements of number theory

Applied Cryptography and Computer Security CSE 664 Spring 2018

NORTHWESTERN UNIVERSITY Tuesday, Oct 6th, 2015 ANSWERS FALL 2015 NU PUTNAM SELECTION TEST

Numerical analysis meets number theory: using rootfinding methods to calculate inverses mod p n

Math 109 HW 9 Solutions

On Newton-Raphson iteration for multiplicative inverses modulo prime powers

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

SEVENTH EDITION and EXPANDED SEVENTH EDITION

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

arxiv: v5 [cs.sc] 15 May 2018

9 Modular Exponentiation and Square-Roots

3 The fundamentals: Algorithms, the integers, and matrices

Solutions to Problem Set 3 - Fall 2008 Due Tuesday, Sep. 30 at 1:00

Partitions in the quintillions or Billions of congruences

PROBLEMS ON CONGRUENCES AND DIVISIBILITY

Extracting Hexadecimal Digits of π

IMPROVING THE CONVERGENCE ORDER AND EFFICIENCY INDEX OF QUADRATURE-BASED ITERATIVE METHODS FOR SOLVING NONLINEAR EQUATIONS

CSE 20 DISCRETE MATH. Fall

Putnam Greedy Algorithms Cody Johnson. Greedy Algorithms. May 30, 2016 Cody Johnson.

CPSC 467: Cryptography and Computer Security

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

p 1 p 0 (p 1, f(p 1 )) (p 0, f(p 0 )) The geometric construction of p 2 for the se- cant method.

arxiv: v2 [math.ho] 31 Dec 2018

Midterm Review. Igor Yanovsky (Math 151A TA)

Mathematics for Cryptography

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

4 Number Theory and Cryptography

Journal of Number Theory

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

= 1 2x. x 2 a ) 0 (mod p n ), (x 2 + 2a + a2. x a ) 2

Algebra for error control codes

Math 551 Homework Assignment 3 Page 1 of 6

Fall 2017 November 10, Written Homework 5

Integers and Division

Tewodros Amdeberhan, Dante Manna and Victor H. Moll Department of Mathematics, Tulane University New Orleans, LA 70118

Continuing discussion of CRC s, especially looking at two-bit errors

CSE525: Randomized Algorithms and Probabilistic Analysis April 2, Lecture 1

Algebra. Modular arithmetic can be handled mathematically by introducing a congruence relation on the integers described in the above example.

Finding simple roots by seventh- and eighth-order derivative-free methods

CSE 20 DISCRETE MATH. Winter

CPSC 467b: Cryptography and Computer Security

#A11 INTEGERS 12 (2012) FIBONACCI VARIATIONS OF A CONJECTURE OF POLIGNAC

Elementary Number Theory Review. Franz Luef

Computer Architecture 10. Residue Number Systems

Numbers. Çetin Kaya Koç Winter / 18

Newton-Raphson Type Methods

Numerical Study of Some Iterative Methods for Solving Nonlinear Equations

Fast evaluation of iterated multiplication of very large polynomials: An application to chinese remainder theory

198 VOLUME 46/47, NUMBER 3

CS March 17, 2009

MATH 310: Homework 7

MATH 361: NUMBER THEORY FOURTH LECTURE

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

Number theory (Chapter 4)

ECEN 5022 Cryptography

Algorithms (II) Yu Yu. Shanghai Jiaotong University

Winter Camp 2009 Number Theory Tips and Tricks

CHAPTER 3. Congruences. Congruence: definitions and properties

Relations. Binary Relation. Let A and B be sets. A (binary) relation from A to B is a subset of A B. Notation. Let R A B be a relation from A to B.

Math.3336: Discrete Mathematics. Mathematical Induction

Fermat s Little Theorem. Fermat s little theorem is a statement about primes that nearly characterizes them.

On Aperiodic Subtraction Games with Bounded Nim Sequence

10 Modular Arithmetic and Cryptography

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Homework 5. This homework is due October 6, 2014, at 12:00 noon.

Number Theory Proof Portfolio

201-1A5-MT - Mathematics Summer 2015 HOMEWORK 2 Deadline : Sunday, August 30, 2015 at 12 :30.

NUMBER SYSTEMS. Number theory is the study of the integers. We denote the set of integers by Z:

Discrete Structures Lecture Solving Congruences. mathematician of the eighteenth century). Also, the equation gggggg(aa, bb) =

Public Key Encryption

Fast Fraction-Integer Method for Computing Multiplicative Inverse

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

#A66 INTEGERS 14 (2014) SMITH NUMBERS WITH EXTRA DIGITAL FEATURES

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Elliptic Curves Spring 2015 Problem Set #2 Due: 02/20/2015

For your quiz in recitation this week, refer to these exercise generators:

SUFFIX PROPERTY OF INVERSE MOD

This exam contains 5 pages (including this cover page) and 4 questions. The total number of points is 100. Grade Table

Part II. Number Theory. Year

New Algorithm for Classical Modular Inverse

Old and new algorithms for computing Bernoulli numbers

CHAPTER 2 EXTRACTION OF THE QUADRATICS FROM REAL ALGEBRAIC POLYNOMIAL

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Summary Slides for MATH 342 June 25, 2018

4 Linear Recurrence Relations & the Fibonacci Sequence

Transcription:

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Numerical methods for finding multiplicative inverses of a modulo N Journal: Songklanakarin Journal of Science and Technology Manuscript ID SJST-0-0.R Manuscript Type: Original Article Date Submitted by the Author: -Jul-0 Complete List of Authors: Prempreesuk, Bencharat; Silpakorn University - Sanam Chandra Palace Campus, Mathematics Pongsriiam, Prapanpong ; Silpakorn University - Sanam Chandra Palace Campus, Mathematics KANYAMEE, NAIRAT; Silpakorn University - Sanam Chandra Palace Campus, Mathematics Keyword: modular multiplicative inverse, Newton s method, secant method, binary representation, Zeckendorf representation

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Numerical methods for finding multiplicative inverses of modulo Bencharat Prempreesuk, Prapanpong Pongsriiam, and Nairat Kanyamee * Department of Mathematics, Faculty of Science, Silpakorn University, Nakhon Pathom, Thailand. * Corresponding author, Email address: kanyamee_n@su.ac.th Abstract In this work, we propose new methods which are based on the root-finding methods in numerical analysis to calculate the inverses of an integer modulo for any positive integer. We apply Newton's and secant methods with a power-reduction process and Newton's and secant methods together with the binary representation and Zeckendorf representation to determine the inverse of an integer modulo. The numerical results confirm an accuracy compared to the analytical results. In addition, the two methods with the binary and Zeckendorf representations give better CPU times than Newton s and secant methods with power-reduction for large. Keyword: modular multiplicative inverse, Newton s method, secant method, binary representation, Zeckendorf representation

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0. Introduction Modular multiplicative inverse is often seen in number theory and it is desirable to be able to calculate it quickly. This motivates us to search for an efficient method in finding the modular multiplicative inverse. On the other hand, numerical analysis involves algorithms that are used in approximating the solutions to a particular problem. So, there should be some connections between the two fields of number theory and numerical analysis. Let Z and, Z. We write mod if. Assume further that,=. Then it is a well-known result (Rosen, 00) in number theory that there exists an integer such that mod. The integer is called the modular multiplicative inverse (or simply the inverse) of modulo and it is denoted by or. For example, mod, so the inverse of modulo is, that is, mod. By the fundamental theorem of arithmetic (Rosen, 00), we can write =, where,,, are distinct primes and,,, are positive integers. We can first calculate the inverse of modulo,,,, respectively, and then apply Chinese remainder theorem (Rosen, 00) to obtain the inverse of modulo. Apart from the Euclidean algorithm to calculate the inverse, some researchers have introduced an interesting application of numerical analysis to number theory. In numerical analysis, we have the classical root-finding methods such as Newton's method and secant method to find a zero of a function or to find a solution of = 0. The concept of iterative root-finding methods is to construct a sequence

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0,,, that will converge to a zero of in [,]. In 0, Knapp and Xenophontos calculated the inverses of an integer modulo using the rootfinding methods such as Newton s method, secant method, fixed-point iteration and higherorder convergent method (Knapp & Xenophontos, 0). Newton s method is suitable for calculating the inverse of an integer modulo when = for =,,, and some positive integer. The secant method is used to find the inverse of modulo, when the inverses of mod and mod are already known. The higher-order convergent method of order is suitable to calculate an inverse of modulo when = for =,,, and some positive integer. In 0, Dumas studied fast algorithms for the computation of modular inverses by using Newton-Raphson iteration (Dumas, 0). He designed four algorithms with a few operations used. He claimed that his hybrid algorithm is % faster than any direct method. In this paper, we extend the work from Knapp et al. by using Newton s and secant methods with a power-reduction calculation and Newton's and secant methods together with the binary representation and Zeckendorf representation to determine the inverse of an integer modulo for any positive integer by splitting into its prime factor form and calculate the inverse in terms of modulo. To do this, we consider into two cases. First case, we represent as the sum of distinct powers of. For the second case, we represent as the Zeckendorf representation (Griffiths, 0). Then we use the root-finding methods to calculate inverses modulo. Furthermore, we show the algorithms in MATLAB to calculate the inverse of modulo and compare the CPU times of each method.

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0. Rootfinding methods for the inverse of modulo In this section, we establish root-finding methods with a power-reduction calculation to calculate the inverse of an integer modulo. The methods are based on the root-finding methods in Knapp et al. (Knapp & Xenophontos, 0). For our problem, we are looking for an integer for which mod or mod. Following the methods in Knapp et al., a suitable choice for the function is =. The goal is to solve the equation =0.. Newton s method with a power-reduction calculation Newton s method is one of the most powerful and well-known numerical method for root-finding problems. We combine this method with a process of modular calculation to reduce power of to find the inverse mod. Newton s method relies on the continuity of,. According to (Burden & Faires, ), the iteration for Newton s method to locate a zero of is given by =, =,,, with a suitable initial value. This iteration generates a sequence { } which converges to a zero of. To apply the method, we first find =. The iteration for Newton s method becomes = =, =,,, (.) Here, we obtain the sequence { } which converges to a solution of =0.

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Theorem... Let >0 and suppose that is an inverse of modulo. Then given by (.) is an inverse of modulo. Proof. See Knapp and Xenophontos (0). Theorem.. implies that if we know the inverse of modulo, then we can use Newton s method to calculate the inverse of modulo, modulo, modulo and so on. For simplicity, we choose the initial guess to be the inverse of modulo and apply Newton s method in (.) to determine the inverse of modulo, modulo, modulo and so on. As a result, this method is suitable for calculating the inverse of an integer modulo when =, =,,,. It is known that the method converges at a quadratic rate for a simple root (Burden & Faires, ). In addition to Newton s method in Knapp et al., we construct the algorithm in order to find the inverse of an integer modulo for any integer, other than the form of. We first apply Newton s method in (.) to calculate the inverse of an integer modulo where << for some positive integer. Then, we begin to reduce the power of from down to. Since mod, it follows that mod. The reduction process applies this idea together with the congruence property to search for the smallest positive number in the same congruent class as modulo (shown in line 0 (referred to line ) in Algorithm ). By continuing this process, we finally arrive with the inverse of an integer modulo. The algorithm (Algorithm ) to determine such an inverse is shown in Table below. (Table ) Table : Algorithm for Newton s method with a power-reduction calculation

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Example : Let =,= and =. We want to calculate the inverse of modulo. We choose the initial value = since mod. Observe that <<. We apply Newton s method to find the inverse of modulo and so on until as follows: mod mod mod. After we obtain, we use the power-reduction calculation and finally get the inverse of modulo as.. The secant method with a power-reduction calculation Secant method is designed to converge almost as fast as Newton s method, but involves only not (Atkinson, ). In a similar way to Newton s method, we also combine this method with a modular calculation to reduce the power of. The iteration for secant method is given by =, =,,, The method requires two initial values and to generate a sequence { } which converges to a zero of. By setting =, the iteration for secant method is given by = = +, =,,, (.) Equation (.) provides a sequence { } which converges to a root of =0.

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Theorem... Suppose that mod and that mod. Then, with given by (.), we have mod. Proof. See Knapp and Xenophontos (0). From this theorem, we can use secant method to find the inverse of modulo if we know the inverse of modulo and modulo. We first choose and such that mod, and mod. Then, we iterate from secant method which will be the inverse of modulo, and continue the process. Since it is simpler to calculate the inverse of modulo, both initial values and for secant method are chosen to be the inverse of modulo. Then, we apply secant method to calculate which is the inverse of modulo. By continuing the process, we obtain the inverse of modulo, modulo, modulo and so on. In fact, the iterated values,, are the inverses in which the powers of are the Fibonacci numbers. This method is known to provide a convergence of order. (Atkinson, ). In addition to the secant method in Knapp et al., we construct the algorithm in order to find the inverse of an integer modulo for any positive integer, other than the form of or where is a Fibonacci number. Recall that the Fibonacci sequence is defined by the recurrence relation = + for and the initial values = =. We first apply the secant method in (.) to calculate the inverse of an integer modulo where << for some positive integer. Then, we use the reduction process (mentioned in section.) to reduce the power of from down to in order to obtain the inverse of an integer modulo. The algorithm (Algorithm ) to determine such an inverse is shown in Table. (Table )

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Table : Algorithm for the secant method with a power-reduction calculation Example : Let =,= and =. We want to calculate the inverse of modulo. We choose the initial value =, = because mod. Notice that <<. We apply the secant method to find the inverse of modulo, modulo and so on until modulo as follows: mod mod mod mod mod. Once we obtain, we use the power-reduction calculation and finally get the inverse of modulo as.. Calculating the inverse of mod and mod In this section, we use the methods in section. and section. to calculate the inverse of modulo for any positive integer. We consider into two cases. For the first case, we represent as the sum of distinct powers of. For the second case, we represent in the form of Zeckendorf representation.. Using binary representation Since we know that every positive integer can be represented as the sum of distinct powers of (Rosen, 00), we first express in a binary system. If is a positive integer and the digit,,, exist, the binary expansion of is given by (Mathew, ) = + + + +,

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 where each digit is either a 0 or. This can also be written in a binary notation as =. Therefore = (.) or =. (.) The form in (.) consists of a prime number with the power of. We can apply Newton s method in Algorithm to calculate the inverse of an integer modulo for each in which in (.) is not zero. The secant method in Theorem.. and Algorithm are then applied to determine the inverse of each pair of modulo until the largest power term. The algorithm (Algorithm ) to calculate the inverse using the binary representation is presented in Table. (Table ) Table : Algorithm for calculating the inverse using binary representation Example : Let =,= and =. We want to calculate the inverse of modulo. We choose the initial value =, since mod. The binary representation of in this problem is == +=. Observe that the representation contains the terms and. We apply Newton s method and Theorem... to find the inverses of modulo, as follows: mod or mod mod or mod mod or mod.

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Using the secant method and Theorem... with and as the initial conditions to calculate the inverse of modulo yields = mod Therefore, is the inverse of modulo.. Using the Zeckendorf representation In view of the fact that any positive integer can be expressed as the sum of Fibonacci numbers (Rosen, 00). In this section, we represent the integer in the form of the Zeckendorf representation. Theorem... (Zeckendorf s Theorem (Rosen, 00; Griffiths, 0)) Every positive integer can be represented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers. More precisely, if is any positive integer, there exist positive integers, with > + for every {0,,,,} such that = where is the Fibonacci number. Such a sum is called the Zeckendorf representation of. In fact, the greedy algorithm always leads to Zeckendorf representation. Proof. See Rosen (00) and Griffiths (0). Example : Consider the number =. There are several ways to express this number as a sum of Fibonacci numbers. Notice that =+++= + + + and =+++= + + + are not Zeckendorf representations because,, and, are consecutive Fibonacci numbers.

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 However, =++= + + is a Zeckendorf representation which is uniquely determined. From the greedy algorithm and Zeckendorf s theorem, we can construct an algorithm to write in form of the Zeckendorf representation. We first construct a Fibonacci sequence starting from and contains numbers closest to. The binary search algorithm is applied to find the largest Fibonacci numbers,, that is less than or equal to. Then repeat the process to find the largest Fibonacci numbers,, that is less than or equal to. By continuing this process, we arrive with the Zeckendorf representation = + + + for some N. Algorithm in Table provides the process of finding such a representation. (Table ) Table : Algorithm for representing with the Zeckendorf representation Once we have the Zeckendorf representation from Algorithm. The secant method in section. is applied to find the inverse of an integer modulo for each Fibonacci number in Algorithm. Then, we apply the secant method again to find the inverse of an integer modulo. The algorithm (Algorithm ) that includes the secant method to find the inverse of an integer modulo is shown in Table. (Table ) Table : Algorithm for calculating the inverse using Zeckendorf representation Example : Let =,= and =. We want to calculate the inverse of modulo. We choose the initial value = and = because mod. We have that =++. Then, we use the secant method and Theorem... to

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 find the inverses of modulo, where is a Fibonacci number less than or equal as follows: mod mod mod mod. Next, we apply the secant method and Theorem... again to find the inverse of modulo and modulo. This yields the inverse = mod. Therefore, is the inverse of modulo. In the next example, we compare the CPU times of each method used to find the inverse of modulo by using MATLAB. The calculations are carried out with an Intel Core i CPU@ GHz RAM GB computer. The results are represented in Example. Example : Let =, =. We choose the initial value = and =, since mod. The CPU times are recorded in seconds. (Table ) Table : CPU times in finding the inverse of modulo of the four methods. From the Table, Newton s method is the fastest method to calculate the inverses when is the power of and is not too large due to less number of operations to execute than the other methods. In this example, we can see that when = and, Newton s method gives the smallest time to calculate the results. If we consider the secant method, it has the best time when is a Fibonacci number and not too large. We can see that this method gives us the smallest time to find the inverses

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 when =, and. The binary and Zeckendorf representation methods can calculate the inverses for every and the CPU time is increased a bit at a time when is larger. These last two methods are the best way to calculate the inverses of modulo, especially when is not in a power of or a Fibonacci number or when is large. The figures below also confirm our discussion above. Figure (a) shows the graphs of the CPU times for the four methods versus when =,,,0. The CPU time in the graph of Newton s method drops when =,,,, and it jumps up due to the power-reduction process. For example, the method uses low CPU time when =, but it takes much longer time when = since it first calculates the inverse of modulo then it reduces the power down to =. Similarly, the CPU time in the graph of the secant method drops when =,,,,, and it jumps up in a similar manner. If we consider the graphs of the CPU times for the binary and Zeckendorf representation methods, the graphs are quite stable and do not increase much. It takes less CPU times than the first two methods as increases. Figure (b) illustrates the behavior of CPU times of these methods when =,,,0. We can see from the graphs that the times taken do not rise up when gets larger. They are time efficient and very stable to calculate the inverse of modulo for any number. (Figure (a)) (Figure (b)) (a) (b) Figure : (a) The graphs of CPU times of the four methods versus when =,,,0. (b) The graphs of CPU times of the binary and Zeckendorf representations versus when =,,,0.

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 We end the section with an example to calculate the inverse of an integer modulo where =. Example : Let = and =0. The prime factorization of is =. We would like to find an integer such that mod. We break it down into finding mod, mod, mod. By using our algorithms, we can find the inverses of each case as mod, mod, mod. Then we combine them by using the Chinese remainder theorem. Let =, =, =, =, =, =. From the Chinese remainder theorem (Rosen, 00), we define = = = = = = = = = = = =. To determine the inverse of, denoted by, we solve mod, which is equivalent to mod. So mod. Next, we find the inverse of, denoted by, by solving mod, which is equivalent

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 to mod. So mod. The inverse of, denoted by, is calculated by solving mod, or equivalently, mod. Then 0 mod. Therefore, according to the Chinese remainder theorem, the inverse of modulo 0 is + + mod ++0 mod mod mod.. Conclusion and Discussion This work introduces new methods to calculate inverses modulo for any positive integer. We express in its prime factorization as =, where,,, are distinct prime numbers and,,, are positive integers. Then, we calculate the inverse by breaking it down to find the inverse of mod, mod,, and mod and combine them using the Chinese remainder theorem. The four methods proposed to calculate the inverse of mod are designed based on the Newton's and secant methods. We also construct the algorithms for each method to help calculating the inverses of modulo based on the MATLAB program and present them in the example of each method. In addition, we compare the CPU times of each method in Example. Newton s method with a power-reduction calculation is good for the case when = for =,,,. The secant method with a power-reduction calculation is used to find the inverse of modulo when the inverses of mod and

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page 0 of 0 0 0 0 0 mod are already obtained. In fact, it is good for the case when is a Fibonacci number. However, these two methods may take time when is not in such a form because of the power-reduction process. The method that expresses as a binary representation followed by Newton s and secant methods is suitable for any numbers because every number can be represented in base. The method does not include power-reduction calculation. As a result, it is time efficient and very stable to calculate the inverse for any number, especially when is large or is not in a power of or a Fibonacci number. Similarly, the method that expresses as a Zeckendorf representation followed by the secant method is suitable for any numbers because every number has its Zeckendorf representation. This method is also as good as the method that expresses in a binary representation. Acknowledgement We would like to thank Dr. Pinyo Taeprasartsit for his helpful suggestions in programming throughout this work. References Atkinson, K. E. (). An Introduction To Numerical Analysis ( nd ed). USA: John Wiley&Sons. Burden, R. L.,& Faires, J. D. (). Numerical Analysis. Pacific Grove, USA: Brooks/Cole. Dumas, J. G. (0). On Newton-Raphson Iteration for Multiplicative Inverses Modulo Prime Powers. IEEE Transations on Computers, (), 0-. doi:./tc.0.

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Griffiths, M. (0). The Zeckendorf Representation of a Beatty-Related Finonacci Sum. Fibonacci Quart. (), 0-. MSC0: B, B. Knapp, M. P.& Xenophontos, C. (0). Numerical analysis meets number theory: Using rootfinding methods to calculate inverses mod. Appl. Anal. Discrete Math. (), -. doi:./aadm00k Mathew, J. H. (). Numerical Methods For Mathematics, Science, And Engineering. New Jersey, USA: Prentice-Hall. Rosen, K. H. (00). Elementary Number Theory And Its Application. USA: Addison- Wesley.

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 SJST MANUSCRIPT TEMPLATE FOR A FIGURE FILE Figure (a) Figure (b) Figure : (a) The graphs of CPU times of the four methods versus when,,,0. (b) The graphs of CPU times of the binary and Zeckendorf representations versus when,,,0.

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 SJST MANUSCRIPT TEMPLATE FOR A TABLE FILE Algorithm : Newton s method with a power-reduction calculation : Input:,, Z ; N ; intitial value (inverse of mod ); : for k = to M : compute : = ( ); = ; : if <0 : set =; = + ; : while <0 : =+; = +( ) ; : end ; display : else if >0 and < : display ; stop the process : else if >0 and > : set =; = ; : while > : =+; = ( ) ; : end ; display : end : if = : stop the process : else if > 0: repeat line - by replacing with : end : end Table : Algorithm for Newton s method with a power-reduction calculation

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Algorithm : The secant method with a power-reduction calculation : Input:,, Z ; N ; intitial value, (inverse of mod ); : =; =; : for k = to M : compute : = + ; = + ;= ; : if <0 : set =; = + ; : while <0 : =+; = +( ) ; : end ; display : else if >0 and < : display ; stop the process : else if >0 and > : set =; = ; : while > : =+; = ( ) ; : end ; display : end : if = : stop the process 0: else if > : repeat line - by replacing with : end : end Table : Algorithm for the secant method with a power-reduction calculation

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Algorithm : Inverse of mod using binary representation : Input:,, Z ; N ; intitial value (inverse of mod ); : = vector representing n in base two ; =size of ; : = vector containing indices of nonzero elements in ; =size of ; : Apply Algorithm from line - : Input:,, Z ; N ; intitial value (inverse of mod ) : Output: : if = : display () ; stop the process : else for = to : =( ) ; : end : = ( ) + ( ) ; : Apply Algorithm from line - : Input:,, Z ; N ; intitial value, ; : Output: : for = to : = + ( ) ; : Apply Algorithm from line - : Input:,, Z ; N ; intitial value, ; 0: end : display () ; stop the process : end Table : Algorithm for calculating the inverse using binary representation

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Algorithm : Representing with the Zeckendorf representation : Input: N ; : set = ; = ;=;= ; : while : = + ; = ; =+ ; (constructing Fibonacci sequence) : end : while 0 : Find =, the closet value to the number, using binary search algorithm : Input:, : Output: and (index of value in ) : if > : = ; =, ; =, ; : else : = ; =, ; =,; : end : = ; : end : = flip left/right of ; = flip left/right of ; display and (Return, the Zeckendorf representation of and corresponding indices ) Table : Algorithm for representing with the Zeckendorf representation

Page of Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE 0 0 0 0 0 Algorithm : Inverse of mod using Zeckendorf representation : Input:, Z ;, N ; intitial value (inverse of mod ) : Apply Algorithm : Input : : Output :,, : Find the closet value to (),, and its index,, using binary search algorithm : Input:,() : Output :, : Apply Algorithm from line -, Change in line to (inv of mod,,, ) : Input:,,() Z ;, N ; intitial value, ; : Output: : = : : if length of = : display () : else = + ; : Apply Algorithm from line - : Input:,, Z ; N ; intitial value, ; : Output: : for = to (length of ) : = + ; 0: Apply Algorithm from line - : Input:,, Z ; N ; intitial value, ; : Output: : end : display () : end Table : Algorithm for calculating the inverse using Zeckendorf representation

Songklanakarin Journal of Science and Technology SJST-0-0.R KANYAMEE Page of 0 0 0 0 0 Methods Newton Secant Base Zeckendorf (mod ) 0.00 0.00 0.0 0.0 (mod ) 0.00. 0.0 0.0 (mod ) 0.00 0.00000 0.0 0.0 (mod ) 0.00 0.00 0.0 0.0 (mod ) >00 0.00 0.0 0.0 (mod )..00 0.0 0.0 (mod ).0 >00 0.0 0.0 (mod ) 0. >00 0.0 0.00 Table : CPU times in finding the inverse of modulo of the four methods.