5
$\begingroup$

I'm somewhat new to Mathematica and want to check symbolic solutions to small positive definite symmetric matrices (like 3x3 in size), which I think should in general yield a symbolic solution since you can get eigenvalues symbolically (Which we want to assume to be all positive). I was trying Assuming[] directive, but it seems not to be evaluating well for constraints like this:

A = {{a00, a01, a02}, {a10, a11, a12}, {a20, a21, a22}}
ATA = Transpose[A]*A
Assuming[{a00, a01, a02, a11, a12, a22} \[Element] Reals , 
 PositiveDefiniteMatrixQ[ATA]]

The last line gives False. Trying Eigenvalues[ATA]>0 also doesn't work. What is the correct way to define a symbolic positive definite symmetric matrix?

New contributor
shangjiaxuan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
6
  • 2
    $\begingroup$ Functions that end in Q do simple checks of whether something is true. If they can't determine this, they return false. $\endgroup$ Commented Nov 8 at 10:39
  • 1
    $\begingroup$ @shangjiaxuan I think PositiveDefiniteMatrixQ ignores Assuming and treats all variables as complex even though Assuming says otherwise. $\endgroup$ Commented Nov 8 at 12:28
  • 1
    $\begingroup$ @mikado The documentation of PositiveDefiniteMatrixQ says otherwise, namely, "PositiveDefiniteMatrixQ works for symbolic as well as numerical matrices.". $\endgroup$ Commented Nov 8 at 13:26
  • $\begingroup$ Shouldn't PositiveDefiniteMatrixQ[ATA] be False? It is not "explicitly positive definite." One might ask what that means. Well, I think it means that the matrix is, in its given form (and without assumptions), positive definite and cannot be not positive-definite. And ATA can be not positive-definite, if, say, all the entries of A are zero. Since, according to the docs, "PositiveDefiniteMatrixQ[m] gives...False otherwise, I think the False result is correct. $\endgroup$ Commented Nov 8 at 19:28
  • 1
    $\begingroup$ It's not clear to me what "define a matrix" to have a property means. Construct a matrix in a way that it has the property? Construct conditions that, as assumptions, lead the system recognize that the matrix has the property — for example, so that PositiveDefiniteMatrixQ[] returns True? Come up with mathematically equivalent conditions even if Mathematica cannot apply them in whatever use-cases you have in mind? — Indeed, what use-cases do you have in mind? $\endgroup$ Commented 2 days ago

3 Answers 3

4
$\begingroup$

A positive definite real symmetric has only positive eigen values. Therefore, we may e.g. construct such a matrix by first define a diagonal matrix with positive entries:

dm=DiagonalMatrix[RandomReal[{0, 1}, 3]]

Then we may arbitrarily rotate this matrix to get a positive definite symmetric matrix. E.g.:

rot = RotationMatrix[0.5, {1, 1, 1}];
Transpose[rot] . dm . rot / MatrixForm

$\endgroup$
3
$\begingroup$

To answer the question 'What is the correct way to define a symbolic positive definite symmetric matrix?', I will interpret it in the following way: 'What are the sufficient and necessary conditions on the matrix such that it is positive definite?'. Moreover, I will assume the symbolic matrix to be real (and symmetric, of course).

Under these conditions, we need that the roots of the characteristic polynomial are greater than zero. To determine a necessary and sufficient condition, we can use Descartes' rule of signs, which in this case states that the signs of the coefficients of the characteristic polynomial should alternate. For this, we can write a simple function.

symPosDefConditions[mat_] := Module[
  {charpol, dims, coefs, x},
  dims = Dimensions[mat];
  
  If[dims[[1]] != dims[[2]] || Not[SymmetricMatrixQ[mat]], 
   Return[False]];
  
  charpol = CharacteristicPolynomial[mat, x];
  
  coefs = CoefficientList[charpol, x][[1 ;; -2]];
  
  Do[
   coefs[[i]] *= -1;
   , {i, 2, Length[coefs], 2}];
  
  And @@ (# > 0 & /@ coefs)
  ];

This gives, for instance

symPosDefConditions[{{a, b}, {b, c}}] / Simplify
symPosDefConditions[{{a, b, c}, {b, d, e}, {c, e, f}}] / Simplify
(* a c > b^2 && a + c > 0 *)
(* 2 b c e + a d f > c^2 d + a e^2 + b^2 f && 
 a d + (a + d) f > b^2 + c^2 + e^2 && a + d + f > 0 *)

Note that this also works correctly on numerical symmetric real matrices.

$\endgroup$
2
$\begingroup$

Firstly I will show that PositiveDefiniteMatrixQ ignores assumptions of Assuming.

This two lines both give True:

PositiveDefiniteMatrixQ[{{1, a}, {-Conjugate[a], 2}}]

Assuming[a \[Element] Reals, FullSimplify[-Conjugate[a] == -a]]

True
True

So we can replace -Conjugate[a] with -a if we assume a is real.

Assuming[a \[Element] Reals, PositiveDefiniteMatrixQ[{{1, a}, {-a, 2}}]]

False

So we see that assumption was ignored by PositiveDefiniteMatrixQ because it outputted False.

And here a numeric counterexample to OP's belief that ATA is always positive definite.

A = {{a00, a01, a02}, {a10, a11, a12}, {a20, a21, a22}}
ATA = Transpose[A] . A /. {a00 -> 1/4, a01 -> 1/2, a02 -> 1, a10 -> 1,
     a11 -> 1, a12 -> 1, a20 -> 1, a21 -> 1, a22 -> 1};
MatrixForm[ATA]

PositiveDefiniteMatrixQ[ATA]

But the above matrix is still positive semidefinite.

PositiveSemidefiniteMatrixQ[ATA]

True
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.