# Singular

#### D.14.3.2 signatureLqf

Procedure from library `phindex.lib` (see phindex_lib).

Usage:
signatureLqf(h); h quadratic form (poly type).

Return:
the signature of h of type int or if r is given and !=0 then intvec with (signature, nr. of +, nr. of -) is returned.

Theory:
To compute the signature we use the method of Lagrange. The law of inertia for a real quadratic form h(x,x) says that in a representation of h(x,x) as a sum of independent squares h(x,x)=sum_{i=1}^r a_i*X_i^2 the number of positive and the number of negative squares are independent of the choice of representation. The signature -s- of h(x,x) is the difference between the number -pi- of positive squares and the number -nu- of negative squares in the representation of h(x,x). The rank -r- of h(x,x) and the signature -s- determine the numbers -pi- and -nu- uniquely, since
r=pi+nu, s=pi-nu.
The method of Lagrange is a procedure to reduce any real quadratic form to a sum of squares.
Ref. Gantmacher, The theory of matrices, Vol. I, Chelsea Publishing Company, NY 1960, page 299.

Example:
 ```LIB "phindex.lib"; ring r=0,(x(1..4)),ds; poly Ax=4*x(1)^2+x(2)^2+x(3)^2+x(4)^2-4*x(1)*x(2)-4*x(1)*x(3)+4*x(1)*x(4)+4*x(2)*x(3)-4*x(2)*x(4); signatureLqf(Ax,1); //The rank of Ax is 3+1=4 ==> 2,3,1 poly Bx=2*x(1)*x(4)+x(2)^2+x(3)^2; signatureLqf(Bx); ==> 2 ```