A NEW ALGORITHM FOR FINDING RATIONAL FIRST INTEGRALS OF POLYNOMIAL VECTOR FIELDS

We present a new method to compute rational first integrals of a planar polynomial vector field. The algorithm is in general much faster than the usual methods and also allows to compute the remarkable curves associated to the rational first integral of the system.


Introduction
A polynomial vector field of degree m defined on C 2 is a vector field of the form where P, Q ∈ C[x, y] are coprime and m = max{deg P, deg Q}. We shall refer to the vector field (1) or equivalently to its associated planar polynomial differential systemẋ = P (x, y),ẏ = Q(x, y).
Let U ⊆ C 2 be an open set. A non-constant C 1 function H : U → C, eventually multi-valued, which is constant on all the solutions of X contained in U is a first integral of X on U . In this case we say that X is integrable on U . Moreover we have XH = 0 on U .
One of the main open problems in the qualitative theory of planar polynomial vector fields is to characterize the integrable ones. The importance of the first integral is in its level sets: the existence of such a function H on U determines the phase portrait of the system on U , because the level sets H = h ∈ H(U ) give the expression of the curves laying on U . Consequently, given a vector field (1), it is important to know if it has a first integral.
The Theory of Integrability is a classical one. It received contributions from the work of Poincaré (see [18]), who was mainly interested in the rational first integrals. Prelle and Singer (see [19]), using methods of differential algebra, showed that if a polynomial vector field has an elementary first integral, then it can be computed using Darboux Theory of Integrability. Singer (see [20]) proved that if a polynomial vector field has Liouvillian first 2 A. FERRAGUT AND H. GIACOMINI integrals, then it has integrating factors given by Darbouxian functions (see [4]).
Forsyth (see [10]), Kummer et al. (see [14]) and Goriely (see [12]) proved that a system of dimension n has k < n algebraically independent first integrals if and only if it has k independent rational first integrals. This result shows that in order to investigate the algebraic integrability of a differential system, we only need to study its rational first integrals.
For the local first integrals of a vector field, Furta (see [11]) proved that if a vector field has a singular point with the eigenvalues not satisfying any resonant conditions, then the vector field has no analytic first integrals in a neighborhood of the singular point. Li et al. (see [16]) gave necessary and sufficient conditions in order that a vector field has a formal first integral in a neighborhood of a singular point when one eigenvalue is zero, and the others are not resonant.
For polynomial vector fields, probably the most natural first integrals are the rational ones (see [1,17]). We recall that a rational function f /g is called a first integral of a polynomial vector field (1) if the polynomials f and g are coprime and f /g is constant on each integral curve in R 2 \ Σ, where Σ = {(x, y) ∈ R 2 : g(x, y) = 0}. We remark that by a result due to Jouanolou (see [13] and see [5] for an easier proof), a planar polynomial vector field of degree m has a rational first integral if and only if it has m(m + 1)/2 + 2 invariant algebraic curves.
If a planar polynomial vector field has a rational first integral H = f /g, then all the integral curves of this vector field are algebraic, and we can write them as f + cg = 0, with c ∈ C ∪ {∞}. According to Poincaré (see [18]) c is a remarkable value of H if f + cg is a reducible polynomial in C[x, y]. Here if c = ∞ then f + cg denotes g. The curves in the factorization of f + cg, when c is a remarkable value, are called remarkable curves. It is proved in [3] that there are finitely many remarkable values for a given rational first integral H. These curves appear to be very important in the phase portrait of the vector field, as it is shown in [8,9].
The following result is due to Poincaré (see [18]). It gives a necessary condition for a planar polynomial vector field to have a rational first integral.
This result was generalized in [15]. We reproduce in Theorem 2 its main result.
Two analytic functions f, g : U ⊂ C 2 → C are coprime if the set of points {(x, y) ∈ U : f (x, y) = g(x, y) = 0} is isolated. We call the ratio of two coprime analytic functions a generalized rational function. A generalized rational function H = f /g defined on U is a first integral of the vector field (1) if Σ = {(x, u) ∈ U : g(x, y) = 0} is a set of integral curves of (1) and H is a first integral on U \ Σ. Finally we recall that a singular point is elementary if at least one eigenvalue of the linear part of the field at that point is nonzero.
Theorem 2 (see [15]). Assume that the origin is an elementary singular point of the analytic differential system where the dots denote the terms of order bigger than one. Let λ 1 = 0, λ 2 be the eigenvalues at the origin. Then system (2) has a generalized rational first integral in some neighborhood of the origin if and only if one of the following conditions holds.
(a) λ 1 = 0 = λ 2 and the origin is not an isolated singular point; (2) is analytically equivalent to its linear part; (e) λ 1 /λ 2 ∈ Q − and the germ (2) is analytically orbitally equivalent to its linear part. Moreover, if (a) or (e) hold then system (2) has an analytic first integral in some neighborhood of the origin.
In Theorem 2 it is proved that the existence of a generalized rational first integral of an analytic differential system having an elementary singular point is equivalent to the fact that the singular point is either a saddle, a center, a node, or a non-isolated singular point having one zero eigenvalue.
From Theorem 2 we know that a planar polynomial differential system having a resonant elementary singular point at the origin has a generalized rational first integral H(x, y) = f (x, y)/g(x, y), where f and g are analytic functions. If H is a rational function of degree k then f and g are polynomials of maximum degree k ∈ N.
The main purpose of this paper is to provide an effective algorithm to compute rational first integrals of polynomial vector fields. The method is explained in section 2. The main idea is to consider a neighborhood U ⊆ R 2 without singular points and to use the power series expansion y = y a 0 (x) = i≥0 a i x i of the local representation of the curves passing through the regular points (x 0 , y(x 0 )). If H = f /g is a rational first integral, then we must have f (x, y a 0 (x)) + cg(x, y a 0 (x)) ≡ 0 for all (x, y a 0 (x)) ∈ U . From this equation we can compute the coefficients of f and g. If we succeed and these coefficients can be obtained, then the system has a rational first integral of degree k given by f /g. We note that the existence and convergence of the series is assured by the general theory of ODE. We also show in section 2 that the algorithm can be applied in a neighborhood of a singular point. Moreover, we show how to compute the remarkable curves of the polynomial system, if any, using our algorithm. Finally in section 3 we explain why the algorithm is better than the usual method consisting in imposing that H = f /g satisfies the equation P H x + QH y = 0.

Rational first integrals of polynomial vector fields
We present in this section an algorithm to compute rational first integrals of polynomial vector fields. We show the efficiency of the method in example 1.
Consider the polynomial vector field X = (P, Q). Let a 0 ∈ (−ε, ε), for ε > 0 small enough such that the orbits of the system passing through the point (0, a 0 ) cross x = 0 transversally. If this is not the case, we can either take a smaller ε or swap x and y or do a translation. Consider the orbit γ a 0 of X crossing (0, a 0 ) and let y a 0 (x) = i≥0 a i x i be the power series expansion of y as a function of x. This power series is obtained from the equation We want the rational function H(x, y) = k i+j=0 f ij x i y j / k i+j=0 g ij x i y j to be a first integral of the system. Hence γ a 0 must be contained into a level set H(x, y) = −c. In particular the point (0, a 0 ) belonging to γ a 0 is in this level set. Therefore H(0, a 0 ) = −c and we can write c in terms of a 0 and of the coefficients of F k solving the equation F k (0, a 0 ) = 0.
As we want F k (x, y) = 0 to be an invariant curve of the system passing through (0, a 0 ), for the value of c mentioned above, the expression F k (x, y a 0 (x)) must be identically zero for arbitrary values of (x, y a 0 (x)) ∈ U . Writing this equation in power series of x and a 0 we obtain a system of equations where the unknowns are the coefficients f ij and g ij of F k . If this system has a non constant solution H then H is a rational first integral of degree k of the system. Otherwise we must look for a rational first integral of a higher degree.
Hence we must proceed in the following way: (1) Assure that a convenient neighborhood of the origin is considered.
(3) Set k = 1. (4) Compute c from the equation F k (0, a 0 ) = 0. (5) Write F k (x, y a 0 (x)) in power series of x and a 0 and construct the system of equations equaling each term of this power series to zero. Solve this system. (6) If the system has a solution providing a non-constant H, then this H is a rational first integral of degree k and we are finished. Otherwise set k := k + 1 and go back to step (4).
We note that the algorithm does not finish if the differential system has no rational first integral. We remark that there exist in the literature examples of families of polynomial systems of fixed degree having rational first integrals of arbitrary degree (see for instance [7] for examples of families of quadratic systems having a rational first integral or arbitrary degree), therefore it is not possible to bound the degree of the rational first integral. Example 1. Consider the polynomial system of degree 4 The origin is a regular point of this system. We compute y a 0 (x): j=0 f 0j a j 0 / 4 j=0 g 0j a j 0 . From the system of equations constructed from F 4 (x, y a 0 (x)) ≡ 0 we obtain the rational first integral of degree 4 We note that we spent less than 12 seconds to compute this first integral H using a program made with Mathematica (see [21]). The number of equations using our algorithm is 60, and there are 30 unknowns. The usual method deals with 72 equations and 30 unknowns, and spends some hours without providing a solution. As this example shows, the number of equations is lower and the computation is much faster using the new algorithm. This is because our algorithm does not waste time in subcases that do not lead to non-constant solutions, as we remark in section 3.
We can compute the remarkable curves of the differential system, if any, from our algorithm in the following way: once we have obtained c on step (4) of the algorithm, write the equation F k (x, y a 0 (x)) = 0 in power series only of x. From this power series we get a system of equations. If there exists a solution of this system which fixes a 0 , then we obtain a curve of degree k which is a solution of the differential system, and this curve is remarkable.
In example 1, from equation F 1 (x, y a 0 (x)) = 0 we obtain a system of equations writing F 1 in power series of x. For a 0 = 2 this system has a solution which is 2 + 3x − y = 0. This is the only remarkable curve of degree one.
The following example will be used in section 3 to compare our algorithm with the usual method.
Example 2. Consider the quadratic systemẋ = x + 2y − y 2 ,ẏ = −y + y 2 . This system has a saddle at (0, 0) whose eigenvalues are 1, −1. Let be the local solution of the system passing through the point (0, a 0 ), with a 0 = 0, 2. We note that for a 0 = 2 we cannot write y as a function of x and for a 0 = 0 we obtain the curves y = −x and y = 0, which are remarkable curves passing through the origin.
If the system has a rational first integral of degree 1, then F 1 (x, y a 0 (x)) = 0. Using our method we get the only solution F 1 = 1 − y and a 0 = 1, which means that the curve y = 1 is a solution of the system and is remarkable.
If we apply the algorithm in order to look for a rational first integral of degree 2, then we obtain where c is a constant. Taking convenient values of the coefficients of F 2 and isolating c we obtain the rational first integral of degree 2 H(x, y) = 1 − y y(x + y) .
The algorithm we have presented also applies in a neighborhood of a singular point, as we show in example 3. As the origin is a node for that system, there are infinitely many orbits passing through that point, while in the cases where the algorithm applies to a regular point (0, a 0 ) only one curve crosses that point.
The local expression y(x) in the case of a resonant node is It is known (see for example [2,12]) that given a polynomial equation f (x, y) = 0 one can always solve for y in terms of x by means of a fractional power series of y as given in (3).

Remark 1.
In the particular case of a resonant node, the relationship between c and a 0 is simpler, and we can write h ij = f ij + cg ij , and therefore F k (x, y) = k i+j=0 h ij x i y j . Hence the number of coefficients in this case is half the number of the general case. Moreover the power series F k (x, y(x)) is done only in terms of a variable that depends on a 0 and x.
Example 3. Consider the quadratic systemẋ = 3x + y 2 ,ẏ = 5y. This system has a node at (0, 0) whose eigenvalues are 3, 5. Let a 15 0 x 18 + · · · be a local solution of the system passing through the point (0, 0). Next we prove that the system has a rational first integral of degree 10. We have to solve the equation 10 i+j=0 h ij x i y a 0 (x) j = 0 with unknowns h ij . We obtain Isolating a 3 0 = 16807c we get the rational first integral of degree 10 The remarkable curve y = 0 can be obtained from F 1 = 0. To get the remarkable curve 7x − y 2 = 0 we need to write x = x(y).
We note that the expression of y a 0 is simpler if the algorithm applies to a singular point than to a regular point, as we see comparing examples 2 and 3.
We can apply the algorithm in a neighborhood of a singular point having both eigenvalues equal to zero. This case can be treated similarly to the studied cases: if there exists a parabolic or an elliptic sector in a neighborhood of the singular point, then we use similar arguments to those applied in example 3; otherwise we use the same arguments we apply to a regular point.
For this system the origin is a singular point with both eigenvalues equal to zero. Let y a 0 (x) = i≥0 a i x i be a local solution of the system close to the origin. Then y a 0 (x) is a solution of the equation y ′ (x) = (ẏ/ẋ)(x, y(x)), from which we obtain four solutions: The first and second curves are separatrices of the system. The third one describes the orbits of a hyperbolic sector close to the origin. The last one corresponds to a parabolic or an elliptic sector close to the origin. As we can see y 4 has a simpler expression than y 3 . Using this fourth solution we prove that the system has a rational first integral of degree 4. We need to solve the equation 4 i+j=0 h ij x i y 4 (x) j = 0 with unknowns h ij . We get Isolating a 3 we get the rational first integral of degree 4 We note that in this case c = 8/a 3 .
Our algorithm applies in general to regular points. The type of the analytic series is the same for all regular points, but it can be rather complicated in some cases, as we can see in the examples we have provided. For these cases it can be easier to apply the algorithm in a neighborhood of a singular point of the system, for the arbitrary parameter appears in a simpler way in the power series expansion, in particular in the case of a parabolic or elliptic sector. See for instance y 4 (x) in example 4, which has a simpler expression than y 3 (x).

Some remarks
The usual method of computing a rational first integral H of a given degree consists in taking a quotient of polynomials and forcing this quotient to be a first integral (i.e. forcing XH = 0), and obtaining an over-determined linear system that has to be solved. Our algorithm is in general much faster than the usual one. For instance a program made with Mathematica spends only half a second to compute the rational first integral of degree 10 in example 3, while the usual method may spend some hours without providing a solution.
In the process of searching the rational first integral our algorithm allows to compute all the remarkable curves of the system, which is in general a difficult task (see [6,9]). The remarkable curves are very important in the phase portrait of the polynomial systems having a rational first integral, because they provide many separatrices of the phase portrait. If the system has no rational first integral, then these curves that we find in the process are invariant algebraic curves of the system, that may be also important in the phase portrait and very useful to compute a Darboux first integral or a Darboux integrating factor of the system (see [3]).
The algebraic systems of equations obtained from the usual method and from the one that we have provided are different. However, the non-constant solutions are the same, and our method need less equations. Moreover, the difference between these algebraic systems of equations is that the resolution of the system given by the usual method wastes a lot of time in branches of subcases from which there is no non-constant solution, while our method is more direct and does not have so many ramifications, as we show in the following analysis of example 2.
Consider again the quadratic system of example 2. We show in figure  1 how we solve the system of equations arising from the series expansion of the equation F 2 (x, y a 0 (x)) = 0. As we can see only eight final subcases arise (the leaves of the tree in figure 1) from the twenty-three equations that are needed to obtain the rational first integral. Moreover, only nine of these equations give conditions on the coefficients; the rest are identically satisfied. The usual method needs to solve seventeen non identically satisfied equations with twelve unknowns. The computations show that solving just the first four equations we have twenty subcases. Thus our method does not waste time and computations in non-necessary subcases that give constant solutions or identically satisfied equations. Each row corresponds to an equation which is numbered on the right column. We only need the first 23 equations of the series expansion of F 2 (x, y a0 (x)) = 0 in powers of x and a 0 . The vertices of the tree mean equations from which some conditions on the coefficients of F 2 are taken. Bifurcations of new branches mean new subcases that need to be considered. The algorithm ends for this system, providing in some cases a rational first integral, which follows from some of the eight leaves of the tree.