Representation of an Integer by a Quadratic Form through the Cornacchia Algorithm ()
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
. 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
, x and y are necessarily prime to p and we have
. The converse is true, which we will demonstrate by giving algorithms that compute integers x. and y such that
[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
of the equation
, where
, 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
(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
(1)
We start from an integer a such that
with m a positive integer that we can assume < p (for example by taking
, we even then have
. Let us suppose
. Let
and
. Let x1 and y1 represent them of minimum x0 and y0 modulo m in absolute value. As
, we write
with
, hence
(2)
We check using
remarkable identity
The terms of the right-hand side checking
(3)
So if
and if
, we have a
with
. All that remains is to start again by replacing m by m’ and
by
. We have obtained a solution of the equation
if we obtain the value
. Let’s check it out. Since the m (and m’) form a strictly decreasing sequence of positive integers, we necessarily obtain
or
.
Let us show that if
, 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
, the integer m must divide p. If p is prime, this implies that
[6].
We have thus obtained an integer solution of the equation
. (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
.
3. Representation of a Prime Number by a Quadratic Form
with Two Variables
3.1. Definition 1
If
is a quadratic form with integer coefficients, f is said to represent p if there are integers x and y such that
. All that remains is to persuade yourself that you have verified the following theorem for a prime number
and different from 2 and 5.
3.2. Theorem 1
−5 is a square modulo p if and only if p is represented by
or by
. 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 Legendre’s quadratic law of reciprocity: if p and q are two distinct odd primes,
.
3.3. Example 1
In the following, a form will be a quadratic form
with a, b, and c integers prime to each other,
.
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
. Such a solution
is then said to be primitive.
3.5. Definition 3
Two forms
and
are said to be equivalent (or properly equivalent) if there are integers
and t such that
and
( resp.
). These are equivalence relationships.
3.6. Lemma 1
A form
properly represents an integer m if and only if
is properly equivalent to a form of the type
for b and c suitable. Indeed, suppose that there are you and v prime to each other such that
. By Bézout’s theorem, there exists w and t such that
and
is of the form
. The reverse is clear.
3.7. Definition 4
We call the discriminant of the form
the integer
[7].
3.8. Remark 1
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
. Its discriminant
is indeed a square modulo m.
Conversely, suppose that D is a square modulo m:
with
Its discriminant
is indeed a square modulo m:
with
. Since m is odd, we can take b and D of the same parity (even if it means changing b to b + m). Like
or 1 mod 4, we then have
.
Let c be the integer such that
. Then,
properly represents m and the integers
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
.
Let’s go back to the forms
and
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
and
.
3.11. Theorem 2
−5 is a square modulo p if and only if p is represented by par
or by
.
3.12. Theorem 3
An odd prime p prime to 5 is represented by
si and only if
or 9 mod 20, it is represented by
if and only if
or 7 mod 20.
Let’s go back to the shape equivalence classes.
3.13. Definition 5
A form
of a negative discriminant is said to be reduced if
and
in cases where
or
. There is only a finite number of reduced forms of the discriminant
given (we have indeed
and therefore
, there is a finite number of a and b and therefore of c since
).
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
and even to the case of
.
Let
be a form and n an integer. We say that a primitive positive solution
of the equation
is admissible if it is obtained in the following way: we take α modulo n such that
, u is the first of the remainders of Euclid’s algorithm associated with n and α that is less than
) (possibly α itself) and the equation
has an integer solution v in y [10].
We will say that Cornacchia’s algorithm is good for the form
if all the primitive positive integer solutions of the equation
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)
with d and n positive integers;
2)
and
,
,
,
et
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
has no integer solutions.
5. Proof of the Cornacchia Algorithm in the Case of the Equation
5.1. Theorem 5
Let a be an integer such as −1 or a square mod a. If b is an integer verifying
et
, the first two remainder
in the algorithm of Euclidean division of a by b give a primitive solution of the equation
. Moreover, all primitive solutions are obtained in this way. A trivial transformation is one of the transformations
ou
. A primitive solution of the equation is a solution
with x and y primes between them [11].
5.2. Some Polynomials Associated with Euclid’s Algorithm
Consider the sequence of equations
(4)
It is easy to see that by substitution, we can write
(5)
where the
and
are polynomials in
of partial degree 1 in relation to each of the
.
Relationships
Implies that:
(6)
We deduce that
and therefore that
(7)
The polynomial
has the property
Indeed, we have
Thus,
is the coefficient at the top left of the matrix
This coefficient is also that of its transpose (in the same place) which is equal to
and is
. We can explicitly compute
with MAPLE using the recurrence relation:
. We find
[12]
It will be noted that the monomials involved in
are exactly those obtained by removing from
a certain number of successive pairs of elements
.
If
, we have
(8)
It is easy to deduce that:
(9)
Particular case
Suppose that n is even and that
, that is, that is,
.
For
, the equation becomes:
Either
5.3. Properties of Euclid’s Algorithm
Let a and b now be two positive integers prime to each other with
. The sequence of the quotients associated with
is the sequence of successive quotients obtained by applying Euclid’s algorithm to a and b: we set
,
and then we define by recurrence
(10)
We denote n the integer such that
and we call it the length of the algorithm. So we have
.
We define another sequence of integers
by:
We then have the ties:
If
is the sequence defined by the same recurrence relation and first terms 1 and 0. By recurrence, it is easy to see that the
are of alternating sign, more precisely
.
Hence the relationship
(11)
The rest of the
is therefore increasing. Thus, we can see the
as the sequence of successive remainders in Euclid’s algorithm applied to
and
. Since
and a and b are prime to each other, for
indicates that a divides
. We actually have
because
What can we say now about
? we have
et
.
5.4. Theorem 6
Let a and b be two integers with
. The sequence of successive quotients in Euclid’s algorithm (of length n) starting with a and b is symmetric if and only if
and we then have
[13].
Let’s prove the lemma. We have just seen that the sequence of
is increasing, that the
are of alternating sign, with
of the sign of
, and that
.
Suppose
with
.
Show that
. We notice that
. Like
, we deduce that
. Moreover,
, therefore
where
.
Suppose
. Wich means
. The euclidian division of
par
gives
Since
. So
and we have
From where
Euclid’s algorithm of a by b would be of length
. Contradiction, so
. It is then clear that the sequences
and
are equa. In addition, we have
. Let us now suppose the sequences
and
equal. So we have
and
. We also always have
which implies that
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
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
such that
; Let’s choose one.
By applying
and by denoting
the successive remainders as before, we obtain that the roots
and
check
Although of course
.
Let us show that
is the first remainder less than
. Let us first note that for any integer i, we have
Indeed, as
and
, by squaring,
; since
, the congruence can be deduced from this. Suppose that there exists
such that
. Then,
and we necessarily have
. On the other hand,
. All that remains is to show that with the nearest transformation by
and
, there is only one solution
to the equation
of quotient x/y mod has given, which will imply that
and therefore
. To do this, let’s take two pairs
and
with
,
et
. So we have the equations
,
and
, for r an integer. Let us eliminate
in the second equation. We easily obtain the equation
whose discriminant must be positive (and even a square in
); it is
. We therefore necessarily have
, or
. For
, we get
, for
, we get
, which proves our assertion. In conclusion, we have shown that the different choices of b verifying
and
give the different primitive solutions of the equation
, with the nearest transformation by
and
, in the following way: the solution is given by the first pair of remainders less than
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
solutions, where
is the number of prime factors in the decomposition of n (if p is odd, −1 is a square in
if and only if
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
: The cornacchia algorithm can be used to find integers x and y that satisfy Fermat’s equation
where z is an integer. This algorithm has been used to solve some such Fermat equations, such as
.
Quadratic form
: Cornacchia’s algorithm can be adapted to solve equations of the form
where a, b, and c are integers. For example: p find solutions to the equation:
, 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
where a, b, and c are integers. For example: we can use it to find solutions to the equation
.
Quadratic forms with Gaussian coefficients: The Cornacchia algorithm can be extended to quadratic forms defined on the ring of Gaussian integers, of the form
, where a and b are integers. This solves equations like
.
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:
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:
, 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
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
.
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
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
(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
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
. Cornacchia’s algorithm can be used to find all these integers
such that
is a perfect square.
For example, finding the solutions of
, the algorithm would give solutions
.
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
. Cornacchia’s algorithm can be used to find triples
such that
is a perfect square.
For example, we can find that
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
.
Cornacchia’s algorithm can also be applied to find quadruplets
such that
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.
8. Conclusions
Cornacchia’s algorithm is good for the form
if all the primitive positive integer solutions of the equation
are admissible, i.e. computable by the algorithmic process. In addition, the Cornacchia algorithm is good in the following cases:
1)
with d and n positive integers;
2)
and
,
,
,
et
and n integer ≥2sup(a, c).