主要内容

hermiteForm

Hermite form of matrix

Description

H = hermiteForm(A) returns the Hermite normal form of a matrix A. The elements of A must be integers or polynomials in a variable determined by symvar(A,1). The Hermite form H is an upper triangular matrix.

example

[U,H] = hermiteForm(A) returns the Hermite normal form of A and a unimodular transformation matrix U, such that H = U*A.

example

___ = hermiteForm(A,var) assumes that the elements of A are univariate polynomials in the specified variable var. If A contains other variables, hermiteForm treats those variables as symbolic parameters.

You can use the input argument var in any of the previous syntaxes.

If A does not contain var, then hermiteForm(A) and hermiteForm(A,var) return different results.

example

Examples

collapse all

Find the Hermite form of an inverse Hilbert matrix.

A = sym(invhilb(5))
A = 

(25-3001050-1400630-3004800-1890026880-126001050-1890079380-11760056700-140026880-117600179200-88200630-1260056700-8820044100)

H = hermiteForm(A)
H = 

(50-210-2806300600000042000000840000002520)

Create a 2-by-2 matrix, the elements of which are polynomials in the variable x.

syms x
A = [x^2 + 3, (2*x - 1)^2; (x + 2)^2, 3*x^2 + 5]
A = 

(x2+32x-12x+223x2+5)

Find the Hermite form of this matrix.

H = hermiteForm(A)
H = 

(14x349+47x249-76x49+20490x4+12x3-13x2-12x-11)

Create a 2-by-2 matrix that contains two variables: x and y.

syms x y
A = [2/x + y, x^2 - y^2; 3*sin(x) + y, x]
A = 

(y+2xx2-y2y+3sin(x)x)

Find the Hermite form of this matrix. If you do not specify the polynomial variable, hermiteForm uses symvar(A,1) and thus determines that the polynomial variable is x. Because 3*sin(x) + y is not a polynomial in x, hermiteForm(A) throws an error.

Find the Hermite form of A specifying that all elements of A are polynomials in the variable y.

H = hermiteForm(A,y)
H = 

(1xy23xsin(x)-2+xx-x23xsin(x)-203y2sin(x)-3x2sin(x)+y3+yx-x2+2)

Find the Hermite form and the corresponding transformation matrix for an inverse Hilbert matrix.

A = sym(invhilb(3));
[U,H] = hermiteForm(A)
U = 

(1397643201512)

H = 

(303001200060)

Verify that H = U*A.

isAlways(H == U*A)
ans = 3×3 logical array

   1   1   1
   1   1   1
   1   1   1

Find the Hermite form and the corresponding transformation matrix for a matrix of polynomials.

syms x y
A = [2*(x - y), 3*(x^2 - y^2);
    4*(x^3 - y^3), 5*(x^4 - y^4)];
[U,H] = hermiteForm(A,x)
U = 

(1202x2+2xy+2y2-1)

H = 

(x-y3x22-3y220x4+6x3y-6xy3-y4)

Verify that H = U*A.

isAlways(H == U*A)
ans = 2×2 logical array

   1   1
   1   1

If a matrix does not contain a particular variable, and you call hermiteForm specifying that variable as the second argument, then the result differs from what you get without specifying that variable. For example, create a matrix that does not contain any variables.

A = [9 -36 30; -36 192 -180; 30 -180 180]
A = 3×3

     9   -36    30
   -36   192  -180
    30  -180   180

Call hermiteForm specifying variable x as the second argument. In this case, hermiteForm assumes that the elements of A are univariate polynomials in x.

syms x
hermiteForm(A,x)
ans = 3×3

     1     0     0
     0     1     0
     0     0     1

Call hermiteForm without specifying variables. In this case, hermiteForm treats A as a matrix of integers.

hermiteForm(A)
ans = 3×3

     3     0    30
     0    12     0
     0     0    60

Input Arguments

collapse all

Input matrix, specified as a symbolic matrix, the elements of which are integers or univariate polynomials. If the elements of A contain more than one variable, use the var argument to specify a polynomial variable, and treat all other variables as symbolic parameters. If A is multivariate, and you do not specify var, then hermiteForm uses symvar(A,1) to determine a polynomial variable.

Polynomial variable, specified as a symbolic variable.

Output Arguments

collapse all

Hermite normal form of input matrix, returned as a symbolic matrix. The Hermite form of a matrix is an upper triangular matrix.

Transformation matrix, returned as a unimodular symbolic matrix. If elements of A are integers, then elements of U are also integers, and det(U) = 1 or det(U) = -1. If elements of A are polynomials, then elements of U are univariate polynomials, and det(U) is a constant.

More About

collapse all

Version History

Introduced in R2015b

See Also

|