Main Content

Hermite form of matrix

returns
the Hermite normal
form of a matrix `H`

= hermiteForm(`A`

)`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.

`___ = hermiteForm(`

assumes
that the elements of `A`

,`var`

)`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.

Find the Hermite form of an inverse Hilbert matrix.

A = sym(invhilb(5)) H = hermiteForm(A)

A = [ 25, -300, 1050, -1400, 630] [ -300, 4800, -18900, 26880, -12600] [ 1050, -18900, 79380, -117600, 56700] [ -1400, 26880, -117600, 179200, -88200] [ 630, -12600, 56700, -88200, 44100] H = [ 5, 0, -210, -280, 630] [ 0, 60, 0, 0, 0] [ 0, 0, 420, 0, 0] [ 0, 0, 0, 840, 0] [ 0, 0, 0, 0, 2520]

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 = [ x^2 + 3, (2*x - 1)^2] [ (x + 2)^2, 3*x^2 + 5]

Find the Hermite form of this matrix.

H = hermiteForm(A)

H = [ 1, (4*x^3)/49 + (47*x^2)/49 - (76*x)/49 + 20/49] [ 0, x^4 + 12*x^3 - 13*x^2 - 12*x - 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 + 2/x, x^2 - y^2] [ y + 3*sin(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`

throws
an error.

H = hermiteForm(A)

Error using mupadengine/feval (line 163) Cannot convert the matrix entries to integers or univariate polynomials.

Find the Hermite form of `A`

specifying that
all elements of `A`

are polynomials in the variable `y`

.

H = hermiteForm(A,y)

H = [ 1, (x*y^2)/(3*x*sin(x) - 2) + (x*(x - x^2))/(3*x*sin(x) - 2)] [ 0, 3*y^2*sin(x) - 3*x^2*sin(x) + y^3 + y*(- x^2 + x) + 2]

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

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

U = [ 13, 9, 7] [ 6, 4, 3] [ 20, 15, 12] H = [ 3, 0, 30] [ 0, 12, 0] [ 0, 0, 60]

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 = [ 1/2, 0] [ 2*x^2 + 2*x*y + 2*y^2, -1] H = [ x - y, (3*x^2)/2 - (3*y^2)/2] [ 0, x^4 + 6*x^3*y - 6*x*y^3 - y^4]

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 = 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 = 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 0 30 0 12 0 0 0 60