Special matrices

(directly go to documentation on : JacobianMatrix, VandermondeMatrix, HessianMatrix, HilbertMatrix, HilbertInverseMatrix, ToeplitzMatrix, WronskianMatrix, SylvesterMatrix. )

# 18. Special matrices

JacobianMatrix | calculate the Jacobian matrix of n functions in n variables
VandermondeMatrix | create the Vandermonde matrix
HessianMatrix | create the Hessian matrix
HilbertMatrix | create a Hilbert matrix
HilbertInverseMatrix | create a Hilbert inverse matrix
ToeplitzMatrix | create a Toeplitz matrix
WronskianMatrix | create the Wronskian matrix
SylvesterMatrix | calculate the Sylvester matrix of two polynomials

###

JacobianMatrix -- calculate the Jacobian matrix of n functions in n variables

##### Standard library

##### Calling format:

    JacobianMatrix(functions,variables)

##### Parameters:

`functions` -- an n-dimensional vector of functions

`variables` -- an n-dimensional vector of variables

##### Description:

The function `JacobianMatrix` calculates the Jacobian matrix of n functions in n variables.

The ( i, j)-th element of the Jacobian matrix is defined as the derivative of i-th function with respect to the j-th variable.

##### Examples:

    In> JacobianMatrix( {Sin(x),Cos(y)}, {x,y} );
    Out> {{Cos(x),0},{0,-Sin(y)}};
    In> PrettyForm(%)

    /                                 \
    | ( Cos( x ) ) ( 0 )              |
    |                                 |
    | ( 0 )        ( -( Sin( y ) ) )  |
    \                                 /

###

VandermondeMatrix -- create the Vandermonde matrix

##### Standard library

##### Calling format:

    VandermondeMatrix(vector)

##### Parameters:

`vector` -- an n-dimensional vector

##### Description:

The function `VandermondeMatrix` calculates the Vandermonde matrix of a vector.

The ( i, j)-th element of the Vandermonde matrix is defined as i^(j-1).

##### Examples:

    In> VandermondeMatrix({1,2,3,4})
    Out> {{1,1,1,1},{1,2,3,4},{1,4,9,16},{1,8,27,64}};
    In>PrettyForm(%)

    /                            \
    | ( 1 ) ( 1 ) ( 1 )  ( 1 )   |
    |                            |
    | ( 1 ) ( 2 ) ( 3 )  ( 4 )   |
    |                            |
    | ( 1 ) ( 4 ) ( 9 )  ( 16 )  |
    |                            |
    | ( 1 ) ( 8 ) ( 27 ) ( 64 )  |
    \                            /

###

HessianMatrix -- create the Hessian matrix

##### Standard library

##### Calling format:

    HessianMatrix(function,var)

##### Parameters:

`function` -- a function in n variables

`var` -- an n-dimensional vector of variables

##### Description:

The function `HessianMatrix` calculates the Hessian matrix of a vector.

If f(x) is a function of an n-dimensional vector x, then the ( i, j)-th element of the Hessian matrix of the function f(x) is defined as Deriv(x[i])Deriv(x[j])f(x). If the third order mixed partials are continuous, then the Hessian matrix is symmetric (a standard theorem of calculus).

The Hessian matrix is used in the second derivative test to discern if a critical point is a local maximum, a local minimum or a saddle point.

##### Examples:

    In> HessianMatrix(3*x^2-2*x*y+y^2-8*y, {x,y} )
    Out> {{6,-2},{-2,2}};
    In> PrettyForm(%)

    /                \
    | ( 6 )  ( -2 )  |
    |                |
    | ( -2 ) ( 2 )   |
    \                /

###

HilbertMatrix -- create a Hilbert matrix

##### Standard library

##### Calling format:

    HilbertMatrix(n)
    HilbertMatrix(n,m)

##### Parameters:

`n,m` -- positive integers

##### Description:

The function `HilbertMatrix` returns the `n` by `m` Hilbert matrix if given two arguments, and the square `n` by `n` Hilbert matrix if given only one. The Hilbert matrix is defined as `A(i,j) = 1/(i+j-1)`. The Hilbert matrix is extremely sensitive to manipulate and invert numerically.

##### Examples:

    In> PrettyForm(HilbertMatrix(4))

    /                          \
    | ( 1 ) / 1 \ / 1 \ / 1 \  |
    |       | - | | - | | - |  |
    |       \ 2 / \ 3 / \ 4 /  |
    |                          |
    | / 1 \ / 1 \ / 1 \ / 1 \  |
    | | - | | - | | - | | - |  |
    | \ 2 / \ 3 / \ 4 / \ 5 /  |
    |                          |
    | / 1 \ / 1 \ / 1 \ / 1 \  |
    | | - | | - | | - | | - |  |
    | \ 3 / \ 4 / \ 5 / \ 6 /  |
    |                          |
    | / 1 \ / 1 \ / 1 \ / 1 \  |
    | | - | | - | | - | | - |  |
    | \ 4 / \ 5 / \ 6 / \ 7 /  |
    \                          /

##### See also:

HilbertInverseMatrix .

###

HilbertInverseMatrix -- create a Hilbert inverse matrix

##### Standard library

##### Calling format:

    HilbertInverseMatrix(n)

##### Parameters:

`n` -- positive integer

##### Description:

The function `HilbertInverseMatrix` returns the `n` by `n` inverse of the corresponding Hilbert matrix. All Hilbert inverse matrices have integer entries that grow in magnitude rapidly.

##### Examples:

    In> PrettyForm(HilbertInverseMatrix(4))

    /                                         \
    | ( 16 )   ( -120 )  ( 240 )   ( -140 )   |
    |                                         |
    | ( -120 ) ( 1200 )  ( -2700 ) ( 1680 )   |
    |                                         |
    | ( 240 )  ( -2700 ) ( 6480 )  ( -4200 )  |
    |                                         |
    | ( -140 ) ( 1680 )  ( -4200 ) ( 2800 )   |
    \                                         /

##### See also:

HilbertMatrix .

###

ToeplitzMatrix -- create a Toeplitz matrix

##### Standard library

##### Calling format:

    ToeplitzMatrix(N)

##### Parameters:

`N` -- an n-dimensional row vector

##### Description:

The function `ToeplitzMatrix` calculates the Toeplitz matrix given an n-dimensional row vector. This matrix has the same entries in all diagonal columns, from upper left to lower right.

##### Examples:

    In> PrettyForm(ToeplitzMatrix({1,2,3,4,5}))

    /                                \
    | ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 )  |
    |                                |
    | ( 2 ) ( 1 ) ( 2 ) ( 3 ) ( 4 )  |
    |                                |
    | ( 3 ) ( 2 ) ( 1 ) ( 2 ) ( 3 )  |
    |                                |
    | ( 4 ) ( 3 ) ( 2 ) ( 1 ) ( 2 )  |
    |                                |
    | ( 5 ) ( 4 ) ( 3 ) ( 2 ) ( 1 )  |
    \                                /

###

WronskianMatrix -- create the Wronskian matrix

##### Standard library

##### Calling format:

    WronskianMatrix(func,var)

##### Parameters:

`func` -- an n-dimensional vector of functions

`var` -- a variable to differentiate with respect to

##### Description:

The function `WronskianMatrix` calculates the Wronskian matrix of n functions.

The Wronskian matrix is created by putting each function as the first element of each column, and filling in the rest of each column by the ( i-1)-th derivative, where i is the current row.

The Wronskian matrix is used to verify that the n functions are linearly independent, usually solutions to a differential equation. If the determinant of the Wronskian matrix is zero, then the functions are dependent, otherwise they are independent.

##### Examples:

    In> WronskianMatrix({Sin(x),Cos(x),x^4},x);
    Out> {{Sin(x),Cos(x),x^4},{Cos(x),-Sin(x),4*x^3},
      {-Sin(x),-Cos(x),12*x^2}};
    In> PrettyForm(%)

    /                                                 \
    | ( Sin( x ) )      ( Cos( x ) )      /  4 \      |
    |                                     \ x  /      |
    |                                                 |
    | ( Cos( x ) )      ( -( Sin( x ) ) ) /      3 \  |
    |                                     \ 4 * x  /  |
    |                                                 |
    | ( -( Sin( x ) ) ) ( -( Cos( x ) ) ) /       2 \ |
    |                                     \ 12 * x  / |
    \                                                 /

The last element is a linear combination of the first two, so the determinant is zero:

    In> A:=Determinant( WronskianMatrix( {x^4,x^3,2*x^4
      + 3*x^3},x ) )
    Out> x^4*3*x^2*(24*x^2+18*x)-x^4*(8*x^3+9*x^2)*6*x
      +(2*x^4+3*x^3)*4*x^3*6*x-4*x^6*(24*x^2+18*x)+x^3
      *(8*x^3+9*x^2)*12*x^2-(2*x^4+3*x^3)*3*x^2*12*x^2;
    In> Simplify(A)
    Out> 0;

###

SylvesterMatrix -- calculate the Sylvester matrix of two polynomials

##### Standard library

##### Calling format:

    SylvesterMatrix(poly1,poly2,variable)

##### Parameters:

`poly1` -- polynomial

`poly2` -- polynomial

`variable` -- variable to express the matrix for

##### Description:

The function `SylvesterMatrix` calculates the Sylvester matrix for a pair of polynomials.

The Sylvester matrix is closely related to the resultant, which is defined as the determinant of the Sylvester matrix. Two polynomials share common roots only if the resultant is zero.

##### Examples:

    In> ex1:= x^2+2*x-a
    Out> x^2+2*x-a;
    In> ex2:= x^2+a*x-4
    Out> x^2+a*x-4;
    In> A:=SylvesterMatrix(ex1,ex2,x)
    Out> {{1,2,-a,0},{0,1,2,-a},
      {1,a,-4,0},{0,1,a,-4}};
    In> B:=Determinant(A)
    Out> 16-a^2*a- -8*a-4*a+a^2- -2*a^2-16-4*a;
    In> Simplify(B)
    Out> 3*a^2-a^3;

The above example shows that the two polynomials have common zeros if a=3.

##### See also:

Determinant , Simplify , Solve , PSolve .