Pascal Koiran
email: pascal.koiran@ens-lyon.fr.

Mateusz Skomra
email: ma-teusz.skomra@laas.fr.

Derandomization and Absolute Reconstruction for Sums of Powers of Linear Forms

de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

(i) It is an algebraic algorithm, i.e., it performs only arithmetic operations and equality tests on the coefficients of the input polynomial f . In particular, it does not make any appeal to polynomial factorization.

(ii) For f ∈ Q[x 1 , . . . , x n ], the algorithm runs in polynomial time when implemented in the bit model of computation.

The algorithm relies on methods from linear and multilinear algebra (symmetric tensor decomposition by simultaneous diagonalization). We also give a version of our algorithm for decomposition over the field of real numbers. In this case, the algorithm performs arithmetic operations and comparisons on the input coefficients. Finally we give several related derandomization results on black box polynomial identity testing, the minimization of the number of variables in a polynomial, the computation of Lie algebras and factorization into products of linear forms.

Introduction

Let f (x 1 , . . . , x n ) be a homogeneous polynomial of degree d, also called a degree d form. In this paper we study decompositions of the type:

f (x 1 , . . . , x n ) = r i=1 l i (x 1 , . . . , x n ) d (1)
where the l i are linear forms. Such a decomposition is sometimes called a Waring decomposition, or a symmetric tensor decomposition. We focus on the case where the linear forms l i are linearly independent. This implies that the number r of terms in the decomposition is at most n. When r = n we have f (x) = P d (Ax) where A is an invertible matrix of size n and

P d (x 1 , . . . , x n ) = x d 1 + x d 2 + • • • + x d n (2)
is the "sum of d-th powers" polynomial. If f can be written in this way, we say that f is equivalent to a sum of n d-th powers. More generally, two polynomials f, g in n variables are said to be equivalent if they can be obtained from each other by an invertible change of variables, i.e., if f (x) = g(Ax) where A is an invertible matrix of size n. As pointed out in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], the case d = 3 (equivalence to a sum of n cubes) can be tackled with the decomposition algorithm for cubic forms in Saxena's thesis [START_REF] Saxena | Morphisms of rings and application to complexity[END_REF]. Equivalence to P d for arbitrary d was studied by Kayal [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. This paper also begins a study of equivalence to other specific polynomials such as the elementary symmetric polynomials; this study is continued in [START_REF] Garg | Determinant equivalence test over finite fields and over Q[END_REF][START_REF] Grochow | Matrix isomorphism of matrix Lie algebras[END_REF][START_REF] Grochow | Isomorphism problems for tensors, groups, and cubic forms: completeness and reductions[END_REF][START_REF] Kayal | Affine projections of polynomials[END_REF][START_REF] Kayal | Reconstruction of full rank algebraic branching programs[END_REF], in particular for the permanent and determinant polynomials. The contributions of the present paper are twofold:

(i) We give efficient tests for equivalence to a sum of n cubes over the fields of real and complex numbers. In particular, for an input polynomial with rational coefficients we give the first polynomial time algorithms in the standard Turing machine model of computation. As explained below in Section 1.1, this is not in contradiction with the polynomial time bounds from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF][START_REF] Saxena | Morphisms of rings and application to complexity[END_REF] because we do not address exactly the same problem or work in the same computation model as these two papers.

More generally, we can test efficiently whether the input f can be written as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] as a sum of cubes of linearly independent linear forms. This follows easily from our equivalence tests and the algorithms from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF][START_REF] Saxena | Morphisms of rings and application to complexity[END_REF] for the minimization of the number of variables in a polynomial.

(ii) Our first equivalence algorithm for the fields of real and complex numbers is randomized. We derandomize this algorithm in Section 5, and we continue with several related derandomization results on black box polynomial identity testing, the minimization of the number of variables in a polynomial, the computation of Lie algebras and factorization into products of linear forms.

Equivalence to a sum of cubes

Our algorithm for equivalence to a sum of n cubes over C is algebraic in the sense that the input polynomial may have arbitrary complex coefficients and we manipulate them using only arithmetic operations and equality tests.

Over the field of real numbers we also allow inequality tests. We therefore work in the "real RAM" model; an appropriate formalization is provided by the Blum-Shub-Smale model of computation [START_REF] Blum | Complexity and Real Computation[END_REF][START_REF] Blum | On a theory of computation and complexity over the real numbers: NP-completeness, recursive functions and universal machines[END_REF]. We can provide algebraic algorithms only because we are considering a decision problem: it is easy to see that if the input f (x 1 , . . . , x n ) is equivalent to a sum of n cubes, the coefficients of the linear forms l i in the corresponding decomposition need not be computable from those of f by arithmetic operations (see Examples 16 and 17 at the beginning of Section 3). Polynomial factorization is an important subroutine in many if not most reconstruction algorithms for arithmetic circuits, see e.g. [START_REF] García-Marco | Reconstruction algorithms for sums of affine powers[END_REF][START_REF] García-Marco | Polynomial equivalence problems for sums of affine powers[END_REF][START_REF] Karnin | Reconstruction of generalized depth-3 arithmetic circuits with bounded top fan-in[END_REF][START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF][START_REF] Kayal | Reconstruction of full rank algebraic branching programs[END_REF][START_REF] Kayal | Reconstruction of non-degenerate homogeneous depth three circuits[END_REF][START_REF] Shpilka | Interpolation of depth-3 arithmetic circuits with two multiplication gates[END_REF]. It may even seem unavoidable for some problems: reconstruction of ΠΣ circuits is nothing but the problem of factorization into products of linear forms, and reconstruction of ΠΣΠ circuits is factorization into products of sparse polynomials. Useful as it is, polynomial factorization is clearly not feasible with arithmetic operations only, even for polynomials of degree 2. We therefore depart from the aforementioned algorithms by avoiding all use of such a subroutine.

For an input polynomial f with rational coefficients, our algebraic algorithms run in polynomial time in the standard bit model of computation, i.e., they are "strongly polynomial" algorithms (this is not automatic due to the issue of coefficient growth during the computation). We emphasize that even for an input f ∈ Q[x 1 , . . . , x n ] we are still considering the problem of equivalence to a sum of n cubes over the real or complex numbers. Consider by contrast Kayal's equivalence algorithm [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], which appeals to a polynomial factorization subroutine. We can choose to factor polynomials over, say, the field of rational numbers. We can then run Kayal's algorithm without any difficulty on a probabilistic polynomial time Turing machine, but the algorithm will then reject the polynomial of Example 17 whereas our algorithm will accept it. 1 At first sight this difficulty seems to have a relatively simple solution: for an input with rational coefficients, instead of factoring polynomials in Q[X] we will factor in a field extension of Q containing the coefficients of the linear forms l i (for instance in Q[ √ 2] for Example 17). It is unfortunately not clear that this approach yields a polynomial time algorithm because it might lead to computations in a field extension of exponential degree. We explain this point in more detail in Section 3.1. For the same reason (reliance on a polynomial factorization subroutine) similar issues arise in the analysis of Saxena's decomposition algorithm. A complete analysis of these two algorithms for equivalence to a sum of powers over C in the Turing machine model would entail good control of coefficient growth and good bounds on the degrees of the field extensions involved. This has not been done yet to the best of our knowledge.

Derandomization

We give a deterministic black box identity testing algorithm for polynomials which can be represented as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] as a sum of powers of linearly independent linear forms. As we will see in Section 6.2, the problem is really to decide whether the (unknown) number of terms r in the decomposition is equal to 0. Indeed, for r ≥ 1 such a polynomial can never be identically zero (and the PIT problem for this family of polynomials can therefore be solved by a trivial algorithm in the white box model). In contrast to our equivalence algorithms, this black box PIT applies to homogeneous polynomials of arbitrary degree.

There is already a significant amount of work on identity testing for sums of powers of linear forms. In particular, Saxena [START_REF] Saxena | Diagonal circuit identity testing and lower bounds[END_REF] gave a polynomial time algorithm in the white box model (where we have access to an arithmetic circuit computing the input polynomial). Subsequently, several algorithms were given for the black box model [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF][START_REF] Forbes | Quasipolynomial-time identity testing of non-commutative and read-once oblivious algebraic branching programs[END_REF][START_REF] Forbes | Explicit Noether normalization for simultaneous conjugation via polynomial identity testing[END_REF][START_REF] Michael A Forbes | Hitting sets for multilinear read-once algebraic branching programs, in any order[END_REF] but they do not run in polynomial time. The current state of the art is in [START_REF] Michael A Forbes | Hitting sets for multilinear read-once algebraic branching programs, in any order[END_REF], with a black box algorithm running in time s O(log log s) . We obtain here a polynomial running time under the assumption that the l i are linearly independent. Without this assumption, designing a black box PIT algorithm running in polynomial time remains to the best of our knowledge an open problem.

In Section 7 we build on our black box PIT to derandomize Kayal's algorithm for the minimization of the number of variables in a polynomial [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. Like our black box PIT, this result applies to polynomials that can be written as sums of powers of linearly independent linear forms. For such a polynomial, the minimal (or "essential") number of variables is just the number r of terms in the corresponding decomposition [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF]. We continue with the computation of Lie algebras of products of linear forms. Finally, our deterministic algorithm for this task is applied to the derandomization of a factorization algorithm from [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF] and of Kayal's algorithm for equivalence to P d [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF].

Our approach

We obtain our equivalence algorithms by viewing the coefficients of the input polynomial f (x 1 , . . . , x n ) as the coefficients of a symmetric tensor T of size n and order 3 (since f is of degree 3). Equivalence to a sum of n cubes then amounts to a kind of diagonalizability property of T . This approach is explained in detail in Section 3. It can be viewed as a continuation of previous work on orthogonal tensor decomposition [START_REF] Koiran | Orthogonal tensor decomposition and orbit closures from a linear algebraic perspective[END_REF] (the present paper is more algorithmic, is not limited to orthogonal decompositions and can be read independently from [START_REF] Koiran | Orthogonal tensor decomposition and orbit closures from a linear algebraic perspective[END_REF]).

We work on a tensor of size n by cutting it into n "slices"; each slice is a symmetric matrix of size n. We therefore rely on methods from linear algebra. This explains the presence of a section of preliminaries on simultaneous reduction by congruence (which is then applied to the slices of T ). Despite these rather long preliminaries, the resulting randomized algorithm is remarkably simple: it is described in just 3 lines at the beginning of Section 4.

Our deterministic algorithms also rely on important insights from Kayal's paper [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. In particular we rely on the factorization properties of the Hessian determinant of the input f , which we manage to use without appealing explicitly to a factorization subroutine (as explained in Section 1.1, this is ruled out in our approach). Our deterministic algorithm for the minimization of the number of variables is directly inspired by the randomized algorithm for this problem in the same paper.

Comparison with previous tensor decomposition algorithms

There is a vast literature on tensor decomposition algorithms, most of them numerical (see [START_REF] Beltrán | Pencil-based algorithms for tensor rank decomposition are not stable[END_REF] for a recent paper showing that many of these algorithms are numerically unstable). From this literature, two papers by De Lathauwer et al. [START_REF] De | A link between the canonical decomposition in multilinear algebra and simultaneous matrix diagonalization[END_REF][START_REF] De Lathauwer | Computation of the canonical decomposition by means of a simultaneous generalized Schur decomposition[END_REF] are closely related to the present work since they already recognized the importance of simultaneous diagonalization by congruence for tensor decomposition. Jennrich's algorithm is also closely related for the same reason. One can find a presentation of this algorithm in the recent book by Moitra [START_REF] Moitra | Algorithmic aspects of machine learning[END_REF] but it goes back much further to Harschman [START_REF] Harshman | Foundations of the PARAFAC procedure: Models and conditions for an "explanatory" multimodal factor analysis[END_REF], where it is presented as a uniqueness result. There are nevertheless important differences between the settings of [START_REF] De | A link between the canonical decomposition in multilinear algebra and simultaneous matrix diagonalization[END_REF][START_REF] De Lathauwer | Computation of the canonical decomposition by means of a simultaneous generalized Schur decomposition[END_REF][START_REF] Moitra | Algorithmic aspects of machine learning[END_REF]] and of the present paper. In particular, these three works do not phrase tensor decomposition as a decision problem but as an optimization problem which is solved by numerical means (one suggestion from [START_REF] De | A link between the canonical decomposition in multilinear algebra and simultaneous matrix diagonalization[END_REF][START_REF] De Lathauwer | Computation of the canonical decomposition by means of a simultaneous generalized Schur decomposition[END_REF] is to perform the simultaneous diagonalization with the extended QZ iteration from [START_REF] Van Der Veen | An analytical constant modulus algorithm[END_REF]; Jennrich's algorithm as presented in [START_REF] Moitra | Algorithmic aspects of machine learning[END_REF] relies on pseudoinverse computations and eigendecompositions). All these numerical algorithms attempt to produce a decomposition of a tensor T which is close to the input tensor T . If one tries to adapt them to the setting of the present paper there is a fundamental difficulty: given T and its decomposition, it is not clear how we can decide whether or not T admits an exact decomposition. This is the main reason why we need to design a new algorithm. As an alternative, one could attempt to run Jennrich's algorithm in symbolic mode. In particular, eigenvalues and the components of eigenvectors would be represented symbolically as elements of a field extension. This leads exactly to the same difficulty as with Kayal's algorithm: as explained in Section 1.1 and in more detail in Section 3, the resulting algorithm might not run in polynomial time because it might lead to computations in field extensions of exponential degree. Note finally that [START_REF] De | A link between the canonical decomposition in multilinear algebra and simultaneous matrix diagonalization[END_REF][START_REF] De Lathauwer | Computation of the canonical decomposition by means of a simultaneous generalized Schur decomposition[END_REF][START_REF] Moitra | Algorithmic aspects of machine learning[END_REF] deal with decompositions of ordinary rather than symmetric tensors. Algorithms for symmetric tensor decomposition can be found in the algebraic literature, see e.g. [START_REF] Brachat | Symmetric tensor decomposition[END_REF][START_REF] Bernardi | Computing symmetric rank for symmetric tensors[END_REF]. Like [START_REF] De | A link between the canonical decomposition in multilinear algebra and simultaneous matrix diagonalization[END_REF][START_REF] De Lathauwer | Computation of the canonical decomposition by means of a simultaneous generalized Schur decomposition[END_REF], these two papers do not provide any complexity analysis for their algorithms.

Future work

In the current literature there is apparently no polynomial time algorithm (deterministic or randomized) in the Turing machine model for the following problem: given a homogeneous polynomial f (x 1 , . . . , x n ) of degree d ≥ 4 with rational coefficients, decide whether it is equivalent to

x d 1 +• • •+x d n over C.
It will be shown in a forthcoming paper that this can be done by extending the tensor-based approach of the present paper to higher degree. This results in a black box algorithm with running time polynomial in n and d [START_REF] Koiran | Black box absolute reconstruction for sums of powers of linear forms[END_REF]. Alternatively, one could try to modify Kayal's equivalence algorithm [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] or provide a better analysis of the existing algorithm. As we have argued in Section 1.1 this has not been done at present even for degree 3. One could also try an approach based on Harrison's work [START_REF] Dk Harrison | A Grothendieck ring of higher degree forms[END_REF] like in Saxena's thesis [START_REF] Saxena | Morphisms of rings and application to complexity[END_REF].

More generally, we suggest to pay more attention to absolute circuit reconstruction, i.e., arithmetic circuit reconstruction over C. 2 Circuit reconstruction over Q or over finite fields has a number-theoretic flavour, whereas circuit reconstruction over R or C is of a more geometric nature.

One goal could be to obtain algebraic decision algorithms; as we have explained, this requires the removal of all polynomial factorization subroutines. In principle, this is always possible since the set of polynomials computable by arithmetic circuits of a given shape and and size is definable by polynomial (in)equalities, i.e., it is a constructible set (over C) or a semi-algebraic set (over R). 3 Another goal would be to obtain good complexity bounds for the Turing machine model when they are not available in the existing literature.

Organization of the paper

Section 2 is devoted to preliminaries on simultaneous diagonalization, by similarity transformations and especially by congruence. In Section 3 we review Kayal's equivalence algorithm and explain why it does not yield a polynomial time bound in the bit model of computation. We also present our tensor-based approach to the equivalence problem. In Section 4 we give a polynomial time randomized algorithm for equivalence to a sum of cubes based on this approach. We derandomize this algorithm in Section 5. In Section 6 we give a PIT algorithm for polynomials that can be written as sums of d-th powers of linearly independent linear forms. As mentioned before, our algorithm runs in polynomial time in the black box model. We give a randomized algorithm to decide whether a polynomial can be expressed under that form in Section 7 (Proposition 41). The remainder of Section 7 is devoted to the derandomization of several algorithms from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF][START_REF] Kayal | Affine projections of polynomials[END_REF] related to sums of powers of linear forms. We begin in Section 7.1 with the computation of linear dependencies between polynomials. Then we give applications to the minimization of the number of variables in sums of powers of linear forms (in Section 7.2), and to the computation of Lie algebras of products of linear forms (in Section 7.3). This leads to the derandomization of a factorization algorithm from [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF] and of the equivalence algorithm by Kayal [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] described in Section 3.1. The resulting equivalence algorithm runs in polynomial time for every fixed value of the degree d. For the computation of the Lie algebras of products of linear forms, we give as an intermediate result (see Proposition 47 and Remark 48) an identity testing algorithm for a certain class of rational functions (rather than polynomials as is done usually). In the commutative setting, this is to the best of our knowledge the first result of this type.

Preliminaries

This section is devoted to preliminaries from linear algebra, and more specifically to simultaneous diagonalization by congruence. We begin with complex symmetric matrices in Section 2.1 and consider real symmetric matrices in Section 2.3. Section 2.2 is devoted to some refinements that are not strictly necessary for our main algorithms (they lead to an interesting connection with semidefinite programming, though; see Theorem 14 and the remarks following it). Upon first reading, if one wishes to understand only our results for the field of complex numbers it will therefore be sufficient to read Section 2.1 only (or even just the statement of Theorem 4; the corresponding result for the field of real numbers is Theorem 10).

A proof of the following lemma for the case of two matrices can be found in [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF]. As shown in [START_REF] Koiran | Orthogonal tensor decomposition and orbit closures from a linear algebraic perspective[END_REF], the general case then follows easily. Note that this lemma is about the "usual" notion of diagonalization (by similarity) rather than by congruence (where one attempts to diagonalize a matrix A by a transformation of the form A → R T AR). That is, we say that an invertible matrix

T diagonalizes A if T -1 AT is diagonal. Lemma 1. Let A 1 , . . . , A k ∈ M n (K)
be a tuple of simultaneously diagonalizable matrices with entries in a field K, and let S ⊆ K be a finite set of size |S| > n(n -1)/2. Then there exist α 2 , . . . , α k in S such that any transition matrix which diagonalizes A 1 + α 2 A 2 + . . . + α k A k must also diagonalize all of the matrices A 1 , . . . , A k .

See Proposition 11 in Section 2.3 for an improvement of this lemma. In the next lemma we give an explicit description of a set of suitable choices for the tuple (α 2 , . . . , α k ) in Lemma 1. This description will be needed for a derandomization result in Section 7.3. Lemma 2. Let A 1 , . . . , A k ∈ M n (K) be a tuple of simultaneously diagonalizable matrices with entries in a field K. There exists a set of at most n(n -1)/2 hyperplanes of K n-1 such that the following properties hold for any point (α 2 , . . . , α n-1 ) ∈ K n-1 which does not belong to the union of the hyperplanes:

(i) Any eigenvector of A 1 + α 2 A 2 + • • • + α k A k must
also be an eigenvector of the k matrices A 1 , . . . , A k .

(ii) Any transition matrix which diagonalizes A 1 + α 2 A 2 + . . . + α k A k must also diagonalize all of the matrices A 1 , . . . , A k .

Proof. Since A 1 , . . . , A k are simultaneously diagonalizable, in order to establish (i) we may as well work in a basis where these matrices become diagonal. Let us therefore assume without loss of generality that A i = diag(λ 1i , . . . , λ ni ). For any α 2 , . . . , α n-1 , the matrix

A 1 + α 2 A 2 + • • • + α k A k is diagonal and its i-th diagonal entry is λ i1 +α 2 λ i2 +• • •+α k λ ik .
It therefore suffices to avoid the (proper) hyperplanes of K n-1 of the form:

λ i1 + α 2 λ i2 + • • • + α k λ ik = λ j1 + α 2 λ j2 + • • • + α k λ jk
where (i, j) ∈ [n] 2 ranges over all the pairs such that (λ i1 , . . . , λ ik ) = (λ j1 , . . . , λ jk ). Indeed, there are at most n(n -1)/2 hyperplanes of this form, and outside of their union there is no "collision of eigenvalues." More precisely, the eigenspace of

A 1 + α 2 A 2 + • • • + α k A k associated to the eigen- value λ i1 + α 2 λ i2 + • • • + α k λ ik is equal to k j=1 E ij
, where E ij denotes the eigenspace of A j associated to λ ij . In particular, any eigenvector of

A 1 + α 2 A 2 + • • • + α k A k is also an eigenvector of A 1 , . . . , A k .
Finally, we show that any point (α 2 , . . . , α n-1 ) which satisfies (i) also satisfies (ii). For any invertible matrix By (i) this implies that each column vector of T is also an eigenvector of A 1 , . . . , A k . As a result, the k matrices T -1 A i T are all diagonal.

T , T -1 (A 1 + α 2 A 2 + • • • + α k A k )T is diagonal iff all the column vectors of T are eigenvectors of A 1 + α 2 A 2 + • • • + α k A k .
We note that Lemma 1 directly follows from Lemma 2.(ii) via e.g. the Schwartz-Zippel lemma.

Simultaneous diagonalization by congruence

The following result is from Horn and Johnson [START_REF] Horn | Matrix Analysis[END_REF]. The first part is just the statement of Theorem 4.5.17(b), and the additional properties in (ii) are established in the proof of that theorem (see [START_REF] Horn | Matrix Analysis[END_REF] for details). (ii) Moreover, if C = SΛS -1 where S is nonsingular and Λ diagonal then the matrix R in (i) can be taken of the form R = S -T V T where V is unitary and commutes with Λ.

The next result generalizes Theorem 3 and provides a solution to the second part of Problem 4.5.P4 in [START_REF] Horn | Matrix Analysis[END_REF].

Theorem 4 (simultaneous diagonalization by congruence). Let A 1 , . . . , A k be complex symmetric matrices of size n and assume that A 1 is nonsingular. The k -1 matrices A -1 1 A i (i = 2, . . . , k) form a commuting family of diagonalizable matrices if and only if there are diagonal matrices Λ i and a nonsingular matrix R ∈ M n (C) such that A i = RΛ i R T for all i = 1, . . . , k.

Proof. Suppose that A i = RΛ i R T where the Λ i are diagonal and R nonsingular. Then the matrices A -1

1 A i = R -T Λ -1 1 Λ i R T indeed
form a commuting family of diagonalizable matrices. For the converse, assume that the matrices A -1 1 A i form such a family. Then these matrices are simultaneously diagonalizable, and by Lemma 1 there is a tuple (α 3 , . . . , α k ) such that any transition matrix that diagonalizes the matrix

C = A -1 1 A 2 + α 3 A -1 1 A 3 + . . . + α k A -1 1 A k diagonalizes all of the k -1 matrices C i = A -1 1 A i . Now we apply Theorem 3 to A = A 1 and B = A 2 + α 3 A 3 + . . . + α k A k . Write C = SΛS -1
where S is nonsingular and Λ diagonal. By part (ii) of Theorem 3 we can write A 1 = RDR T and B = R∆R T where R is nonsingular, D and ∆ are diagonal, R = S -T V T , V commutes with Λ and is unitary. By choice of the tuple α, we can write C i = SΛ i S -1 where Λ i is diagonal. We will show that A i = RDΛ i R T for i ≥ 2, thereby completing the proof of the theorem. First, we note that V commutes with the Λ i . Indeed, V and Λ are simultaneously diagonalizable since they commute and are diagonalizable (Λ is diagonal and V unitary). But any transition matrix which diagonalizes simultaneously V and Λ will diagonalize simultaneously V and the Λ i (this follows from the choice of α and the relations

C i = SΛ i S -1 , C = SΛS -1
). These matrices must therefore commute. We can now complete the proof: for i ≥ 2 we have

A i = A 1 C i = (S -T V T DV S -1 )(SΛ i S -1 ) = S -T V T DV Λ i S -1 . Since V commutes with Λ i , A i = S -T V T DΛ i V S -1 = RDΛ i R T as an- nounced.

A refinement of Theorem 4

In this section we give a more "invariant" formulation of Theorem 4. Note indeed that this theorem assigns a special role to A 1 . In Theorem 8 we give a formulation that depends only on the space spanned by the A i and not on the choice of a specific spanning family A 1 , . . . , A k . Some of the results in this section apply to K = R as well as K = C.

The role of A 1 in Theorem 4 could of course be played by any other invertible matrix in the tuple. As it turns out, for our k -1 matrices the commutation property alone is also independent of the choice of the invertible matrix in the tuple. More precisely, we have:

Proposition 5. Let A 1 , . . . , A k ∈ M n (K); assume that A 1 and A k are non- singular. The k -1 matrices A -1 k A i (i = 1, . . . , k -1) commute if and only if the same is true of the k -1 matrices A -1 1 A i (i = 2, . . . , k).
The proof will use the following simple fact. Lemma 6. If A and B commute and A is invertible, then A -1 and B commute as well.

Proof of Proposition 5. Suppose that the A -1 k A i commute. We can write:

(A -1 1 A i )(A -1 1 A j ) = (A -1 k A 1 ) -1 (A -1 k A i )(A -1 k A 1 ) -1 (A -1 k A j ).
It follows from our hypothesis and from Lemma 6 that the four factors on the right hand side commute. We can therefore rewrite this equation as:

(A -1 1 A i )(A -1 1 A j ) = (A -1 k A 1 ) -1 (A -1 k A j )(A -1 k A 1 ) -1 (A -1 k A i ),
and now the right hand side is equal to

(A -1 1 A j )(A -1 1 A i ).
Let V be the space of matrices spanned by A 1 , . . . , A k . The matrices

A -1 1 A i commute if and only if A -1 1 V is a commuting subspace of M n (K).
With Proposition 5 in hand, we can characterize this property in a way that is completely independent of the choice of a spanning family A 1 , . . . , A k for V.

Theorem 7. Let V be a nonsingular subspace of matrices of M n (K) (i.e., V does not contain singular matrices only). The two following properties are equivalent:

(i) There exists a nonsingular matrix A ∈ V such that A -1 V is a commuting subspace.

(ii) For all nonsingular matrices A ∈ V, A -1 V is a commuting subspace.

Proof. Since V is nonsingular, (ii) implies (i). For the converse, assume that A -1 1 V is a commuting subspace and that A 1 , . . . , A k is a spanning family of V. Let A ∈ V be a nonsingular matrix. We can add A to our spanning family and apply Proposition 5 to (A 1 , . . . , A k , A), with A playing the role of A k in that proposition.

As a result, we can dissociate the commutativity test from the diagonalizability test in Theorem 4: Theorem 8. Let A 1 , . . . , A k be complex symmetric matrices of size n and assume that the subspace V spanned by these matrices is nonsingular. The two following properties are equivalent:

(i) There are diagonal matrices Λ i and a nonsingular matrix R ∈ M n (C) such that A i = RΛ i R T for all i = 1, . . . , k.

(ii) V satisfies the two equivalent properties of Theorem 7, and there exists an invertible B ∈ V such that the matrices B -1 A i (i = 1, . . . , k) are all diagonalizable.

Proof. Let A ∈ V be nonsingular, and suppose that there are diagonal matrices Λ i and a nonsingular matrix

R ∈ M n (C) such that A i = RΛ i R T for all i.
Note that we have the same form for A, i.e., A = RΛR T with Λ diagonal.

As a result, we may assume without loss of generality that A is one of the matrices in the tuple A 1 , . . . , A k (we add it if necessary), and we may even assume that A = A 1 . We may then take B = A by Theorem 4.

Let us now prove the converse. We therefore assume that V satisfies the two properties of Theorem 7, and that B ∈ V is an invertible matrix such the matrices B -1 A i (i = 2, . . . , k) are all diagonalizable. From property (ii) in Theorem 7 it follows that the matrices B -1 A i commute. We conclude by applying Theorem 4 to the tuple (B, A 1 , . . . , A k ).

Real matrices

Here we study the existence of decompositions similar to those of Theorem 3 and Theorem 4 for real matrices. We begin with a real version of Theorem 3. (ii) Moreover, if C = SΛS -1 where S is a real nonsingular matrix and Λ diagonal then the matrix R in (i) can be taken of the form R = S -T V T where V is orthogonal and commutes with Λ.

Proof. If a decomposition of the pair (A, B) as in (i) exists, it is clear that C must be diagonalizable with real eigenvalues since C = R -T D -1 ∆R T . The converse and part (ii) can be obtained by a straightforward adaptation of the proof of Theorem 4.5.17(b) in [START_REF] Horn | Matrix Analysis[END_REF].

The next result generalizes Theorem 9 and provides a real version of Theorem 4.

Theorem 10 (simultaneous diagonalization by congruence). Let A 1 , . . . , A k be real symmetric matrices of size n and assume that A 1 is nonsingular. The k -1 matrices A -1

1 A i (i = 2, . . . , k) form a commuting family of diagonalizable matrices with real eigenvalues if and only if there are real diagonal matrices Λ i and a nonsingular matrix R ∈ M n (R) such that A i = RΛ i R T for all i = 1, . . . , k.

Proof. The proof of Theorem 4 applies almost verbatim: we just need to work everywhere with real matrices instead of complex matrices (and with real coefficients α i ), and appeal to Theorem 9 instead of Theorem 3. There is just one point in the proof where a little care is needed. Namely, in the proof of Theorem 4 we used the fact that Theorem 3.(ii) provides us with a unitary matrix V , and that unitary matrices are diagonalizable. In the real case we get an orthogonal matrix instead (as per Theorem 9.(ii)), and orthogonal matrices are not necessarily diagonalizable over R. Nevertheless, real orthogonal matrices are diagonalizable over C since they are unitary. We can therefore conclude like in the proof of Theorem 4 that our real orthogonal matrix V commutes with the Λ i . The remainder of the proof is unchanged.

In the proofs of Theorems 4 and 10 we have used the fact that V is a unitary matrix. These arguments can be somewhat simplified at the expense of proving the following improvement to Lemma 1. First we recall that the centralizer of a matrix M , denoted Z(M ), is the subspace of matrices that commute with M . Proposition 11. Let A 1 , . . . , A k and α 2 , . . . , α k be as in Lemma 1; let

A = A 1 + α 2 A 2 + . . . + α k A k . Then Z(A) = k i=1 Z(A i ).
This result applies to real as well as complex matrices. Before giving the proof, let us explain how it can be used in Theorems 4 and 10. Applying Proposition 11 to the tuple of simultaneously diagonalizable matrices C 2 , . . . , C k , we see that

Z(C) = k i=2 Z(C i ). Since C i = SΛ i S -1 and C = SΛS -1 , this implies Z(Λ) = k i=2 Z(Λ i ). Since V ∈ Z(Λ)
, we conclude that V commutes with the Λ i . Therefore, we have established this commutation property without using the fact that V can be taken unitary.

Proof of Proposition 11. The inclusion from right to left obviously holds for any choice of the α i . For the converse, let B ∈ Z(A) and assume as a first step that B is diagonalizable. Since A and B commute and both matrices are diagonalizable, there exists a transition matrix T such that T -1 AT and T -1 BT are diagonal. By choice of the α i , all of the matrices T -1 A i T are diagonal as well. We conclude that B and A i commute since they are simultaneously diagonalizable. To complete the proof, we just need to observe that diagonalizable matrices are dense in Z(A). This follows from the fact that A itself is diagonalizable (observe indeed that the centralizer of a diagonal matrix takes a block-diagonal from, and diagonalizable matrices are dense in each block).

Like in the complex case, we can dissociate the commutativity test in Theorem 10 from the diagonalizability test: Theorem 12. Let A 1 , . . . , A k be real symmetric matrices of size n and assume that the subspace V spanned by these matrices is nonsingular. The two following properties are equivalent:

(i) There are diagonal matrices Λ i and a nonsingular matrix R ∈ M n (R) such that A i = RΛ i R T for all i = 1, . . . , k.

(ii) V satisfies the two equivalent properties of Theorem 7, and there exists an invertible B ∈ V such that the matrices B -1 A i (i = 2, . . . , k) are all diagonalizable with real eigenvalues.

The proof is identical to the proof of Theorem 8, except that we appeal to Theorem 10 instead of Theorem 4. The criterion in Theorem 12 takes a particularly simple form when V contains a positive definite matrix. Before explaining this, we recall the following lemma. Lemma 13. Let A and B be two real symmetric matrices with B positive definite. Then B -1 A is diagonalizable with real eigenvalues.

Proof. Since B is positive definite, we can write B = HH T where H is a real invertible matrix. Hence

B -1 A = H -T H -1 A = H -T (H -1 AH -T )H T . Since H -1 AH -T is real symmetric it is diagonalizable with real eigenvalues.
This is true of B -1 A as well since the two matrices are similar.

As an immediate consequence of Lemma 13 and Theorem 12 we have: Theorem 14 (simultaneous diagonalization by congruence, positive definite case). Let A 1 , . . . , A k be real symmetric matrices of size n and assume that the subspace V spanned by these matrices contains a positive definite matrix. The 3 following properties are equivalent:

(i) There exists a nonsingular matrix A ∈ V such that A -1 V is a commuting subspace.

(ii) For all nonsingular matrices A ∈ V, A -1 1 V is a commuting subspace.

(iii) There are real diagonal matrices Λ i and a nonsingular matrix R ∈ M n (R) such that A i = RΛ i R T for all i = 1, . . . , k.

A related characterization can be found in [START_REF] Jiang | Simultaneous diagonalization of matrices and its applications in quadratically constrained quadratic programming[END_REF]Theorem 3.3]. As we will see at the end of Section 3, the significance of Theorem 14 is that when a polynomial is equivalent to a sum of n real cubes, the corresponding V always contains a positive definite matrix.

The equivalence problem

In this section we review Kayal's equivalence algorithm and present our tensor-based approach. We first recall the following definition from the introduction.

Definition 15. A polynomial f ∈ K[x 1 , . . . , x n ] is said to be equivalent to a sum of n d-th powers if f (x) = P d (Ax) where P d (x 1 , . . . , x n ) = x d 1 + . . . + x d n and A ∈ M n (K) is a nonsingular matrix.
As explained before, our equivalence algorithms in Sections 4 and 5 deal only with the case d = 3 (equivalence to a sum of cubes). More generally, one could ask whether two forms of degree 3 given as input are equivalent (by an invertible change of variables as above). This problem is known to be at least as hard as graph isomorphism [START_REF] Agrawal | Equivalence of F-algebras and cubic forms[END_REF][START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] and is "tensor isomorphism complete" [START_REF] Grochow | Isomorphism problems for tensors, groups, and cubic forms: completeness and reductions[END_REF]. By contrast, equivalence of quadratic forms is "easy": it is classically known from linear algebra that two real quadratic forms are equivalent iff they have the same rank and signature (this is "Sylvester's law of inertia") and two quadratic forms over C n are equivalent iff they have the same rank. 4Note that when K = R, Definition 15 requires the changes of variables matrix A as well as the input polynomial f to be real. It also makes sense to ask if an input f ∈ R[x 1 , . . . , x n ] is equivalent to a sum of n cubes as a complex polynomial. The following example shows that these are two distinct notions of equivalence.

Example 16. Consider the real polynomial

f (x 1 , x 2 ) = (x 1 + ix 2 ) 3 + (x 1 -ix 2 ) 3 = 2x 3 1 -6x 1 x 2 2 .
This decomposition shows that as a complex polynomial, f is equivalent to a sum of two cubes. Moreover, there is no decomposition as a sum of 2 cubes of real linear forms since the above decomposition is essentially the unique decomposition of f . This follows from Corollary 20 below: in any other decomposition f = l 3 1 + l 3 2 , the linear forms l 1 and l 2 must be scalar multiples of x 1 + ix 2 and x 1 -ix 2 .5 Note that this is very different from the case of degree 2 forms: any real quadratic form in n variables can be written as a linear combinations of n real squares.

A similar example shows that for a polynomial f (x 1 , x 2 ) with rational coefficients, equivalence to a sum of two cubes over Q or other R are distinct notions:

Example 17. Consider the rational polynomial

f (x 1 , x 2 ) = (x 1 + √ 2x 2 ) 3 + (x 1 - √ 2x 2 ) 3 = 2x 3 1 + 12x 1 x 2 2 .
This polynomial is equivalent to a sum of two cubes over R but not over Q.

Review of Kayal's equivalence algorithm

Let f ∈ C[x 1 , . . . , x n ] be a homogeneous polynomial of degree d ≥ 3.
Recall that the Hessian matrix of f is the symmetric matrix of size n with entries ∂ 2 f /∂x i ∂x j , and that the Hessian determinant of f , denoted H f , is the determinant of this matrix. Kayal's equivalence algorithm is based on the factorization properties of the Hessian determinant. Note that

H f = [d(d -1)] n (x 1 • • • x n ) d-2 for f = P d .
It is shown in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] that we still have a factorization as a product of linear forms after an invertible change of variables:

Lemma 18. Suppose that f (x 1 , . . . , x n ) = n i=1 a i l i (x 1 , . . . , x n ) d
where the l i are linear forms and a i ∈ C \ {0}. The Hessian determinant of f is of the form

H f (x 1 . . . , x n ) = c n i=1 l i (x 1 , . . . , x n ) d-2
for some constant c. Moreover, c = 0 iff the l i are linearly independent.

As a consequence we have the uniqueness result of Corollary 20 below, which generalizes Corollary 5.1 in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. First, we need the following lemma: Lemma 19. Suppose that f can be written as in (1) as a sum of powers of linearly independent linear forms. If r ≥ 1 then f is not identically zero.

Proof. We already know this for r = n: Lemma 18 shows that H f is not identically 0. For a more direct proof of the result in this case, one can simply observe that f is equivalent to P d but P d is not equivalent to 0.

The general case can be reduced to the case r = n by setting n -r of the variables of f to 0. In this way, we obtain a sum of powers of r linear forms l i in r variables, Moreover, it is always possible to choose the variables of f that are set to 0 so that the l i remain linearly independent like the forms l i in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF]. Indeed, this follows from the fact that a r × n matrix of rank r must contain a r × r submatrix of rank r.

Corollary 20. Suppose that f (x 1 , . . . , x n ) = r i=1 l i (x 1 , . . . , x n ) d where the l i are linearly independent linear forms. For any other decomposition f (x 1 , . . . , x n ) = r i=1 i (x 1 , . . . , x n ) d the linear forms i must satisfy i = ω i l π(i) where ω i is a d-th root of unity and π ∈ S n a permutation.

Proof. Consider first the case r = n. By Lemma 18 and uniqueness of factorization we must have i = c i l π(i) for some constants c i and some permutation π. Plugging this relation into the two decompositions of f shows that:

n i=1 l d i = n i=1 c d i l d π(i) .
Moving all terms to the left-hand side we obtain:

n i=1 (1 -c d π -1 (i) )l d i = 0,
and Lemma 19 then implies that c d i = 1 for all i. Assume now that r < n. Since the l i are linearly independent, we can extend this family into a family of n linearly independent linear forms l 1 , . . . , l n . Our two decompositions of f yield two decompositions for the polynomial g = f + l d r+1 + • • • + l d n , and we can apply the result for the case r = n to g. Another way to reduce to this case would be to decrease n by setting n -r of the variables of f to 0 as in the proof of Lemma 19.

Kayal's algorithm can be summarized by the 3 following steps. It takes as input a degree d form f ∈ K[x 1 , . . . , x n ] and determines whether f is equivalent to

P d over K, where K ⊆ K are two subfields of C. If f is equiva- lent to P d it determines linearly independent linear forms i ∈ K[x 1 , . . . , x n ] such that f (x 1 , . . . , x n ) = n i=1 i (x 1 , . . . , x n ) d .
This presentation generalizes slightly [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], which focuses on the case K = K = C.

1. Check that the Hessian determinant H f is not identically 0 and can be factorized in

K[x 1 , . . . , x n ] as H f (x 1 . . . , x n ) = c n i=1 l i (x 1 , . . . , x n ) d-2
where the l i are linear forms and c ∈ K. If this is not possible, reject.

Try to find constants

a i ∈ K such that f (x 1 , . . . , x n ) = n i=1 a i l i (x 1 , . . . , x n ) d .
If this is not possible, reject.

3. Check that all the a i have d-th roots in K. If this is not the case, reject.

Otherwise, declare that f is equivalent to P d over K and output the linear forms i = α i l i where α d i = a i and α i ∈ K.

The correctness of the algorithm follows from Lemma 18 and Corollary 20.

Note in particular that if the algorithm accepts, the forms l i must be linearly independent (or else H f would be identically 0 by Lemma 18, and the algorithm would have rejected at step 1); and the constants a i at step 2 are unique if they exist. For d = 3, or more generally for small degree, the constants a i at step 2 can be found efficiently by dense linear algebra assuming an algebraic model of computation (for the Turing machine model, see the comments below). For large d we can instead evaluate f and the powers l d i at random points (see Section 7 on linear dependencies or [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] for details).

At step 1, the Hessian determinant can be factorized by Kaltofen's algorithm [START_REF] Kaltofen | Factorization of polynomials given by straight-line programs[END_REF] for the factorization of arithmetic circuits as suggested in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], or by the black box factorization algorithm of Kaltofen and Trager [START_REF] Kaltofen | Computing with polynomials given by black boxes for their evaluations: Greatest common divisors, factorization, separation of numerators and denominators[END_REF]. These two algorithms assume access to an algorithm for the factorization of univariate polynomials (one of the algorithms in [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF] reduces instead to the closely related task of matrix diagonalization). For K = K = C one can just assume the ability to factor univariate polynomials as part of our computation model. This yields a polynomial time algorithm, which is clearly not designed to run on a Turing machine. Another option is to take K = K = Q, and we obtain a polynomial time algorithm for the Turing machine model.

Assume now that K = Q, K = C and that we wish to design again an algorithm for the Turing machine model. As mentioned in Section 1.1, a natural approach would be to factor H f symbolically at step 1, i.e., to construct an extension K of Q of finite degree where we can find the coefficients of the linear forms l i . The linear algebra computations of step 2 would then be carried out symbolically in K . It is not clear that this approach yields a polynomial time algorithm even for d = 3 because these computations could possibly take place in an extension of exponential degree (recall indeed that the splitting field of a univariate polynomial of degree r may be of degree as high as r!). We provide polynomial time algorithms for this problem (and for K = R) in Sections 4 and 5. In order to stay closer to Kayal's original algorithm, a plausible approach would be to stop his algorithm at step 1. Note indeed that step 3 is not necessary for K = C, and it is not immediately clear whether step 2 is necessary. Namely, it is not obvious whether there are polynomials that pass the factorization test of step 1 but fail at step 2. This led us to the following question:

Question 1. Let f ∈ C[x 1 , . . . , x n ] be a homogeneous polynomial of degree d ≥ 3. If the Hessian determinant of f is equal to (x 1 x 2 • • • x n ) d-2 , must f be of the form f (x 1 , . . . , x n ) = α 1 x d 1 + • • • + α n x d n ?
A positive answer would yield a polynomial time decision algorithm for the equivalence problem since the existence of a suitable factorization at step 1 can be decided in polynomial time [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF]. Representation of polynomials by Hessian determinants has proved to be a delicate topic: see [START_REF] Gondim | On cubic hypersurfaces with vanishing Hessian[END_REF] for a famous mistake by Hesse about his eponymous determinant. Hesse's mistake was about polynomials with vanishing Hessian, a topic that remains of interest to this day [START_REF] Huang | Vanishing Hessian, wild forms and their border VSP[END_REF]. One of the authors of [START_REF] Huang | Vanishing Hessian, wild forms and their border VSP[END_REF] came accross Question 1 in an earlier version of the present paper, and managed to obtain a negative answer for many cases of interest [START_REF] Ventura | On a question of Koiran and Skomra[END_REF]: n ≥ 2 and d ≥ 4 even, or n ≥ 3 and 3 ≤ d ≤ n, or n ≥ 3 and and d = kn for some k > 1. The approach pursued in our paper, based on simultaneous diagonalization by congruence, therefore remains the only way of testing equivalence to a sum of cubes over C in polynomial time. We now present this approach in detail.

Equivalence by tensor decomposition

In the remainder of this section we explain our approach to the equivalence problem. Like in most of the paper, we work in a field K which is either the field of real or complex numbers. Recall that we can associate to a symmetric tensor T of order 3 the homogeneous polynomial f (x 1 , . . . , x n ) = n i,j,k=1 T ijk x i x j x k . This correspondence is bijective, and the symmetric tensor associated to a homogeneous polynomial f can be obtained from the relation:

∂ 3 f ∂x i ∂x j ∂x k = 6T ijk . (3)
The i-th slice of T is the symmetric matrix T i with entries (T i ) jk = T ijk . By abuse of language, we will also say that T i is the i-th slice of f . Note that (3) is the analogue of the relation

∂ 2 q ∂x i ∂x j = 2Q ij
which connects the entries of a symmetric matrix Q to the partial derivatives of the quadratic from q(x) = x T Qx. Comparing these two equations shows that the matrix of the quadratic form ∂f /∂x k is equal to 3T k .

Remark 21. The slices of a polynomial of the form

g(x 1 , . . . , x n ) = α 1 x 3 1 + . . . + α n x 3 n ( 4
)
are the diagonal matrices diag(α 1 , 0, . . . , 0), . . . , diag(0, . . . , 0, α n ). Conversely, if all the slices of a degree 3 homogeneous polynomial g are diagonal then g must be of the above form (in particular, such a g is equivalent to a sum of n cubes iff the coefficients α i are all nonzero; this follows from the fact that for K ∈ {R, C}, any element of K has a cube root in K). Indeed, the presence of any other monomial in g would yield an off-diagonal term in some slice: for the monomial m = x 2 i x j with i = j we have ∂m/∂x i = 2x i x j and for m = x i x j x k with all indices distinct we have ∂m/∂x i = x j x k .

In light of Definition 15, it is important to understand how slices behave under a linear change of variables. This was done for symmetric and ordinary tensors in [42, Section 2.1 and Proposition 48]. In particular, for symmetric tensors the following result can be obtained from (3): Proposition 22. Let g be a degree 3 form with slices S 1 , . . . , S n and let f (x) = g(Ax). The slices T 1 , . . . , T n of f are given by the formula:

T k = A T D k A where D k = n i=1 a ik S i
and the a ik are the entries of A. In particular, if g is as in (4) we have D k = diag(α 1 a 1k , . . . , α n a nk ).

A similar property appears in the analysis of Jennrich's algorithm [START_REF] Moitra | Algorithmic aspects of machine learning[END_REF]Lemma 3.3.3]. The action on slices given by the formula T k = A T D k A in this proposition seems at least superficially related to the action on tuples of symmetric (and antisymmetric) matrices studied by Ivanyos and Qiao [START_REF] Ivanyos | Algorithms based on*-algebras, and their applications to isomorphism of polynomials with one secret, group isomorphism, and polynomial identity testing[END_REF]. They consider an action of GL n sending a tuple (S 1 , . . . , S m ) to the tuple (T 1 , . . . , T m ) where T i = A T S i A. Two tuples are said to be isometric if there exists an invertible matrix A realizing this transformation. Some of the main differences with our setting are:

(i) The number of elements in our matrix tuples is the same as the dimension n of the matrices, but in their setting m and n are unrelated.

(ii) The matrices in our tuples must come from a symmetric tensor but they allow arbitrary tuples of symmetric matrices.

(iii) They act independently on each component of a matrix tuple, whereas we "mix" components with the transformation D k = n i=1 a ik S i . In spite of this difference, the actions on the space of matrices spanned by the tuple's components are the same, see Lemma 23 below.

Also we note that their algorithm for isometry testing is not algebraic since it requires the construction of field extensions as explained e.g. in the paragraph on the representation of fields and field extensions in [START_REF] Ivanyos | Algorithms based on*-algebras, and their applications to isomorphism of polynomials with one secret, group isomorphism, and polynomial identity testing[END_REF]. 6Lemma 23. Let f (x 1 , . . . , x n ) and g(x 1 , . . . , x n ) be two forms of degree 3 such that f (x) = g(Ax) for some nonsingular matrix A.

(i) If U and V denote the subspaces of M n (K) spanned respectively by the slices of f and g, we have U = A T VA.

(ii) In particular, for g = P 3 the subspace V is the space of diagonal matrices and U is a nonsingular subspace, i.e., it is not made of singular matrices only.

Proof. Proposition 22 shows that U ⊆ A T VA. Since g(x) = f (A -1 x), the same argument shows that V ⊆ A -T UA -1 . The inclusion U ⊆ A T VA therefore cannot be strict. The second part of the lemma follows immediately from the first and from Remark 21.

For the next theorem, we recall from the beginning of Section 3.2 that one may take either K = R or K = C. Theorem 24. A degree 3 form f ∈ K[X 1 , . . . , X n ] is equivalent to a sum of n cubes if and only if its slices T 1 , . . . , T n span a nonsingular matrix space and the slices are simultaneously diagonalizable by congruence, i.e., there exists an invertible matrix

Q ∈ M n (K) such that the n matrices Q T T i Q are diagonal.
Proof. Let U be the space spanned by T 1 , . . . , T n . If f is equivalent to a sum of n cubes, Proposition 22 shows that the slices of f are simultaneously diagonalizable by congruence and Lemma 23 shows that U is nonsingular.

Let us show the converse. Since the slices are simultaneously diagonalizable by congruence, there are diagonal matrices Λ k and a nonsingular matrix algebraic algorithm is known for semi-definite programming (famously, this is already an open problem for linear programming). For this reason, the equivalence algorithms of this paper will be based on Corollary 25 rather than Theorem 26.

Randomized equivalence algorithm

As a test for equivalence to a sum of n cubes, Corollary 25 is not quite satisfactory due to the hypothesis on T 1 (note indeed that this hypothesis is not even satisfied by f = P 3 ). This restriction can be overcome by performing a random change of variables before applying Corollary 25. This yields the following simple randomized algorithm with one-sided error. The input is a degree 3 form f ∈ K[x 1 , . . . , x n ]. We recall from Section 3.2 that K = R or K = C (except in Proposition 27 where any field of characteristic 0 is allowed).

1. Pick a random matrix R ∈ M n (K) and set h(x) = f (Rx).

2. Let T 1 , . . . , T n be the slices of h.

If T 1 is singular, reject. Otherwise, compute T 1 = T -1 1 .
3. If the matrices T 1 T k commute and are all diagonalizable over K, accept. Otherwise, reject.

Before proving the correctness of this algorithm, we explain how the diagonalizability test at step 3 can be implemented efficiently with an algebraic algorithm. This can be done thanks to the following classical result from linear algebra (see e.g. [28, Corollary 3.3.8] for the case K = C).

Proposition 27. Let K be a field of characteristic 0 and let χ M be the characteristic polynomial of a matrix M ∈ M n (K). Let P M = χ M /gcd(χ M , χ M ) be the squarefree part of χ M . The matrix M is diagonalizable over K iff P M (M ) = 0. Moreover, in this case M is diagonalizable over K iff all the roots of P M lie in K.

Over the field of complex numbers it therefore suffices to check that P M (M ) = 0. Over R, we need to check additionally that all the roots of P M are real. This can be done for instance with the help of Sturm sequences, which can be used to compute the number of roots of a real polynomial on any real (possibly unbounded) interval. Alternatively, the number of real roots of a real polynomial can be obtained through Hurwitz determinants [46, Corollary 10.6.12], and is given by the signature of the Hermite quadratic form [START_REF] Basu | Algorithms in Real Algebraic Geometry[END_REF]Theorem 4.48]. The arithmetic cost of these methods is polynomially bounded, and they can also be implemented to run in polynomial time in the bit model. 7Theorem 28. If an input f ∈ K[X 1 , . . . , X n ] is accepted by a run of the above randomized algorithm then f must be equivalent to a sum of n cubes.

Conversely, if f is equivalent to a sum of n cubes then f will be accepted with high probability over the choice of the random matrix R at step 1. More precisely, if the entries r ij are chosen independently at random from a finite set S the input will be accepted with probability at least 1 -2n/|S|.

Proof. Assume that f is accepted for some choice of R ∈ M n (C). Since T 1 is invertible, it follows from Proposition 22 that R must be invertible as well. Moreover, h must be equivalent to a sum of n cubes by Corollary 25. The same is true of f since f (x) = h(R -1 x).

For the converse, assume that f is equivalent to a sum of n cubes. We can obtain the slices T k of h from the slices S k of f by Proposition 22, namely, we have

T k = R T D k R where D k = n
i=1 r ik S i and the r ik are the entries of R. Therefore T 1 is invertible iff R and D 1 are invertible. By Lemma 23.(ii) there is a way to choose the entries r i1 so that D 1 is invertible. In fact, D 1 will be invertible for most choices of these entries. This follows from the fact that as a polynomial in the entries r 11 , . . . , r n1 , det(D 1 ) is not identically zero. Therefore, by the Schwartz-Zippel lemma D 1 will fail to be invertible with probability at most n/|S|. Likewise, R will fail to be invertible with probability at most n/|S| and the result follows from the union bound.

Remark 29. In Theorem 28 and in the corresponding algorithm, we can reduce the amount of randomness by picking random matrices R of the following special form: R is lower triangular with 1's on the diagonal (except possibly for r 11 ), r 11 , . . . , r n1 are drawn independently and uniformly from S, and all the other entries are set to 0. The same analysis as before shows that D 1 will fail to be invertible with probability at most n/|S|. Moreover, R will fail to be invertible with probability at most 1/|S| since det(R) = r 11 . By the union bound, f will be accepted with probability at least 1 -(n + 1)/|S|.

We will use a similar construction in the deterministic algorithm of the next section.

Deterministic equivalence algorithm

In the analysis of our randomized algorithm we have invoked the Schwartz-Zippel lemma to argue that a polynomial of the form

H(r 1 , . . . , r n ) = det(r 1 S 1 + . . . + r n S n )
does not vanish for most of the random choices r 1 , . . . , r n (recall from the proof of Theorem 28 that S 1 , . . . , S n denoted the slices of f ). In this section we will obtain obtain our deterministic equivalence algorithm by derandomizing this step. Namely, we will use the fact that we are not trying to solve an arbitrary instance of symbolic determinant identity testing: as it turns out, the polynomial H can be factored as a product of linear forms. This fact was already at the heart of Kayal's equivalence algorithm. Indeed, his algorithm is based on the factorization of the Hessian determinant of f [37, Lemma 5.2] and as pointed out in [START_REF] Koiran | Orthogonal tensor decomposition and orbit closures from a linear algebraic perspective[END_REF], the symbolic matrix r 1 S 1 + . . . + r n S n is a constant multiple of the Hessian. The point where we depart form Kayal's algorithm is that we do not explicitly factor H as a product of linear forms (recall indeed that this is not an algebraic step). Instead, we will use the existence of such a factorization to find deterministically a point where H does not vanish. We can then conclude as in the previous section.

First, we formally state this property of H as a lemma and for the sake of completeness we show that it follows from Proposition 22 (one can also make this argument in the opposite direction, see Section 2.1 of [START_REF] Koiran | Orthogonal tensor decomposition and orbit closures from a linear algebraic perspective[END_REF] for details).

Lemma 30. Let f be a degree 3 form with slices S 1 , . . . , S n and let H(x 1 , . . . , x n ) = det(x 1 S 1 + . . . + x n S n ). If f is equivalent to a sum of n cubes then H is not identically 0 and can be factored as a product of n linear forms.

Proof. Let A be the invertible matrix such that f (x) = P 3 (Ax). By Proposition 22, H(x) = (det A) 2 det D(x) where

D(x) = n k=1 x k D k = diag(a 11 x 1 + • • • + a 1n x n , . . . , a n1 x 1 + • • • + a nn x n ).
This gives the required factorization. In particular, H is nonzero since A is invertible.

The non vanishing of H means that the slices span a nonsingular matrix space. We have given in Theorem 24 a slightly different proof of the fact that this space is indeed nonsingular when f is equivalent to a sum of n cubes. By Lemma 30, the zero set of H is a union of n hyperplanes. We can avoid the union of any finite number of hyperplanes by a standard construction involving the moment curve γ(t) = (1, t, t 2 , . . . , t n-1 ). Lemma 31. Let M ⊆ C n be a set of (n -1)p + 1 points on the moment curve. For any set of p hyperplanes H 1 , . . . , H p ⊆ C n there is at least one point of M which does not belong to any of the H i .

Proof. Let l i (x 1 , . . . , x n ) = 0 be the equation of H i . The moment curve has at most n -1 intersections with H i since l i (1, t, t 2 , . . . , t n-1 ) is a nonzero polynomial of degree n -1. For the p hyperplanes we therefore have a grand total of p(n -1) intersection points at most.

The size of M in this lemma is the smallest that can be achieved in such a blackbox construction. Indeed, for any set of (n -1)p points one can always find a set of p hyperplanes which covers them all.

We can now describe our deterministic algorithm. As in Section 4 the input is a degree 3 form f (x 1 , . . . , x n ) with slices S 1 , . . . , S n .

1. Pick an arbitrary set M of n(n -1) + 1 points on the moment curve. 5. If the matrices T 1 T k commute and are all diagonalizable, accept. Otherwise, reject.

Theorem 32. A degree 3 form f (x 1 , . . . , x n ) is accepted by the above algorithm if and only if f is equivalent to a sum of n cubes.

Proof. As a preliminary observation, we note that if the algorithm reaches step 4 the matrix T 1 is well-defined since T 1 is invertible. Indeed, we have seen in the proof of Theorem 28 that T 1 = R T D 1 R; moreover, D 1 is invertible since the algorithm has not failed at step 2 and R is clearly invertible as well. Suppose now that an input f (x 1 , . . . , x n ) is accepted by the algorithm. The same argument as in the proof of Theorem 28 shows that f is equivalent to a sum of n cubes. Namely, h must be equivalent to a sum of n cubes by Corollary 25. The same is true of f since R is an invertible matrix.

For the converse, suppose that an input f (x 1 , . . . , x n ) is equivalent to a sum of n cubes. By Lemma 30 and Lemma 31, there exists a point r ∈ M where the polynomial H(r) = det(r 1 S 1 + . . . + r n S n ) does not vanish. As a result, the algorithm will not reject at step 2. Since the matrix R constructed at step 3 is invertible, the polynomial h at step 4 is equivalent to a sum of n cubes and the algorithm will accept at step 5 by Corollary 25.

Remark 33. Some of the results in the paper by Ivanyos and Qiao [START_REF] Ivanyos | Algorithms based on*-algebras, and their applications to isomorphism of polynomials with one secret, group isomorphism, and polynomial identity testing[END_REF] mentioned after Proposition 22 are motivated by an application to symbolic determinant identity testing (SDIT). In our setting we only need to consider very simple determinants (as explained at the beginning of this section, they factor as a product of linear forms). As a result we can use the simple black box solution provided by Lemma 31. More connections between group actions and SDIT can be found in [START_REF] Garg | A deterministic polynomial time algorithm for non-commutative rational identity testing[END_REF][START_REF] Ivanyos | Constructive non-commutative rank computation is in deterministic polynomial time[END_REF][START_REF] Ivanyos | Non-commutative Edmonds' problem and matrix semi-invariants[END_REF].

Polynomial Identity Testing

It is a basic fact that black box PIT for a class of polynomials C is equivalent to constructing a hitting set for C, i.e., a set of points H such that every polynomial in C which vanishes on all points of H must vanish identically. Indeed, from a hitting set we obtain a black box PIT algorithm by querying the input polynomial f at all points of H. Conversely, for any black box PIT algorithm the set of points queried on the input f ≡ 0 must form a hitting set. Note that the validity of this simple argument depends on the hypothesis that 0 ∈ C (otherwise we can declare that f ≡0 without making any query).

In this section we first consider the following scenario. An algorithm is provided with black box access to a polynomial f that is either identically 0 or equivalent to P d , and must decide in which of these two categories its input falls (note that these are indeed two disjoint cases). This is equivalent to constructing a hitting set for the equivalence class of P d , a task that we carry out in Section 6.1. Then in Section 6.2 we generalize this hitting set construction to a larger class of polynomials, namely, those that can be written as sums of d-th powers of linearly independent linear forms.

A hitting set for the equivalence class of P d

Here we construct a polynomial size hitting set for the set of polynomials f ∈ C[X 1 , . . . , X n ] that are equivalent to P d . Let S = {s 0 , s 1 , . . . , s d } be a set of d + 1 complex numbers with s 0 = 0. We denote by S i the set of points (x 1 , . . . , x n ) ∈ C n with x i ∈ S and all other coordinates equal to 0. Pick an arbitrary nonzero point p ∈ C n , and form the set

G p = p + n i=1 S i , of size nd + 1.
Proposition 34. For any d ≥ 2 and any nonzero point p ∈ C n , G p is a hitting set for the set of polynomials f ∈ C[X 1 , . . . , X n ] that are equivalent to P d .

Proof. Let f (x) = P d (Ax) where A is an invertible matrix. The proof is based on the fact that the gradient ∇f = (∂f /∂x 1 , . . . , ∂f /∂x n ) does not vanish anywhere except at x = 0. Indeed, this property clearly holds true for P d , and is preserved by an invertible change of variables since

∇f (x) = A T ∇P d (Ax) (5)
by the chain rule. In particular, ∇f (p) = 0 since p = 0. This implies that f does not vanish on all of G p . Indeed, if f vanishes on p + S i then f vanishes on the whole line going through p + S i , hence ∂f ∂x i (p) = 0.

Let K be a subfield of C. The same construction yields a hitting set for the set of polynomials in K[x 1 , . . . , x n ] that are equivalent to a polynomial of the form n i=1 a i x d i where a i ∈ K \ {0}. Such polynomials are indeed equivalent to P d as complex polynomials.

Fewer powers

We now give a black box PIT algorithm for a bigger class of polynomials, namely, those that can be written as sums of d-th powers of linearly independent linear forms. These polynomials therefore admit decompositions as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] where the forms l i are linearly independent and the number r ≤ n of forms in the decomposition is unknown. We will generalize the approach from Section 6.1. In particular, we will see that the gradient of f does not vanish outside of a certain (unknown) linear subspace V . We can find deterministically a point outside of V with the help of the moment curve like in Section 5. This leads to the construction of the following hitting set: for an arbitrary set M of n points on the moment curve, we construct the union of the G p 's as p ranges over M (recall that G p is the hitting set of Section 6.1). This set G ⊆ C n is of size n(nd + 1).

Theorem 35. For any d ≥ 2, G is a hitting set for the set of polynomials f ∈ C[X 1 , . . . , X n ] that can be written as sums of d-th powers of linearly independent linear forms.

Proof. Suppose that f can be written as a sum of r d-th powers for some r ≥ 1. We have f (x) = P d,r (Ax) where A is an invertible matrix and

P d,r (x 1 , . . . , x n ) = x d 1 + • • • + x d r .
We will use the fact that the gradient of f vanishes only on a (proper) linear subspace V of dimension n -r. This property clearly holds true for P d,r , and it is preserved for f since we now have

∇f (x) = A T ∇P d,r (Ax)
instead of [START_REF] Bernardi | Computing symmetric rank for symmetric tensors[END_REF]. By Lemma 31, M contains at least one point p lying outside of V . At this point ∇f (p) = 0, and the same argument as in the proof of Proposition 34 shows that f does not vanish on G p .

Linear dependencies, essential variables and Lie algebras

In this section we build on the results from Section 6 to derandomize several algorithms from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF][START_REF] Kayal | Affine projections of polynomials[END_REF]. We begin in Section 7.1 with the computation of linear dependencies between polynomials. Then we give applications to the minimization of the number of variables in sums of powers of linear forms (in Section 7.2), and to the computation of Lie algebras of products of linear forms (in Section 7.3). This leads to the derandomization of a factorization algorithm from [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF] and of the equivalence algorithm by Kayal [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] described in Section 3.1.

From black box PIT to linear dependencies

We first recall from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] the notion of linear dependencies among polynomials.

It has found applications to the elimination of redundant variables [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], the computation of the Lie algebra of a polynomial [START_REF] Kayal | Affine projections of polynomials[END_REF], the reconstruction of random arithmetic formulas [START_REF] Gupta | Random arithmetic formulas can be reconstructed efficiently[END_REF], full rank algebraic programs [START_REF] Kayal | Reconstruction of full rank algebraic branching programs[END_REF] and nondegenerate depth 3 circuits [START_REF] Kayal | Reconstruction of non-degenerate homogeneous depth three circuits[END_REF].

Definition 36. Let f = (f 1 , . . . , f m ) be a tuple of m polynomials of K[X 1 , . . . , X n ]. The space of linear dependencies of f , denoted f ⊥ , is the space of all vectors v = (v 1 , . . . , v m ) ∈ K m such that v 1 f 1 + • • • + v m f m is identically 0.
As a computational problem, the POLYDEP problem consists of finding a basis of f ⊥ for a tuple f given as input. If the f i are verbosely given as sum of monomials, this is a simple problem of linear algebra. The problem becomes more interesting if the f i are given by arithmetic circuits or black boxes. In Section 7.1 we present a simple and general relation between this problem and black box PIT.

A natural approach to POLYDEP consists of evaluating the f j at certain points a 1 , . . . , a k of K n to form a k × m matrix M with the f j (a i ) as entries. Note that f ⊥ ⊆ ker(M ) for any choice of the evaluation points. We would like this inclusion to be an equality since this will allow to easily compute a basis of f ⊥ . This motivates the following definition. Definition 37. The points a 1 , . . . , a k form a hitting set for the linear dependencies of f if the above matrix M = (f j (a i )) 1≤i≤k,1≤j≤m satisfies f ⊥ = ker(M ).

Kayal [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] showed (without using explicitly this terminology) that if k = m and the a i are chosen at random, a hitting set for the linear dependencies of f will be obtained with high probability.

Here we point out that constructing deterministically a hitting set for the linear dependencies of f is equivalent to solving black box PIT for the family of polynomials in Span(f ) (the space of linear combinations of f 1 , . . . , f m ):

Proposition 38. Let f = (f 1 , . . . , f m ) be a tuple of m polynomials of K[X 1 , . . . , X n ].
For any tuple (a 1 , . . . , a k ) of k points of K n , the two following properties are equivalent:

(i) The points a 1 , . . . , a k form a hitting set for the linear dependencies of f . (ii) They form a hitting set for Span(f ).

Proof. This is immediate from the definitions. Suppose indeed that (i) holds, and that some polynomial f = v 1 f 1 + . . . + v m f m of Span(f ) vanishes at all of the a i . This means that v ∈ ker M , hence v ∈ f ⊥ by (i). We conclude that f is identically 0 and (ii) holds.

To prove the converse we can take the same steps in reverse. Suppose that (ii) holds and that v ∈ ker M . This means that f = v 1 f 1 + . . . + v m f m vanishes at all the a i , hence f is identically 0 by (ii). We have shown that v ∈ f ⊥ , i.e., f ⊥ = ker M . In Section 7.2 we will use this observation and the black box PIT algorithm of Section 6.2 to minimize the number of variables in sums of powers of linearly independent linear forms. In Section 7.3 we give an application to the computation of Lie algebras and factorization into products of linear forms.

Minimizing variables

We first recall the notion of redundant and essential variables studied by Carlini [START_REF] Carlini | Reducing the number of variables of a polynomial[END_REF] and Kayal [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. Definition 39. A variable x i in a polynomial f (x 1 , . . . , x n ) is redundant if f does not depend on x i , i.e., x i does not appear in any monomial of f . We say that f has t essential variables if t is the smallest number for which there is an invertible matrix of size n such that f (Ax) depends on t variables only.

A randomized algorithm for minimizing the number of variables is given in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]Theorem 4.1]. More precisely, if the input f has t essential variables the algorithm finds (with high probability) an invertible matrix A such that f (Ax) depends on its first t variables only. It is based on the observation from [START_REF] Carlini | Reducing the number of variables of a polynomial[END_REF][START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] that t = n -dim(∂f ) ⊥ = dim(∂f ) where ∂f denotes the tuple of n partial derivatives ∂f /∂x i (and dim(∂f ) denotes the dimension of the spanned subspace). As recalled in Section 7.1, a basis of the space of linear dependencies (∂f ) ⊥ can be found by a randomized algorithm from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. Moreover, a suitable invertible matrix A is easily found from such a basis by completing it into a basis of the whole space K n (see appendix B of [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] for details).

Example 40. If f can be written as a sum of r powers of linearly independent linear forms then the number of essential variables of f is equal to r. This is clear for f (x 1 , . . . ,

x n ) = x d 1 + • • • + x d r since ∂f is spanned by x d-1
1 , . . . , x d-1 r . In the general case, f is equivalent to x d 1 + • • • + x d r and two equivalent polynomials have the same number of essential variables.

The next proposition is a consequence of the above variable minimization algorithm. The input f to the algorithm of Proposition 41 can be described by an arithmetic circuit like in [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF] or more generally by a black box. Here we assume (in contrast with Sections 4 and 5) that we have access to an oracle for the factorization of univariate polynomials. This is a prerequisite for running Kaltofen's factorization algorithms for the arithmetic circuit [START_REF] Kaltofen | Factorization of polynomials given by straight-line programs[END_REF] and black box models [START_REF] Kaltofen | Computing with polynomials given by black boxes for their evaluations: Greatest common divisors, factorization, separation of numerators and denominators[END_REF].

Proposition 41. There is a randomized polynomial time algorithm that decides whether a homogeneous polynomial f (x 1 , . . . , x n ) can be written as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] as a sum of powers of linearly independent linear forms.

Proof. First compute the number r of essential variables in f using the randomized algorithm from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF], and make the corresponding change of variables to obtain a polynomial g(x 1 , . . . , x r ). Then test whether g is equivalent to x d 1 + • • • + x d r using the equivalence algorithm from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. To prove that this algorithm is correct, we show that f can be written as a sum of r powers of linearly independent linear forms if and only if g can be written in such a form. Let A ∈ K n×n be an invertible matrix such that f (Ax) = g(x 1 , . . . , x r ) for all x ∈ K n . Suppose that g(Bx) = x where I ∈ K (n-r)×(n-r) is the identity matrix, then the matrix AC is invertible and we have f (ACx) = g B(x 1 , . . . , x r ) T = x d 1 + • • • + x d r for every x ∈ K n . Conversely, suppose that there exists an invertible matrix

B ∈ K n×n such that f (Bx) = x d 1 + • • • + x d r .
We have r = r by Example 40. Moreover, for all x ∈ K n we have

x d 1 + • • • + x d r = f (Bx) = f (AA -1 Bx) = g (A -1 Bx) 1 , . . . , (A -1 Bx) r . Thus, by setting x r+1 = . . . = x n = 0, we get x d 1 + • • • + x d r = g(Cx)
for all x ∈ K r , where C ∈ K r×r is the submatrix of A -1 B obtained by taking the first r rows and columns. To show that C is invertible, suppose that this is not the case. Then, there exists an invertible matrix D ∈ K r×r such that D(0, . . . , 0, 1) T ∈ ker C. Hence, for every x ∈ K r we have g(CD(x 1 , . . . , x r-1 , 0) T ) = g(CDx) = h(Dx), where h

(x) = x d 1 + • • • + x d r .
In particular, h has less than r essential variables, which gives a contradiction with Example 40. Therefore, the matrix C is invertible.

In this algorithm it is essential to compute the number of essential variables in f before calling the equivalence algorithm from [START_REF] Kayal | Efficient algorithms for some special cases of the polynomial equivalence problem[END_REF]. Indeed, this algorithm is based on the factorization of the Hessian determinant of f ; but H f is identically 0 for any polynomial with fewer than n essential variables. Hence looking at det H f does not yield any useful information for r < n.

Remark 42. We can minimize the number of variables of a degree 3 form f (x 1 , . . . , x n ) in deterministic polynomial time using dense linear algebra. Indeed, as pointed out in Section 7.1 this is true more generally for the POLY-DEP problem with inputs that are verbosely given as sums of monomials. 8Combining this observation with the deterministic equivalence algorithm from Section 5 we obtain , as in Proposition 41, a deterministic algorithm to decide whether a degree 3 form can be written as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] as a sum of cubes of linearly independent (real or complex) linear forms.

The second result of this section is the following derandomization of Kayal's algorithm for finding the number of essential variables, under the assumption that the input polynomial is a sum of powers of independent linear forms: Theorem 43. Let f (x 1 , . . . , x n ) be a homogoneous polynomial of degree d and let {a 1 , . . . , a k } be the hitting set of Theorem 35 corresponding to polynomials of degree d-1 in n variables (recall that it is of size O(n 2 d)). Let f j be the partial derivative ∂f /∂x j . We consider like in Section 7.1 the matrix M = (f j (a i )) 1≤i≤k,1≤j≤n .

If f can be written as in [START_REF] Agrawal | Quasi-polynomial hitting-set for set-depth-∆ formulas[END_REF] as a sum of r powers of linearly independent linear forms then ker M = (∂f ) ⊥ . In particular, the number of essential variables of such an f can be computed deterministically from a black box for f by the formula: r = n -dim ker M .

Proof. We recall that a black box for f j can be easily obtained from a black box for f by polynomial interpolation. It therefore remains to show that ker M = (∂f ) ⊥ . By Proposition 38 it suffices to show that {a 1 , . . . , a k } is a hitting set for Span(∂f ). This is clear from the definition of {a 1 , . . . , a k } since the elements of Span(∂f ) can be written as linear combinations of at most r (d -1)-th powers of linearly independent linear forms (namely, the same forms that appear in the decomposition of f ).

Lie algebras and polynomial factorization

One can associate to a polynomial f ∈ K[X 1 , . . . , X n ] the group of invertible n × n matrices A that leave f invariant, i.e., such that f (Ax) = f (x). One can in turn associate to this matrix group its Lie algebra. This is a linear subspace of M n (K), which we call simply "the Lie algebra of f ." It turns out that elements of this Lie algebra correspond to linear dependencies between the n 2 polynomials x j ∂f ∂x i . A proof can be found in [START_REF] Kayal | Affine projections of polynomials[END_REF]Section 7.2], and we will take this characterization as our definition of the Lie algebra for the purpose of this paper: Definition 44. The Lie algebra of a polynomial f ∈ K[x 1 , . . . , x n ] is the subspace of all matrices C ∈ M n (K) that satisfy the identity:

i,j∈[n] c ij x j ∂f ∂x i = 0 .
A randomized algorithm for the computation of the Lie algebra was given in [START_REF] Kayal | Affine projections of polynomials[END_REF], with applications to the reconstruction of affine projections of polynomials. In this section we study the deterministic computation of Lie algebras of polynomials, a topic which has not been studied in the literature as far as we know.

The Lie algebra of a homogenous polynomial f consists of all matrices of M n (K) if and only if f is identically 0. This shows that one cannot hope to compute the Lie algebra in deterministic polynomial time without derandomizing Polynomial Identity Testing (and these two problems are in fact equivalent in the black box setting by Proposition 38). Nevertheless, it makes sense to search for deterministic algorithms for specific classes of polynomials. We take a first step in this direction in Theorem 49, for polynomials that factor as products of linear forms. Taking again our cue from Proposition 38, we will do this by constructing a hitting set for a related family of polynomials. As it turns out, it is convenient to first design a hitting set for a certain family of "simple" rational functions. Those are defined as follows: Definition 45. Let p 1 , . . . , p m ∈ C n , q 1 , . . . , q m ∈ C n \ {0} be a collection of 2m vectors in C n . Furthermore, let H = m i=1 {x ∈ C n : q i , x = 0}. We associate to this collection of 2m vectors an oracle which for any x ∈ C n returns the value

f (x) =        m i=1 p i , x q i , x if x / ∈ H, NaN otherwise. (6)
In the commutative setting, there does not seem to be a lot of literature on rational identity testing (there is however the deep result that rational identity testing can be done in deterministic polynomial time in the noncommutative setting [START_REF] Garg | A deterministic polynomial time algorithm for non-commutative rational identity testing[END_REF]). For (commutative) arithmetic circuits with divisions, deterministic rational identity testing is easily seen to be equivalent to PIT for ordinary (division free) arithmetic circuits. Nevertheless, it makes sense to investigate it for specific families of rational functions such as those in Definition 45.

Remark 46. According to the above definition, the oracle returns NaN when we evaluate f on a point x where q i (x) = 0, and this remains true even if the corresponding vector p i is equal to 0. This convention is useful for the proof of Proposition 47 below.

For every n, k ∈ N, let P(n, k) ⊂ C n be the set of k(n -1) + 1 points defined as

P(n, k) = {(1, 1, . . . , 1), (1, 2, 2 2 , . . . , 2 n-1 ), . . . , (1, k(n -1) + 1, (k(n -1) + 1) 2 , . . . , (k(n -1) + 1) n-1 )} .
Recall from Lemma 31 that these points cannot be all contained in a union of k hyperplanes since they lie on the moment curve. Moreover, for every m, n ≥ 1 let

Λ(m, n) = {u + λv : v ∈ P(n, m), u ∈ P(n, m 2 ) ∪ {0}, λ ∈ [2m + 1]} .
The next result shows that the set Λ(m, n) is a hitting set for the rational functions of Definition 45.

Proposition 47. The function f (x) in ( 6) is equal to 0 for every x / ∈ H if and only if f (x) ∈ {0, NaN} for every x ∈ Λ(m, n).

Proof. The "only if" implication is trivial. To prove the other direction, suppose that f (x) ∈ {0, NaN} for every x ∈ Λ(m, n). First we observe that it is enough to assume that {q 1 , . . . , q m } are pairwise linearly independent. Indeed, if q i = µq j for some i, j ∈ [m] and µ ∈ C \ {0}, then we can put pi = p i + µp j , replace p i by pi and forget p j and q j . This does not change the function f (in particular, by Remark 46 the domain of definition of f is unchanged). By repeating this procedure, we can write f in such a way that the denominators are pairwise linearly independent (and their number m does not increase).

From now on, we assume that {q 1 , . . . , q m } are pairwise linearly independent. By Lemma 31, there exists v ∈ P(n, m) such that q i , v = 0 for all i ∈ [m]. For every i ∈ [m], denote a i = p i , v / q i , v ∈ C. We will show that p i = a i q i for all i ∈ [m]. To do so, suppose that there exists at least one i such that p i -a i q i = 0. For every pair (i, j) ∈ [m] 2 such that i = j let d ij = q i , v / q j , v . Using Lemma 31 one more time, there exists u ∈ P(n, m 2 ) satisfying the following two conditions: (i) p i -a i q i , u = 0 for every i ∈ [m] such that p i -a i q i = 0;

(ii) q i -d ij q j , u = 0 for every (i, j) such that i = j. (We note that q i -d ij q j = 0 because the {q i } i are pairwise linearly independent.) Let b i = p i -a i q i , u for all i ∈ [m] and consider the univariate function g(λ) defined as g(λ) = f (u + λv). Note that for every λ ∈ C such that u + λv / ∈ H we have

g(λ) = m i=1 p i , u + λv q i , u + λv = m i=1 a i + m i=1 b i q i , u + λ q i , v .
Observe that the function g(λ) attains the value NaN for at most m values of λ. Furthermore, since we assumed that q i -d ij q j , u = 0, the functions λ → q i , u + λ q i , v have distinct zeros. In particular, if b i = 0, then |g(λ)| approaches +∞ as λ approaches -q i , u / q i , v . Since we assumed that at least one b i is nonzero, it follows that the function g(λ) attains some values not in {0, NaN}. Moreover, g(λ) has at most m zeroes, because it can be written in the form g(λ) = P (λ)/Q(λ) where P, Q are nonzero polynomials of degree at most m. In particular, at least one of the values g(1), . . . , g(2m+1)

does not belong to {0, NaN}, contradicting our assumption. Therefore, we have p i = a i q i for all i ∈ [m]. In particular, for every x / ∈ H we have f

(x) = a 1 + • • • + a m . To conclude, we observe that f (v) = 0 since v ∈ Λ(m, n). It follows that f (x) = a 1 + • • • + a m = 0 for all x / ∈ H.
Remark 48. One can derive from the above proof a syntactic characterization of the rational functions in Definition 45 that are identically 0. Namely, assuming that the q i are pairwise linearly independent, the following condition is necessary and sufficient: there exist constants a 1 , . . . , a m ∈ C such that a 1 + . . . + a m = 0 and p i = a i q i for all i = 1, . . . , m.

Let P (x) ∈ C[X 1 , . . . , X n ] be a polynomial that factors as a product of linear forms, i.e., P (x) = q 1 , x q 2 , x . . . q d , x for some vectors q 1 , . . . , q d in C n . From Proposition 47 we can derive the following characterization of the Lie algebra of P .

Theorem 49. Let P (x) ∈ C[X 1 , . . . , X n ] be a polynomial of degree d ≥ 1 that factors as a product of linear forms. Then, a matrix C ∈ C n×n belongs to the Lie algebra of P if and only if

i,j∈[n] c ij x j ∂P ∂x i (x) = 0 (7)
for every x ∈ Λ(d, n). In particular, a basis of the Lie algebra can be computed deterministically in polynomial time with black box access to P .

Proof. The "only if" direction follows immediately from Definition 44. To prove the opposite implication, let us now assume that (7) holds for every x ∈ Λ(d, n). We need to show that C belongs to the Lie algebra of f . Let us write P (x) = q 1 , x q 2 , x . . . q d , x where the q i are nonzero vectors, and consider the function

f C (x) =        1 P (x) i,j∈[n] c ij x j ∂P ∂x i (x) if x / ∈ H, NaN otherwise.
Here H denotes the union of the m hyperplanes {x ∈ C n : q i , x = 0} as in Definition 45. Note that we have f C (x) ∈ {0, NaN} for every x ∈ Λ(d, n). Furthermore, observe that for every x / ∈ H we have

1 P (x) i,j∈[n] c ij x j ∂P ∂x i (x) = i,j∈[n] c ij x j k∈[d] q ki q k , x = k∈[d] i,j∈[n] c ij q ki x j q k , x .
Since this rational fraction is of form ( 6), we can apply Proposition 47 and conclude that f C (x) is equal to zero for every x / ∈ H. This implies that i,j∈[n] c ij x j ∂P ∂x i (x) = 0 for all x / ∈ H. By continuity we obtain i,j∈[n] c ij x j ∂P ∂x i (x) = 0 for all x ∈ C n , which implies that C belongs to the Lie algebra of P .

Let us now turn to the second part of the theorem. It is well known that a black box for ∂P/∂x i can be constructed from a black box for P (by interpolating P on a line). By the first part, the determination of the Lie algebra therefore boils down to the resolution of a system of |Λ(d, n)| linear equations in n 2 variables.

Remark 50. We have stated Proposition 47 and Theorem 49 for the field of complex numbers only because the proof of Proposition 47 uses the absolute value. Nevertheless, it follows from general principles that these two results apply to any field K of characteristic 0. Indeed, K can be embedded in an algebraically closed field K which must satisfy the same first order formulas as C.

For our final derandomization results we will need to perform simultaneous diagonalization in polynomial time over Q. Proposition 51. There is a polynomial time deterministic algorithm which takes as input a tuple (A 1 , . . . , A k ) of matrices of size n with rational entries, and:

(i) decides whether A 1 , . . . , A k are simultaneously diagonalizable over Q;

(ii) if they are, constructs an invertible matrix T ∈ M n (Q) such that the k matrices T -1 A i T are all diagonal.

This result is not particularly surprising but we could not find it in the literature.

Proof. For k = 1 this is quite standard. We can for instance compute the characteristic polynomial of A 1 , compute its roots (which should all be rational) and attempt to construct a basis of eigenvectors by solving the corresponding linear systems.

For k > 1, we can check that the matrices are simultaneously diagonalizable by checking that each matrix is diagonalizable, and that the A i pairwise commute (Theorem 1.3.21 in [START_REF] Horn | Matrix Analysis[END_REF]). In this case, in order to construct a transition matrix T which diagonalizes the A i , we will use Lemma 2 to reduce to the case k = 1. Namely, we will construct a finite set S of points (α 2 , . . . , α n ) ∈ Q n-1 , and for each α ∈ S we will:

1. Diagonalize A α = A 1 + α 2 A 2 + • • • + α k A k as: A α = T α D α T -1
α , where D α is diagonal and T α invertible.

Check whether T -1

α A i T α is diagonal for all i = 1, . . . , k.

When the A i are simultaneously diagonalizable, Lemma 2.(ii) guarantees that this test will will succeed for at least one α ∈ S if S is not included in a certain union of n(n -1)/2 hyperplanes. In order to avoid these hyperplanes we can proceed as in Section 5 and pick any set S of 1 + n(n -1)(n -2)/2 points on the moment curve as per Lemma 31.

An alternative to the above algorithm can possibly be extracted from the proof of Theorem 1.3.21 in [START_REF] Horn | Matrix Analysis[END_REF].

Let f (x 1 , . . . , x n ) be a polynomial that can be written as

f (x) = λl 1 (x) α 1 • • • l n (x) αn ( 8
)
where λ is a constant, the l i are linearly independent linear forms and the exponents α i are all nonzero. A randomized algorithm which finds such a factorization from black box access to f was proposed in [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF]Section 4]. This algorithm appealed to randomization for the computation of the Lie algebra of f and also, following [START_REF] Kayal | Affine projections of polynomials[END_REF], for simultaneous diagonalization. In this paper we have given deterministic algorithms for these two tasks, in Theorem 49 and Proposition 51 respectively. This leads to the following polynomial time deterministic factorization algorithm, which we call the derandomized Liealgebraic factorization algorithm (or DerandLie for short):

1. Compute a basis B 1 , . . . , B k of the Lie algebra of f .

2. Reject if k = n -1, i.e., if the Lie algebra is not of dimension n -1.

3. Check that the matrices B 1 , . . . , B n-1 commute and are all diagonalizable over Q. If this is not the case, reject. Otherwise, declare the existence of a factorization f (x) = λl 1 (x) α 1 • • • l n (x) αn where the linear forms l i are linearly independent and α i ≥ 1 (λ, the l i and α i will be determined in the last 3 steps of the algorithm).

4. Perform a simultaneous diagonalization of the B i 's, i.e., find an invertible matrix A such that the n -1 matrices AB i A -1 are diagonal.

5. At the previous step we have found a matrix A such that g(x) = f (A -1 x) has a Lie algebra g g which is an (n -1)-dimensional subspace of the space of diagonal matrices. Then we compute the orthogonal of g g , i.e., we find a vector α = (α 1 , . . . , α n ) such g g is the space of matrices diag(d 1 , . . . , d n ) satisfying n i=1 α i d i = 0. We normalize α so that n i=1 α i = d.

6. We must have g(x) = λ.m where λ ∈ Q * and m is the monomial x α 1 1 • • • x αn n (in particular, α must be a vector with integral entries). We therefore have f (x) = λ.m(Ax) and we output this factorization.

Theorem 52. Let f (x 1 , . . . , x n ) be a polynomial that can be written as in [START_REF] Brachat | Symmetric tensor decomposition[END_REF] as a product of powers of linearly independent linear forms, where λ and the coefficients of the linear forms are in Q. From a black box for f , the above DerandLie algorithm computes this factorization deterministically in polynomial time.

See [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF]Section 4] for a correctness proof. As mentioned above, in order to obtain a deterministic algorithm we appeal to Theorem 49 in Step 1 and to Proposition 51 in Step 4. In order to find the scaling factor λ at step 6, we evaluate f at a point x where f (x) = 0. From Lemma 31, we can find such a point deterministically by trying at most 1 + n(n -1) on the moment curve since we need to avoid the n hyperplanes l i (x) = 0.

Note that DerandLie may fail if f does not factor as a product of linear forms since this is a prerequisite of Theorem 49. The fact that DerandLie fails on some inputs may seem at first sight like a weakness of the algorithm, but this is in fact unavoidable for any deterministic polynomial-time black box algorithm (see [START_REF] Koiran | Orbits of monomials and factorization into products of linear forms[END_REF]Section 1.5] for details).

Recall from Section 3.1 that Kayal's algorithm for equivalence to a sum of powers relies on factorization into products of linear forms. If this factorization is performed with the DerandLie algorithm, we obtain a deterministic version of Kayal's algorithm. Let us call LieEquivalence this deterministic equivalence algorithm. As our final result, we observe that LieEquivalence will work correctly on all inputs due to the presence of the verification step in Kayal's algorithm: Theorem 53. Let f ∈ Q[X 1 , . . . , X n ] be a homogeneous polynomial of degree d given verbosely as a sum of monomials. The LieEquivalence algorithm determines whether f is equivalent over Q to P d , the "sum of d-th powers" polynomial from [START_REF] Agrawal | Equivalence of F-algebras and cubic forms[END_REF]. If this is the case, it outputs an invertible matrix A with rational entries such that f (x) = P d (Ax). Moreover, for any fixed d the algorithm runs in polynomial time in the Turing machine model.

Proof. Since we are interested in equivalence over the field of rational numbers, we will run the 3-step algorithm from Section 3.1 with K = K = Q. First we establish the correctness of LieEquivalence. If the algorithm accepts its input f , it explicitly finds at step 2 and step 3 linearly independent linear forms i ∈ Q[x 1 , . . . , x n ] such that f = n i=1 d i . The algorithm's answer must therefore be correct in this case. Conversely, assume that such a decomposition exists. Then the Hessian determinant H f factors as

H f = c n i=1 d-2 i
where c is a nonzero constant. Since the i are linearly independent, we are in the situation where DerandLie works correctly. Therefore, by Theorem 52 we will find the i (or actually constant multiples l i of the i ) at step 1 of the algorithm of Section 3.1. Finally, the decomposition f = n i=1 d i is obtained at steps 2 and 3. We now turn to the algorithm's complexity. Since DerandLie runs in polynomial time, the first step of the algorithm from Section 3.1 will also run in polynomial time. At step 2 we can afford to expand the powers l d i as sums of monomials (this takes polynomial time for constant d), and then we find the constants a i by dense linear algebra. Finally, the extraction of d-th roots of rational numbers at step 3 also takes polynomial time.

Theorem 3 .

 3 Let A, B ∈ M n (C) be two complex symmetric matrices of size n with A nonsingular, and let C = A -1 B. (i) C is diagonalizable if and only if there are complex diagonal matrices D and ∆ and a nonsingular R ∈ M n (C) such that A = RDR T and B = R∆R T .

Theorem 9 .

 9 Let A, B ∈ M n (R) be two real symmetric matrices of size n with A nonsingular, and let C = A -1 B. (i) C is diagonalizable and has real eigenvalues if and only if there are real diagonal matrices D and ∆ and a nonsingular R ∈ M n (R) such that A = RDR T and B = R∆R T .

2 . 3 . 4 .

 234 Enumerate the elements of M to find a point r = (1, r 2 , . . . , r n ) ∈ M such that the matrix D 1 = S 1 + r 2 S 2 . . . + r n S n is invertible. If there is no such point, reject. Construct the following matrix R ∈ M n (K): R is lower triangular with 1's on the diagonal, r 21 = r 2 , . . . , r n1 = r n and all the other entries are set to 0. Compute h(x) = f (Rx), the slices T 1 , . . . , T n of h and T 1 = T -11 .

d 1 +

 1 • • • + x d r for some invertible matrix B ∈ K r×r . If we denote C = B 0 0 I ∈ K n×n

Alternatively, one can run Kayal's algorithm in a computation model over C where, in addition to arithmetic operations over complex numbers, root finding of univariate polynomials is considered an atomic operation (as suggested in a footnote of[START_REF] Garg | Determinant equivalence test over finite fields and over Q[END_REF]). The algorithm would then give the same answer as our algorithm, but it would not operate anymore within the Turing machine model (or within the BSS model).

The name is borrowed from absolute factorization, a well studied problem in computer algebra (see e.g.[START_REF] Cheze | Four lectures on polynomial absolute factorization[END_REF][START_REF] Chèze | Lifting and recombination techniques for absolute factorization[END_REF][START_REF] Gao | Factoring multivariate polynomials via partial differential equations[END_REF][START_REF] Shaker | Topology and factorization of polynomials[END_REF]).

This argument does not provide by itself an efficient decision algorithm.

This paper is focused on the fields of real and complex numbers but equivalence of quadratic forms has been an active topic of study for other fields as well, especially from the point of view of number theory: see for instance[START_REF] Timothy | Introduction to quadratic forms[END_REF][START_REF] Scharlau | Quadratic and Hermitian forms[END_REF].

More precisely one must have l1 = α1(x1 + ix2), l2 = α2(x1 -ix2) (or vice versa) where α 3 1 = α 3 2 = 1.

An algebraic algorithm does not require the construction of field extensions since by definition all operations take place in the ground field. In[START_REF] Ivanyos | Algorithms based on*-algebras, and their applications to isomorphism of polynomials with one secret, group isomorphism, and polynomial identity testing[END_REF] they only need to construct extensions of polynomially bounded degree. As explained in Section 3.1, this is not clear for Kayal's algorithm.

For Sturm sequences this is not obvious because in a naive implementation, the bit size of the numbers involved may grow exponentially. There is however an efficient implementation based on subresultants[START_REF] Basu | Algorithms in Real Algebraic Geometry[END_REF]. The same issue of coefficient growth already occurs in the computation of the gcd of two polynomials, and can also be solved with subresultants.

Variable minimization for forms of degree 3 is also studied in Saxena's thesis[START_REF] Saxena | Morphisms of rings and application to complexity[END_REF] Proposition 3.1]. He attributes the corresponding deterministic algorithm to Harrison[START_REF] Dk Harrison | A Grothendieck ring of higher degree forms[END_REF].

Acknowledgements

We would like to thank Roger Horn for pointing out Problem 4.5.P4 in [28] and Peter Bürgisser for references to the tensor literature. The anonymous referee suggested several improvements in the presentation of the paper, and a significant simplification in the hitting set constructions of Section 6.

R ∈ M n (K) such that T k = RΛ k R T for all k = 1, . . . , n. Let g(x) = f (R -T x). By Proposition 22 the slices of g are linear combinations of the Λ k , i.e., they are all diagonal. By Remark 21, g must be as in [START_REF] Beltrán | Pencil-based algorithms for tensor rank decomposition are not stable[END_REF]. It therefore remains to show that the coefficients α i are all nonzero. This must be the case due to the hypothesis on U. Indeed, this hypothesis implies that the matrix space V spanned by the slices of g is nonsingular (apply again Lemma 23, this time in the other direction). But if some α i vanishes, V is included in the space of diagonal matrices with a 0 in the i-th diagonal entry.

Corollary 25. Let f be a degree 3 form with slices T 1 , . . . , T n and assume that T 1 is nonsingular. Then f is equivalent to a sum of n cubes if and only if the n -

Proof. This follows from Theorem 24 as well as Theorem 4 for K = C and Theorem 10 for K = R.

We conclude this section with an alternative characterization of equivalence to a sum of cubes for the field of real numbers.

Theorem 26. Let f be a real form of degree 3 and let V be the subspace of M n (R) spanned by the slices of f . The 3 following properties are equivalent:

(i) f is equivalent as a real polynomial to a sum of n cubes.

(ii) There exist two invertible matrices A, B ∈ V such that A -1 V is a commuting subspace and B is positive definite.

(iii) V contains a positive definite matrix, and A -1 V is a commuting subspace for any invertible matrix A ∈ V.

Proof. Suppose that f is equivalent to a sum of n cubes, i.e., f (x) = P 3 (Qx) where Q ∈ M n (R) is invertible. We have seen in Lemma 23 that the slices of P 3 span the space D of diagonal matrices, and that those of f span Q T DQ. The latter span contains the positive definite matrix B = Q T Q. Moreover, according to Proposition 22 the slices of f are simultaneously diagonalizable by congruence. By Theorem 12, A -1 V is a commuting subspace for any invertible matrix A ∈ V. Hence we have shown that (i) implies (iii). That (iii) implies (ii) is clear since V is nonsingular (by hypothesis, it contains a positive definite matrix). Finally, let us show that (ii) implies (i). By hypothesis, V contains a positive definite matrix B hence we can apply Theorem 14. It follows that the slices are simultaneously diagonalizable by congruence. By Theorem 24, f must be equivalent to a sum of n cubes.

Compared to Theorem 24 or Corollary 25, Theorem 26 does not involve any diagonalizability test. One can check that V contains a positive definite matrix using semi-definite programming. Unfortunately, no efficient