Function: semidef - test for positive and negative definite and semidefinite matrices and Matrices
Calling sequence:
semidef(A,t);
Parameters:
A - a square matrix or Matrix
t - one of the four names positive_def , negative_def , positive_semidef and negative_semidef .
Description:
Examples:
A 3 x 3 matrix that definite and IsDefinite incorrectly identify as positive semidefinite:
>
A:= matrix([[2,0,3],[0,0,0],[3,0,1]]);
"definite answers", linalg[definite](A,positive_semidef);
"IsDefinite answers",
LinearAlgebra:-IsDefinite(Matrix(A),
query=positive_semidef);
"semidef answers",
semidef(A,positive_semidef);
"Eigenvalues are",evalf(Eigenvals(A));
Another 3 x 3 example which IsDefinite incorrectly identifies as positive semidefinite.
>
A:= Matrix([[2,0,3],[0,1,0],[3,0,1]]);
"definite answers", linalg[definite](convert(A,matrix),positive_semidef);"IsDefinite answers",
LinearAlgebra[IsDefinite](A,query=positive_semidef);
"semidef answers",
semidef(A,positive_semidef);
"Eigenvalues are",evalf(LinearAlgebra:-Eigenvalues(A));
A complex hermitian matrix: definite incorrectly identifies it as not positive definite.
>
A:= matrix([[2,I],[-I,2]]);
"definite answers",
linalg[definite](A,positive_def);
"semidef answers",
semidef(A,positive_def);
"Eigenvalues are",linalg[eigenvals](A);
A matrix with symbolic entries: this is hermitian if the parameter p is real.
>
A:= matrix([[2,I*p],[-I*p,2]]);
"IsDefinite returns an error";
LinearAlgebra:-IsDefinite(Matrix(A),
query=positive_def);
"definite answers",linalg[definite](A,positive_def);
"semidef answers",
semidef(A,positive_def);
"Eigenvalues are",linalg[eigenvals](A);
Error, (in LinearAlgebra:-LA_Main:-IsDefinite) cannot evaluate boolean: p^2 < 4
Another matrix with entries depending on a parameter. The result of semidef is rather complicated, but solve can be used. In this case solve does not work on the output of definite , while the result of IsDefinite is incorrect.
>
A:= matrix([[4+p,0,p,1],[0,3,p,2],[p,p,4,-p],[1,2,-p,2]]);
> linalg[definite](A,positive_semidef); solve(%,p);
Error, (in RealRange_fromineq) cannot handle intervals, use solve over name sets
>
solve({-4-p <= 0, -48+7*p^2-12*p+p^3 <= 0, -20+47*p^2-8*p+9*p^3 <= 0, -12+p^2 <= 0,
-8+9*p^2 <= 0, -8+p^2 <= 0},p);
> LinearAlgebra[IsDefinite](Matrix(A),query=positive_semidef); solve(%);
> semidef(A,positive_semidef);solve(%);
See also: linalg , linalg[definite] , LinearAlgebra , LinearAlgebra[IsDefinite] , matrix , Matrix
Maple Advisor Database R. Israel, 2000