Representation of an Integer by a Quadratic Form through the Cornacchia Algorithm

Abstract

Cornachia’s algorithm can be adapted to the case of the equation x 2 +d y 2 =n and even to the case of a x 2 +bxy+c y 2 =n . For the sake of completeness, we have given modalities without proofs (the proof in the case of the equation x 2 + y 2 =n ). Starting from a quadratic form with two variables f( x,y )=a x 2 +bxy+c y 2 and n an integer. We have shown that a primitive positive solution ( u,v ) of the equation f( x,y )=n is admissible if it is obtained in the following way: we take α modulo n such that f( α,1 )0modn , u is the first of the remainders of Euclid’s algorithm associated with n and α that is less than 4cn/ | D | ) (possibly α itself) and the equation f( x,y )=n . has an integer solution u in y. At the end of our work, it also appears that the Cornacchia algorithm is good for the form n=a x 2 +bxy+c y 2 if all the primitive positive integer solutions of the equation f( x,y )=n are admissible, i.e. computable by the algorithmic process.

Share and Cite:

Woba, M. (2024) Representation of an Integer by a Quadratic Form through the Cornacchia Algorithm. Applied Mathematics, 15, 614-629. doi: 10.4236/am.2024.159037.

1. Introduction

Quadratic forms are used in many fields of mathematics: different results for the classification of conics and then generally quadratics, search for local minimum or maximum of a function of several variables from a limited expansion, introduction of surface curvature, principal component analysis in statistics. Integer quadratic forms are used in number theory and topology [1].

Let p be an odd prime. −1 is a square modulo p if and only if p1mod4 . Thus, if p is a prime number that can be written as the sum of two squares (of integers), it is congruent to 1 mod 4: indeed, if p= x 2 + y 2 , x and y are necessarily prime to p and we have ( x/y ) 2 1modp . The converse is true, which we will demonstrate by giving algorithms that compute integers x. and y such that x 2 + y 2 =p [2].

In mathematics, the Cornacchia algorithm is a procedure for solving certain Diophantine equations generalizing the Pell-Fermat equation. This algorithm is named after the Italian mathematician Giuseppe Cornacchia who introduced it in 1908 and sometimes also attributed to the Vilandic mathematician Henry Smith, under the name of the Cornacchia-Smith algorithm [3].

More specifically, the algorithm provides a solution between ( x,y ) of the equation x 2 +d y 2 =m , where 1dm , and the integers d and m are prime to each other. This algorithm is of major practical interest, because it makes it possible to find a representation of a first P as the norm of an element of a quadratic extension, an essential step for example in the proof of primality by elliptic curves [4].

Another important use of the Cornacchia algorithm is the generation of elliptic curves with complex multiplication [5].

For this task, the Cornacchia algorithm is more efficient than generic methods based on quadratic forms or Euclidean lattice reduction to [François Morain “Implementing the asymptotically fast version of thé elliptie curve primalty proving algorithme”].

We will then look at the more general problem of “representing” a prime number by a two-variable quadratic form. Before we start, let’s notice that our problem is not empty, there are prime numbers ≡1 mod 4. There are even an infinity of them because if n is an integer, a prime factor of n ! 2 +1 (which exists!) is necessarily greater than n and congruent to 1 mod 4; So there is an arbitrarily large prime number ≡1 mod 4.

2. Writing a Prime Number ≡ 1 Mod 4 as the Sum of Two Squares

Let’s fix a prime number p ≡ 1 mod 4. Let us give a first algorithm for finding integers x and y such that

x 2 + y 2 =p (1)

We start from an integer a such that a 2 +1=mp with m a positive integer that we can assume < p (for example by taking a ( p1 )/2 , we even then have m ( p1 )/4 . Let us suppose m1 . Let x 0 =a and y 0 =1 . Let x1 and y1 represent them of minimum x0 and y0 modulo m in absolute value. As x 1 2 + y 1 2 0modm , we write x 1 2 + y 1 2 =m m with m m/2 , hence

( x 0 2 + y 0 2 )( x 1 2 + y 1 2 )= m m 2 p. (2)

We check using | z 0 z 1 |=| z 0 || z 1 | remarkable identity

( x 0 2 + y 0 2 )( x 1 2 + y 1 2 )= ( x 0 x 1 + y 0 y 1 ) 2 + ( x 0 y 1 x 1 y 0 ) 2 .

The terms of the right-hand side checking

x 0 x 1 + y 0 y 1 x 0 2 + y 0 2 0modm.

x 0 y 1 x 1 y 0 0modm (3)

So if x 2 = ( x 0 x 1 + y 0 y 1 )/m and if y 2 = ( x 0 y 1 x 1 y 0 )/m , we have a x 1 2 + y 1 2 = m p with m m/2 . All that remains is to start again by replacing m by m’ and x 0 , y 0 by x 2 , y 2 . We have obtained a solution of the equation x 2 + y 2 =p if we obtain the value m=1 . Let’s check it out. Since the m (and m’) form a strictly decreasing sequence of positive integers, we necessarily obtain m =1 or m =0 .

Let us show that if m =0 , m is necessarily equal to 1. Indeed, this implies with the previous notations in the corresponding step that x0 and y0 are both divisible by m and therefore since x 0 2 + y 0 2 =mp , the integer m must divide p. If p is prime, this implies that m=1 [6].

We have thus obtained an integer solution of the equation x 0 2 + y 0 2 =p . (We will call this algorithm descending algorithm in the following, it closely follows Euler’s proof which is based on Fermat’s principle of making “descend” in positive integers). The number of steps is increased by log 2 ( m ) .

3. Representation of a Prime Number by a Quadratic Form with Two Variables

3.1. Definition 1

If f( x,y ) is a quadratic form with integer coefficients, f is said to represent p if there are integers x and y such that f( x,y )=p . All that remains is to persuade yourself that you have verified the following theorem for a prime number p<1000 and different from 2 and 5.

3.2. Theorem 1

−5 is a square modulo p if and only if p is represented by x 2 +5 y 2 or by 2 x 2 +2xy+3 y 2 . The proof of this fact for any prime number, already stated by Fermat, goes back to Euler. There are two parts to the proof: the first part uses Legendres quadratic law of reciprocity: if p and q are two distinct odd primes, ( p q )( q p )= ( 1 ) ( p1 ) ( q1 )/4 .

3.3. Example 1

( 5 p )=( 1 p )( 5 p )= ( 1 ) ( p1 )/2 ( 5 p )

In the following, a form will be a quadratic form a x 2 +bxy+c y 2 with a, b, and c integers prime to each other, a>0 .

3.4. Definition 2

We say that a form f properly represents an integer m if there are integers u and v prime to each other such that f( u,v )=m . Such a solution ( u,v ) is then said to be primitive.

3.5. Definition 3

Two forms f( x,y ) and g( x,y ) are said to be equivalent (or properly equivalent) if there are integers u,v,w and t such that f( x,y )=g( ux+vy,wx+ty ) and utvw=±1 ( resp. utvw=1 ). These are equivalence relationships.

3.6. Lemma 1

A form f( x,y ) properly represents an integer m if and only if f( x,y ) is properly equivalent to a form of the type m x 2 +bxy+c y 2 for b and c suitable. Indeed, suppose that there are you and v prime to each other such that f( x,y )=m . By Bézout’s theorem, there exists w and t such that uwvt=1 and f ( ux+ty,vx+wy ) is of the form m x 2 +axy+c y 2 . The reverse is clear.

3.7. Definition 4

We call the discriminant of the form a x 2 +bxy+c y 2 the integer D= b 2 4ac [7].

3.8. Remark 1

  • Two equivalent forms have even discriminating.

  • D is congruent to b2 modulo 4 and therefore D is congruent to 0 or 1 modulo 4.

3.9. Lemma 2

Let D be an integer ≡ 0 or 1 mod 4 and m an odd integer prime to D. Then there is a form of discriminant D properly representing m if and only if D is a square modulo m.

Indeed, if there is a form properly representing m, we can take it of the type f( x,y )=m x 2 +bxy+c y 2 . Its discriminant = b 2 4mc is indeed a square modulo m.

Conversely, suppose that D is a square modulo m: D b 2 modm with b Its discriminant D= b 2 4mc is indeed a square modulo m: D b 2 modm with b . Since m is odd, we can take b and D of the same parity (even if it means changing b to b + m). Like D0 or 1 mod 4, we then have D b 2 mod4m .

Let c be the integer such that D= b 2 4mc . Then, m x 2 +bxy+c y 2 properly represents m and the integers a=m,b and c are prime to each other because m is prime with D. We deduce the result of the following corollary: [8].

3.10. Corollary 1

Let n be an integer and p an odd prime that does not divide n. Then p is represented by a form of discriminant-4m if and only if ( n p )=1 .

Let’s go back to the forms x 2  +5 y 2 and 2 x 2 +2xy+3 y 2 of discriminant-20. To show the following theorem, all that remains is to show that the forms of discriminant-20 are all properly equivalent to one of the two forms x 2 +5 y 2 and 2 x 2 +2xy+3 y 2 .

3.11. Theorem 2

−5 is a square modulo p if and only if p is represented by par x 2 +5 y 2 or by 2 x 2 +2xy+3 y 2 .

3.12. Theorem 3

An odd prime p prime to 5 is represented by x 2 +5 y 2 si and only if p1 or 9 mod 20, it is represented by 2 x 2 +2xy+3 y 2 if and only if p3 or 7 mod 20.

Let’s go back to the shape equivalence classes.

3.13. Definition 5

A form a x 2 +bxy+c y 2 of a negative discriminant is said to be reduced if | b |ac and b0 in cases where | b |=a or a=c . There is only a finite number of reduced forms of the discriminant D<0 given (we have indeed D=4ac b 2 4 a 2 a 2 =3 a 2 and therefore a D 3 , there is a finite number of a and b and therefore of c since b 2 4ac=D ).

3.14. Theorem 3

Any form of negative discriminant is properly equivalent to a single reduced form. Thus, the set of equivalence classes C(D) (for proper equivalence) of the given discriminant forms is finite [9].

The cardinal h(D) of C(D) is called the number of classes of discriminant D.

4. A Look Back at the Algorithms

Cornachia’s algorithm can be adapted to the case of the equation x 2 +d y 2 =n and even to the case of a x 2 +bxy+c y 2 =n .

Let f( x,y )=a x 2 +bxy+c y 2 be a form and n an integer. We say that a primitive positive solution ( u,v ) of the equation f( x,y )=n is admissible if it is obtained in the following way: we take α modulo n such that f ( α,1 )0modn , u is the first of the remainders of Euclid’s algorithm associated with n and α that is less than 4cn/ | D | ) (possibly α itself) and the equation f( x,y )=n has an integer solution v in y [10].

We will say that Cornacchia’s algorithm is good for the form n=a x 2 +bxy+c y 2 if all the primitive positive integer solutions of the equation f( x,y )=n are admissible, i.e. computable by the algorithmic process we have just described.

Theorem 4

The Cornacchia algorithm is good in the following cases:

1) n= x 2 +d y 2 with d and n positive integers;

2) n=a x 2 +bxy+c y 2 and a>0 , c>0 , D= b 2 4ac<0 , | D |>16 et | b | | D |16 8 and n integer ≥ 2sup(a, c).

So, Cornacchia’s algorithm is good for f and n and if you can’t find any qualifying pairs, The equation n=f( x,y ) has no integer solutions.

5. Proof of the Cornacchia Algorithm in the Case of the Equation x 2 + y 2 =a

5.1. Theorem 5

Let a be an integer such as −1 or a square mod a. If b is an integer verifying 0ba/2 et b 2 1moda , the first two remainder < a in the algorithm of Euclidean division of a by b give a primitive solution of the equation x 2 + y 2 =a . Moreover, all primitive solutions are obtained in this way. A trivial transformation is one of the transformations ( x,y )( ±x;±y ) ou ( x,y )( ±y;±x ) . A primitive solution of the equation is a solution ( x,y ) with x and y primes between them [11].

5.2. Some Polynomials Associated with Euclid’s Algorithm

Consider the sequence of equations

{ r 0 = q 1 r 1 + r 2 r i1 = q i r i + r i+1 r n1 = q n r n + r n+1 (4)

It is easy to see that by substitution, we can write

r 0 = f n ( q 1 ,, q n ) r n + g n1 ( q 1 ,, q n1 ) r n+1 (5)

where the f m and g m are polynomials in q 1 ,, q n of partial degree 1 in relation to each of the q i .

Relationships

r 0 = f n1 ( q 1 ,, q n1 ) r n1 + g n2 ( q 1 ,, q n1 ) r n

r n1 = q n r n + r n+1  

Implies that:

r 0 =( f n1 ( q 1 ,, q n1 ) q n + g n2 ( q 1 ,, q n1 ) ) r n + f n1 ( q 1 ,, q n1 ) r n+1 (6)

We deduce that g n1 = f n1 and therefore that

r 0 = f n ( q 1 ,, q n ) r n + f n1 ( q 1 ,, q n1 ) r n+1 (7)

The polynomial f n has the property

f n ( q 1 ,, q n )= f n ( q n ,, q 1 )

Indeed, we have

( r i1 r i )=( q i 1 1 0 )( r i r i+1 )

Thus, f n ( q 1 ,, q n ) is the coefficient at the top left of the matrix

( q i 1 1 0 )( q n 1 1 0 )

This coefficient is also that of its transpose (in the same place) which is equal to ( q n 1 1 0 )( q i 1 1 0 ) and is f n ( q 1 ,, q n ) . We can explicitly compute f 1 ,, f 7 with MAPLE using the recurrence relation: f n =  f n1 q n + f n2 . We find

{ f 1 = q 1 f 2 = q 2 q 1 +1 f 3 = q 3 q 2 q 1 + q 3 + q 1 f 4 = q 4 q 3 q 2 q 1 + q 4 q 3 + q 4 q 1 + q 2 q 1 +1 f 5 = q 5 q 4 q 3 q 2 q 1 + q 5 q 4 q 3 + q 5 q 4 q 1 + q 5 q 2 q 1 + q 3 q 2 q 1 + q 5 + q 3 + q 1 f 6 = q 6 q 5 q 4 q 3 q 2 q 1 + q 6 q 5 q 4 q 3 + q 6 q 5 q 4 q 1 + q 6 q 5 q 2 q 1 + q 6 q 3 q 2 q 1 + q 4 q 3 q 2 q 1 + q 6 q 5 + q 6 q 3 + q 6 q 1 + q 4 q 3 + q 4 q 1 + q 2 q 1 +1 f 7 = q 7 q 6 q 5 q 4 q 3 q 2 q 1 + q 7 q 6 q 5 q 4 q 3 + q 7 q 6 q 5 q 4 q 1 + q 7 q 6 q 5 q 2 q 1 + q 7 q 6 q 3 q 2 q 1 + q 7 q 4 q 3 q 2 q 1 + q 5 q 4 q 3 q 2 q 1 + q 7 q 6 q 5 + q 7 q 6 q 3 + q 7 q 6 q 1 + q 7 q 4 q 3 + q 7 q 4 q 1 + q 7 q 2 q 1 + q 5 q 4 q 3 + q 5 q 4 q 1 + q 5 q 2 q 1 + q 3 q 2 q 1 + q 7 + q 5 + q 5 + q 1 [12]

It will be noted that the monomials involved in f n are exactly those obtained by removing from q 1 ,, q n a certain number of successive pairs of elements ( q i ,, q i+1 ) .

If 1<m<n , we have

r m = f nm ( q m+1 ,, q n ) r n + f nm1 ( q m+1 ,, q n1 ) r n+1

r m+1 = f nm1 ( q m+2 ,, q n ) r n + f nm2 ( q m+2 ,, q n1 ) r n+1 (8)

r 0 = f m ( q 1 ,, q m ) r m + f m1 ( q 1 ,, q m1 ) r m+1

It is easy to deduce that:

f n ( q 1 ,, q n ) = f m ( q 1 ,, q m ) f nm ( q m+1 ,, q n )+ f m1 ( q 1 ,, q m1 ) f nm1 ( q m+2 ,, q n ) (9)

Particular case

Suppose that n is even and that ( q 1 ,, q n )=( q n ,, q 1 ) , that is, that is, q i = q n+1i .

For m= n 2 , the equation becomes:

f n ( q 1 ,, q n ) = f n 2 ( q 1 ,, q n 2 ) f n 2 ( q n 2  +1 ,, q n )+ f n 2 1 ( q 1 ,, q n 2 1 ) f n 2 1 ( q n 2 +2 ,, q n )

f n ( q 1 ,, q n )= f n 2 ( q 1 ,, q n 2 ) 2 + f n 2 1 ( q 1 ,, q n 2 1 ) 2 = f n 2 ( q n ,, q n 2 +2 ) 2

Either f n ( q 1 ,, q n )= f n 2 ( q n 2  +1 ,, q n ) 2 + f n 2 1 ( q n 2 +2 ,, q n ) 2

5.3. Properties of Euclid’s Algorithm

Let a and b now be two positive integers prime to each other with b<a . The sequence of the quotients associated with ( a,b ) is the sequence of successive quotients obtained by applying Euclid’s algorithm to a and b: we set r 0 =a , r 1 =b and then we define by recurrence

q i =[ r i1 / r i ]et r i+1 = r i1 q i r i (10)

We denote n the integer such that r n =pgcd( a,b )=1 and we call it the length of the algorithm. So we have r i1 =0 .

We define another sequence of integers t i by:

t 0 =0, t 1 =1et t i+1 = t i1 q i t i byi=1,,n+1

We then have the ties:

r i = s i a+ t i b

If s i is the sequence defined by the same recurrence relation and first terms 1 and 0. By recurrence, it is easy to see that the t i are of alternating sign, more precisely | t i |= ( 1 ) i1 t i .

Hence the relationship

| t i+1 |=| t i1 |+ q i | t i | (11)

The rest of the | t i | is therefore increasing. Thus, we can see the | t i+1i | as the sequence of successive remainders in Euclid’s algorithm applied to | t i+1 | and | t i | . Since r i+1 =0 and a and b are prime to each other, for i=n+1 indicates that a divides r n+1 =0 . We actually have | t n+1 |=a because | t n+i |= f n ( q n ,, q 1 )= f n ( q 1 ,, q n )=a What can we say now about | t n | ? we have t n <a et b t n 1moda .

5.4. Theorem 6

Let a and b be two integers with b<a/2 . The sequence of successive quotients in Euclid’s algorithm (of length n) starting with a and b is symmetric if and only if b 2 ±1moda and we then have b 2 ( 1 ) n+1 moda [13].

Let’s prove the lemma. We have just seen that the sequence of | t i | is increasing, that the t i are of alternating sign, with t n of the sign of ( 1 ) n+1 , and that | t i+1 |=a .

Suppose b 2 εmoda with ε=±1 .

Show that | t n |=εb . We notice that t n b1moda . Like b 2 εmoda , we deduce that t n εbmoda . Moreover, | t n |<| t n+1 |=a , therefore | t n |=εb where | t n |=ε( ba ) .

Suppose t n =ε( ba ) . Wich means | t n |=ab . The euclidian division of | t n+i |=a par | t n |=ab gives

| t n+i |=| t n |+b

Since b<ab . So | t n+i |=b and we have

a=( ab )+| t ni |

ab= q n1 b+| t n2 |

b= q n2 | t n2 |+| t n3 |

From where

a=( q n1 +1 )b+| t n2 |

b= q n2 | t n2 |+| t n3 |

Euclid’s algorithm of a by b would be of length n1 . Contradiction, so t n =εb . It is then clear that the sequences ( q 1 ,, q n ) and ( q n ,, q 1 ) are equa. In addition, we have ε= ( 1 ) n+1 . Let us now suppose the sequences ( q 1 ,, q n ) and ( q n ,, q 1 ) equal. So we have | t n+1 |=a and t n = ( 1 ) n+1 b . We also always have t n b1moda which implies that b 2 ( 1 ) n+1 moda and ends the proof of the lemma. Let’s use the above to prove the theorem. A necessary condition for a primitive solution of the equation x 2 + y 2 =a to exist is that 4 does not divide a and that all odd primes dividing a are congruent to 1 mod 4 (this is a condition for −1 to be a square mod a). We now assume so. There is then an integer b< a 2 such that b 2 1moda ; Let’s choose one.

By applying

f n ( q 1 ,, q n )= f n 2 ( q n 2 +1 ,, q n ) 2 + f n 2 1 ( q n 2 +2 ,, q n ) 2 and by denoting r i the successive remainders as before, we obtain that the roots r n 2 and r n 2 +1 check

a= r n 2 2 + r n 2 +1 2

Although of course 0 r n 2 a .

Let us show that r n 2 is the first remainder less than a . Let us first note that for any integer i, we have

r i 2 + r n+1i 2 0moda

Indeed, as t i b r i moda and b 2 1moda , by squaring, t i 2 + r i 2 moda ; since t i = r n+1i , the congruence can be deduced from this. Suppose that there exists m< n 2 such that r m a . Then, r n+1m 2 a and we necessarily have r m 2 + r n+1m 2 =a . On the other hand, r m / r n+1m 2 bmoda r n 2 / r n 2 +1 . All that remains is to show that with the nearest transformation by ( x,y )( ±x,±y ) and ( x,y )( ±y,±x ) , there is only one solution ( x,y ) to the equation x 2 + y 2 =a of quotient x/y mod has given, which will imply that r m = r n 2 1 and therefore m= n 2 1 . To do this, let’s take two pairs ( x,y ) and ( x , y ) with x<y , x < y et x/y x / y moda . So we have the equations x 2 + y 2 =a , x 2 + y 2 =a and x y x y=ar , for r an integer. Let us eliminate x in the second equation. We easily obtain the equation y 2 2rx y +a r 2 y 2 =0 whose discriminant must be positive (and even a square in ); it is ( 1 r 2 ) β 2 . We therefore necessarily have r=0 , or r =±1 . For r=0 , we get y 2 = y 2 , for r =±1 , we get y ±x=0 , which proves our assertion. In conclusion, we have shown that the different choices of b verifying 0<b<a/2 and b 2 1moda give the different primitive solutions of the equation x 2 + y 2 =a , with the nearest transformation by ( x,y )( ±x,±y ) and ( x,y )( ±y,±x ) , in the following way: the solution is given by the first pair of remainders less than a in Euclid’s algorithm of a by such a b. For an odd divisible only by prime numbers congruent to à 1 mod 4, we find 4 2 λ solutions, where λ is the number of prime factors in the decomposition of n (if p is odd, −1 is a square in / p S   if and only if p1mod4 and then there are exactly two solutions; then use the Chinese remainder theorem).

6. What Is the Motivation for Adapting the Cornacchia Algorithm to More Complex Cases?

The adaptation of the Cornacchia algorithm for complex cases allows to gain in efficiency and speed during the calculations involved in various fields of Cryptography, which makes it an interesting tool to strengthen the security and performance of Cryptographic systems.

Examples 2

  • Increased efficiency: The Cornacchia algorithm offers a more efficient approach than traditional methods to solving some complex problems related to number theory, such as calculating square roots modulo a composite number. This results in reduced computation times.

  • Public Key Cryptography: This algorithm has its application in Public Key Cryptography schemes, such as RSA encryption and discrete logarithm-based digital signatures. Its use makes it possible to speed up these operations.

  • Primality verification: it can be used to effectively test the primality of certain numbers, which is essential in many cryptographic protocols that rely on the use of prime numbers.

  • Integer factorization: To ensure that factorization itself remains a complex computational challenge, the Cornacchia algorithm can help improve some factorization techniques, such as the known fraction method.

6.1. Some Examples of Applications of Cornacchia’s Algorithm for Specific Quadratic Forms

  • Quadratic form x 2 + y 2 : The cornacchia algorithm can be used to find integers x and y that satisfy Fermat’s equation x 2 + y 2 = z 2 where z is an integer. This algorithm has been used to solve some such Fermat equations, such as x 2 + y 2 =61 .

  • Quadratic form a x 2 +b y 2 : Cornacchia’s algorithm can be adapted to solve equations of the form a x 2 +b y 2 =c where a, b, and c are integers. For example: p find solutions to the equation: 3 x 2 +5 y 2 =17 , we can use a modified version of Cornacchia’s algorithm.

  • Ternary binary quadrancy forms: The Cornacchia algorithm can also be used to solve equations of the form a x 2 +b y 2 +c y 2 =d where a, b, and c are integers. For example: we can use it to find solutions to the equation 2 x 2 +xy+3 y 2 =13 .

  • Quadratic forms with Gaussian coefficients: The Cornacchia algorithm can be extended to quadratic forms defined on the ring of Gaussian integers, of the form ( a+b ) 2 , where a and b are integers. This solves equations like ( 3+2i ) x 2 +( 1i ) y 2 =( 5+3i ) .

In any case, Cornacchia’s algorithm provides a systematic way to find integer solutions to quadratic equations, exploiting the particular properties of each quadratic form. It is a very powerful tool in number theory. In any case, Cornacchia’s algorithm provides a systematic way to find integer solutions to quadratic equations, exploiting the particular properties of each quadratic form. It is a very powerful tool in number theory.

6.2. Let’s Discuss the Computational Complexity of the Cornacchia Algorithm

The Cornacchia algorithm is an efficient method for solving the Pell-Fermat equation, which has the following form: x 2 d y 2 =1 where D is a positive non-square integer. The computational complexity of the adapted Cornacchia algorithm depends mainly on two factors:

1) The size of the numbers involved in the calculation:

  • The larger the numbers, the more time arithmetic operations (multiplication, division, etc.) take.

  • The algorithmic complexity for basic operations on large numbers is usually logarithmic in the size of the numbers.

2) The number of iterations needed to find a solution:

  • Cornacchia’s algorithm proceeds by successive iterations until a solution is found.

  • The number of iterations depends on the value of D and can vary greatly depending on the case.

  • In general, the larger the D, the number of iterations will be large.

In conclusion, the complexity of the adapted Cornacchia algorithm can be characterized as follows:

  • Complexity of arithmetic operations: O(logn), where n is the size of the manipulated numbers.

  • Overall complexity: O(klogn), where k is the number of iterations needed to find a solution.

The actual complexity therefore depends heavily on the value of D and the size of the numbers involved. For relatively small D values, the adapted Cornacchia algorithm is usually very efficient and can be used to solve reasonably sized Pell-Fermat equations [14].

6.3. How Does Cornacchia’s Algorithm Compare to the Algecta of Cornacchia Origin in Terms of Efficiency and Practice?

Let’s go through a comparison between the adapted Cornacchia algorithm and the original one.

  • Original Cornacchia algorithm

  • This algorithm was proposed by Giuseppe Cornacchia in 1908 to solve the Pell-Fermat equation.

  • It uses operations on integers and cont9inue fractions to find a solution.

  • Complexity of calculation: O( DlogD ) , where D is the coefficient of the Pell-Fermat equation.

  • Efficiency: very good for relatively small D values (e.g. <106).

  • Disadvantages: can become very slow for very large D values, and requires the calculation of the square root fractional portion of D.

  • Adapted Cornacchia algorithm

  • This algorithm is an improved variant of the original algorithm, proposed more recently.

  • It uses operations only on integers, thus avoiding calculations with continuous fractions.

  • Computational complexity: O(klogn), where k is the number of iterations and n is the size of the numbers manipulated.

  • Efficiency: Generally faster than the original algorithm, especially for very large D values

  • The advantages

  • Avoids calculations with continuous fractions, no more to implement.

  • Can be faster than the original algorithm, especially for very large D values.

  • Adaptable to solving other Diophantine equations.

In summary, the adapted Cornacchia algorithm is generally more efficient and more convenient to implement than the original algorithm, especially for very large D values. However, for relatively small D values, the two algorithms have similar performance.

7. Elaborating on the Criteria for Determining Whether a Primitive Positive Solution Is Admissible. Providing Clear Guidance and Rationale for These Criteria

The criteria for determining whether a primitive solution to the Pell-Fermat equation x 2 D y 2 =1 is admissible are as follows:

1) Positivities of solutions

  • The solutions (x, y) must be positive integers.

  • Rationale: The Pell-Fermat equation describes a relationship between geometric quantities that must be positive (length, areas, etc).

2) Minimality of the solution

  • Among all the possible solutions, we must identify the smallest solution in absolute value, called the primitive solution.

  • Rationale: The original solution is the simplest and most fundamental, from which all other solutions can be generated.

3) Uniqueness of the primitive solution

  • For a given value of D, there must be only one primitive solution.

  • Rationale: If there were multiple primitive solutions, this would imply that there are several fundamentally different ways of solving the equation, which is not the case.

4) Pell condition

  • The primitive solution (x, y) must satisfy the Pell condition x 2 D y 2 =1 .

  • Justification: it is the very definition of the Pell-Fermat equation that we are trying to solve [15].

7.1. Guidelines for Verifying Whether a Solution Is Acceptable

1) Verify that the values of x and y are positive integers.

2) Calculate the product x 2 D y 2 and check that it is equal to 1.

3) Compare the candidate solution to already known solutions to identify the smallest in value.

4) Make sure that there are no other primitive solutions for the same value of D. By following these criteria, it can be guaranteed that the solution identified is the unique and fundamental primitive solution of the Pell-Fermat equation for the value of D considered.

7.2. Discussion of the Possible Range of Solutions for Given Quadratic Forms, Are There Any Constraints or Special Cases Where the Adapted Algorithm Does Not Work

The range of possible solutions for the equations of the quadratic form x 2 D y 2 =1 (Pell-Fermat equation) depends on several factors.

1) Valeur of D

  • For a given value of D, there are infinitely many solutions (x, y) satisfying the equation.

  • However, among these solutions, there is only one primitive solution that is the smallest in value.

  • From this primitive solution, we can generate all the solutions using recurrence formulas.

2) Sign of solutions

  • The solutions x and y must be positive integers.

  • There are therefore no negative solutions for this solution.

3) Solution size

  • The larger the value of D, the larger the primitive solutions x and y can become.

  • For example, for D = 61, the primitive solution is (x, y) = (267.37).

  • The larger D is, the more iterations are needed to find the primitive solution.

7.3. Regarding Constraints or Special Cases or Adapted of Cornacchia May Not Work

1) Ineligible D values.

  • The adapted Cornacchia algorithm assumes that D is a positive non-square integer.

  • If it is not, the algorithm will not be able to find solutions because the Pell-Fermat equation would have no solutions in this case.

2) Numerical precision problems.

  • If the values of the variables of x and y become too large, they may exceed the maximum capacity of the numeric data types used by the implementation.

  • This can cause overflow issues and prevent the algorithm from working properly.

To overcome these problems, it may be necessary to use arbitrarily precise calculation libraries or to adapt the algorithm to better handle very large values.

In summary: the range of possible solutions for the Pell-Fermat equations is very wide and depends mainly on the value of D. however, the adapted Cornacchia algorithm may encounter limitations when values become very large, requiring adaptations to ensure its robustness.

7.4. Let Us Give More Detailed Examples, Especially for Generalist Generative Forms, Which Could Help Illustrate the Application of the Cornacchia Algorithm. Then Discuss the Potential Applications of These Findings in Other or Related Areas of Mathematics That Can Provide Additional Context and Motivation for Research

1) Quadratic generating forms:

  • Consider the quadratic form Q( x,y )= x 2 +xy+ y 2 . Cornacchia’s algorithm can be used to find all these integers x,y such that Q( x,y ) is a perfect square.

  • For example, finding the solutions of Q( x,y )=4 , the algorithm would give solutions ( x,y )=( 0,±2 );( ±1,±1 );( ±2,0 ) .

  • This application has links with number theory and number geometry, especially in the study of quadratic forms and their representation by squares.

2) Cubic generating forms.

  • Let the cubic form C( x,y,z )= x 3 + y 3 + z 3 . Cornacchia’s algorithm can be used to find triples ( x,y,z ) such that C( x,y,z ) is a perfect square.

  • For example, we can find that C( 1,1,1 )=1 is a perfect square thus giving a non-trivial solution.

  • This application has links to number theories, Diophantine numbers and the search for integer solutions for cubic equations.

3) Higher-order generative forms.

  • More generally, we can consider higher-order generative forms such as f( x,y,z,t )= x 4 + y 4 + z 4 + t 4 .

  • Cornacchia’s algorithm can also be applied to find quadruplets ( x,y,z,t ) such that f( x,y,z,t ) is a perfect square. These results are part of a broader result of the theory of Diophantine equations and the search for integer solutions for polynomial equations.

7.5. Regarding the Potential Equations of These Results, We Can Mention

1) Number theory and number geometry.

  • Quadratic, cubic, and order generative forms have direct links to the theory of quadratic and cubic forms, as well as number geometry.

  • These results can contribute to a better understanding of the arithmetic properties of these forms and their representation by perfect squares.

2) Diophantine équations

  • The search for integer solutions for polynomial equations is a central topic in Diophantine number theory.

  • Applications of the Cornacchia algorithm to these generative forms can provide new tools and perspectives for the study of Diophantine equations.

3) Additive number theory.

  • Generating forms can be related to problems in additive number theory, such as the representation of integers by sums of powers.

  • Results obtained with the Cornacchia algorithm may shed new light on these questions.

4) Cryptography and number theory.

  • Some cryptographic and code theory applications use arithmetic properties similar to those studied.

  • The techniques developed by the Cornacchia algorithm could find applications in this field.

8. Conclusions

Cornacchia’s algorithm is good for the form n=a x 2 +bxy+c y 2 if all the primitive positive integer solutions of the equation f( x,y )=n are admissible, i.e. computable by the algorithmic process. In addition, the Cornacchia algorithm is good in the following cases:

1) n= x 2 +d y 2 with d and n positive integers;

2) n=a x 2 +bxy+c y 2 and a>0 , c>0 , D= b 2 4ac<0 , | D |>16 et | b | | D |16 8 and n integer ≥2sup(a, c).

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Serre, J.P. (1973) A Course in Arithmetc, Collection: Graduate Texts in Mathematics. Springer, 115.
[2] Serre, J.P. (1970) Cours d’Arithmétique. P.U.F., 123.
[3] Crandall, R. and Pomerance, C. (2005) Prime Numbers: A Computation Al Perspective. Spinger, 97.
[4] Morain, F. (2007) Implementing the Asymptotically Fast Version of the Elliptic Curve Primality Proving Algorithm. Mathematics of Computation, 76, 493-505.
https://doi.org/10.1090/S0025-5718-06-01890-4
[5] Blachut, R.E. (2014) Cryptography and sécure communication. Cambridge University Press, 602.
[6] Cohen, H. (1993) A Course in Computational Algebraic Number Teory. Springer, 234.
https://doi.org/10.1007/978-3-662-02945-9
[7] Cox, D.A. (1989) Primes of the Form , Fermat, Class Field Theory and Complex Multiplication. Wiley, 432.
[8] Hardy, K., Muskat, J.B. and Williams, K.S. (1990) Solving Using the Euclidan Algorithm. Utilitas Mathematica, 38, 225-236.
[9] Hardy, G.H. and Wright, E.M. (1969) An Introduction to the Theory of Numbers。 5th Edition, Oxford Science Publications, 567。
[10] Wagon, S. (1990) Editor’s Corner: The Euclidean Algorithm Strikes again. The American Mathematical Monthly, 97, 125-129.
https://doi.org/10.1080/00029890.1990.11995559
[11] Samuel, P. (1970) Théorie algébrique des nombres. Hermann, 282.
[12] Cornacchia, G. (1908) Su di un metodo per la risoluzione in numeri interi dell’equazione . Giornale di Matematiche di Battaglini, 46, 33-90.
[13] Séroul, R. (1995) Math-info, Informatique pour mathématiciens. InterEditions, 321.
[14] Smith, H.J.S. (1855) De compositione numerorum primorum formae 4λ + 1 ex duobus qudratis. Journal für die reine und angewandte Mathematik, 1855, 91-92.
https://doi.org/10.1515/crll.1855.50.91
[15] Cohen, H. (1993) A Course in Computational Algebraic Number Theory. Spinger, 536.
https://doi.org/10.1007/978-3-662-02945-9

Copyright © 2025 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.