ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 11 Jan 2016 13:23:10 +0100rank of matrices depending on parametershttps://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/Hi!
I have a question on how to treat objects depending with parameters.
For example, let M be a matrix depending on a parameter - call it t.
The rank command just returns the generic rank.
I would like to know the rank of the matrix, varying the parameter.
In the example,
_ = var('t')
M = matrix([[t,0],[0,1]])
M.rank()
I would like to get: if t=0, the rank is 1; otherwise is 2.
Is there any command for this in Sage? (I've heard about a "full solve" in Mathematica.)
Thanks in advance,Mon, 11 Jan 2016 12:29:49 +0100https://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/Answer by vdelecroix for <p>Hi!</p>
<p>I have a question on how to treat objects depending with parameters.</p>
<p>For example, let M be a matrix depending on a parameter - call it t.
The rank command just returns the generic rank.
I would like to know the rank of the matrix, varying the parameter.
In the example,</p>
<pre><code>_ = var('t')
M = matrix([[t,0],[0,1]])
M.rank()
</code></pre>
<p>I would like to get: if t=0, the rank is 1; otherwise is 2.
Is there any command for this in Sage? (I've heard about a "full solve" in Mathematica.)</p>
<p>Thanks in advance,</p>
https://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/?answer=32148#post-id-32148There is no such command in Sage. But the rank is just obtain from conditions on the minors of the matrix.
sage: t = polygen(ZZ, 't')
sage: M = matrix([[t,0],[0,1]])
sage: M.minors(2)
[t]
sage: M.minors(1)
[t, 0, 0, 1]
In other words:
- if $t \not= 0$ your matrix has rank 2
- otherwise if $t \not= 0$ or $0 \not= 0$ or $1 \not= 0$ your matrix has rank 1
- otherwise your matrix has rank 0 (never happen)Mon, 11 Jan 2016 12:55:35 +0100https://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/?answer=32148#post-id-32148Comment by tmonteil for <p>There is no such command in Sage. But the rank is just obtain from conditions on the minors of the matrix.</p>
<pre><code>sage: t = polygen(ZZ, 't')
sage: M = matrix([[t,0],[0,1]])
sage: M.minors(2)
[t]
sage: M.minors(1)
[t, 0, 0, 1]
</code></pre>
<p>In other words:</p>
<ul>
<li><p>if $t \not= 0$ your matrix has rank 2</p></li>
<li><p>otherwise if $t \not= 0$ or $0 \not= 0$ or $1 \not= 0$ your matrix has rank 1</p></li>
<li><p>otherwise your matrix has rank 0 (never happen)</p></li>
</ul>
https://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/?comment=32149#post-id-32149Automatizing this in the general case (over the reals, in any dimension) with `qepcad` (a package to eliminate quantifiers in formulas involving polynomial inequalities, provided as an optional packaged in Sage by yours truly) could be a nice exercise :PMon, 11 Jan 2016 13:23:10 +0100https://ask.sagemath.org/question/32147/rank-of-matrices-depending-on-parameters/?comment=32149#post-id-32149