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.Fri, 12 May 2017 01:50:21 +0200solve with many variableshttps://ask.sagemath.org/question/37574/solve-with-many-variables/hi
please i have a problem
i have a MATRIX contains many variables, and i want to find the eigenvalues of this matrix in function of this variables i let you my matrix here and my code
x,a,b,c,s1,s2,s3,s4,s5,s6=var('x a b c s1 s2 s3 s4 s5 s6')
k=matrix([[-3*a-b+c*s1,a,a,0,a,0],
[a,-2*a-b+c*s2,a,0,0,0],
[a,a,-4*a-b+c*s3,a,a,0],
[0,0,a,-2*a-b+c*s4,a,0],
[a,0,a,a,-4*a-b+c*s5,a],
[0,0,0,0,a,-a-b+c*s6]]
)
B=matrix(k- x*matrix.identity(6))
eq(a,b,c,s1,s2,s3,s4,s5,s6)=det(B)
solve(eq==0,x)
but i can get the solution but if i give to the variable c=0 or b=0 i get the solution so please can you help meThu, 11 May 2017 10:51:34 +0200https://ask.sagemath.org/question/37574/solve-with-many-variables/Answer by dan_fulea for <p>hi
please i have a problem
i have a MATRIX contains many variables, and i want to find the eigenvalues of this matrix in function of this variables i let you my matrix here and my code </p>
<pre><code>x,a,b,c,s1,s2,s3,s4,s5,s6=var('x a b c s1 s2 s3 s4 s5 s6')
k=matrix([[-3*a-b+c*s1,a,a,0,a,0],
[a,-2*a-b+c*s2,a,0,0,0],
[a,a,-4*a-b+c*s3,a,a,0],
[0,0,a,-2*a-b+c*s4,a,0],
[a,0,a,a,-4*a-b+c*s5,a],
[0,0,0,0,a,-a-b+c*s6]]
)
B=matrix(k- x*matrix.identity(6))
eq(a,b,c,s1,s2,s3,s4,s5,s6)=det(B)
solve(eq==0,x)
</code></pre>
<p>but i can get the solution but if i give to the variable c=0 or b=0 i get the solution so please can you help me</p>
https://ask.sagemath.org/question/37574/solve-with-many-variables/?answer=37577#post-id-37577I had to start an answer, since a comment would not fit in the given space. The present "answer" is only showing that the resulting equation of degree six -- even in some particular cases -- is "too generic" to offer a possibility of expressing solutions by "simple means", e.g. radicals (combined with simple algebra.)
First of all, let us rewrite the code, so that it can be copy-pasted.
x,a,b,c,s1,s2,s3,s4,s5,s6 = var( 'x a b c s1 s2 s3 s4 s5 s6' )
k = matrix( [
[-3*a-b+c*s1,a,a,0,a,0],
[a,-2*a-b+c*s2,a,0,0,0],
[a,a,-4*a-b+c*s3,a,a,0],
[0,0,a,-2*a-b+c*s4,a,0],
[a,0,a,a,-4*a-b+c*s5,a],
[0,0,0,0,a, -a-b+c*s6]
] )
B = matrix( k - x*matrix.identity(6) )
print k
And the matrix k is:
[c*s1 - 3*a - b a a 0 a 0]
[ a c*s2 - 2*a - b a 0 0 0]
[ a a c*s3 - 4*a - b a a 0]
[ 0 0 a c*s4 - 2*a - b a 0]
[ a 0 a a c*s5 - 4*a - b a]
[ 0 0 0 0 a c*s6 - a - b]
A first question is: Is this the matrix to be studied?
Now we want to subtract $x$ on the diagonal, apply the determinant, and solve with respect to $x$.
Then we can forget about $b$. (It has only a shifting contribution of the eigenvalues.) We can set without loss of generality $b=0$. The variable $c$ is the next one that we should get rid of. Since $s_1,s_2,\dots,s_6$ are general enough, we can also set either $c=0$, the degenerated case which removes the dependency on the $s$-variables, or $c=1$ else. Than, replacing $s_1-3a$ by "an other" $s_1$ we have to understand the eigenvalues of a matrix $M$ of the following "too general" shape:
M = matrix( [
[s1,a,a,0,a,0],
[a,s2,a,0,0,0],
[a,a,s3,a,a,0],
[0,0,a,s4,a,0],
[a,0,a,a,s5,a],
[0,0,0,0,a,s6]
] )
M
We get:
[s1 a a 0 a 0]
[ a s2 a 0 0 0]
[ a a s3 a a 0]
[ 0 0 a s4 a 0]
[ a 0 a a s5 a]
[ 0 0 0 0 a s6]
If $a=0$, a very special case, we have of course no problems. Else, we can multiply the whole matrix by $1/a$ and get an equivalent problem, namely to find the eigenvalues of the matrix:
M = matrix( [
[s1,1,1,0,1,0],
[1,s2,1,0,0,0],
[1,1,s3,1,1,0],
[0,0,1,s4,1,0],
[1,0,1,1,s5,1],
[0,0,0,0,1,s6]
] )
M
Explicity:
[s1 1 1 0 1 0]
[ 1 s2 1 0 0 0]
[ 1 1 s3 1 1 0]
[ 0 0 1 s4 1 0]
[ 1 0 1 1 s5 1]
[ 0 0 0 0 1 s6]
Some rows / columns are simpler than the other ones.
For instance, the row / column through the entry $s_6$ has only one non-diagonal $1$.
This matrix is still too complicated to allow a general formula for its eigenvalues.
For instance, let us plug in some explicit values for $s_1,s_2,\dots,s_6$:
def MM( s1, s2, s3, s4, s5, s6 ):
return matrix( [
[s1,1,1,0,1,0],
[1,s2,1,0,0,0],
[1,1,s3,1,1,0],
[0,0,1,s4,1,0],
[1,0,1,1,s5,1],
[0,0,0,0,1,s6]
] )
MM( 0,0,0,0,0,0 ).charpoly()
This gives:
x^6 - 8*x^4 - 6*x^3 + 7*x^2 + 4*x - 1
Well, the above polynomial has no "obvious roots", that can be expressed by radicals. So the more general equation also has no "obvious roots". Which is the origin of the question?
Thu, 11 May 2017 20:03:23 +0200https://ask.sagemath.org/question/37574/solve-with-many-variables/?answer=37577#post-id-37577Comment by simo1993 for <p>I had to start an answer, since a comment would not fit in the given space. The present "answer" is only showing that the resulting equation of degree six -- even in some particular cases -- is "too generic" to offer a possibility of expressing solutions by "simple means", e.g. radicals (combined with simple algebra.)
First of all, let us rewrite the code, so that it can be copy-pasted.</p>
<pre><code>x,a,b,c,s1,s2,s3,s4,s5,s6 = var( 'x a b c s1 s2 s3 s4 s5 s6' )
k = matrix( [
[-3*a-b+c*s1,a,a,0,a,0],
[a,-2*a-b+c*s2,a,0,0,0],
[a,a,-4*a-b+c*s3,a,a,0],
[0,0,a,-2*a-b+c*s4,a,0],
[a,0,a,a,-4*a-b+c*s5,a],
[0,0,0,0,a, -a-b+c*s6]
] )
B = matrix( k - x*matrix.identity(6) )
print k
</code></pre>
<p>And the matrix k is:</p>
<pre><code>[c*s1 - 3*a - b a a 0 a 0]
[ a c*s2 - 2*a - b a 0 0 0]
[ a a c*s3 - 4*a - b a a 0]
[ 0 0 a c*s4 - 2*a - b a 0]
[ a 0 a a c*s5 - 4*a - b a]
[ 0 0 0 0 a c*s6 - a - b]
</code></pre>
<p>A first question is: Is this the matrix to be studied?</p>
<p>Now we want to subtract $x$ on the diagonal, apply the determinant, and solve with respect to $x$.
Then we can forget about $b$. (It has only a shifting contribution of the eigenvalues.) We can set without loss of generality $b=0$. The variable $c$ is the next one that we should get rid of. Since $s_1,s_2,\dots,s_6$ are general enough, we can also set either $c=0$, the degenerated case which removes the dependency on the $s$-variables, or $c=1$ else. Than, replacing $s_1-3a$ by "an other" $s_1$ we have to understand the eigenvalues of a matrix $M$ of the following "too general" shape:</p>
<pre><code>M = matrix( [
[s1,a,a,0,a,0],
[a,s2,a,0,0,0],
[a,a,s3,a,a,0],
[0,0,a,s4,a,0],
[a,0,a,a,s5,a],
[0,0,0,0,a,s6]
] )
M
</code></pre>
<p>We get:</p>
<pre><code>[s1 a a 0 a 0]
[ a s2 a 0 0 0]
[ a a s3 a a 0]
[ 0 0 a s4 a 0]
[ a 0 a a s5 a]
[ 0 0 0 0 a s6]
</code></pre>
<p>If $a=0$, a very special case, we have of course no problems. Else, we can multiply the whole matrix by $1/a$ and get an equivalent problem, namely to find the eigenvalues of the matrix:</p>
<pre><code>M = matrix( [
[s1,1,1,0,1,0],
[1,s2,1,0,0,0],
[1,1,s3,1,1,0],
[0,0,1,s4,1,0],
[1,0,1,1,s5,1],
[0,0,0,0,1,s6]
] )
M
</code></pre>
<p>Explicity:</p>
<pre><code>[s1 1 1 0 1 0]
[ 1 s2 1 0 0 0]
[ 1 1 s3 1 1 0]
[ 0 0 1 s4 1 0]
[ 1 0 1 1 s5 1]
[ 0 0 0 0 1 s6]
</code></pre>
<p>Some rows / columns are simpler than the other ones.
For instance, the row / column through the entry $s_6$ has only one non-diagonal $1$.
This matrix is still too complicated to allow a general formula for its eigenvalues.
For instance, let us plug in some explicit values for $s_1,s_2,\dots,s_6$:</p>
<pre><code>def MM( s1, s2, s3, s4, s5, s6 ):
return matrix( [
[s1,1,1,0,1,0],
[1,s2,1,0,0,0],
[1,1,s3,1,1,0],
[0,0,1,s4,1,0],
[1,0,1,1,s5,1],
[0,0,0,0,1,s6]
] )
MM( 0,0,0,0,0,0 ).charpoly()
</code></pre>
<p>This gives:</p>
<pre><code>x^6 - 8*x^4 - 6*x^3 + 7*x^2 + 4*x - 1
</code></pre>
<p>Well, the above polynomial has no "obvious roots", that can be expressed by radicals. So the more general equation also has no "obvious roots". Which is the origin of the question?</p>
https://ask.sagemath.org/question/37574/solve-with-many-variables/?comment=37578#post-id-37578thanks you for your time
may be i didnt understand you'r answer so we start with my matrix k which contains many variables im asking if i can compute all eigenvalues of this matrix such that if we suppose that x is an eigenvalue of this matrix i want to find some function f such that x=f(a,b,c,s1,..s6) and i need that this function must be sumbolic
exxample
let A=matrix([[a,0];[0 b]])
f(a,b)=A.charpoly()=(a-x)*(b-x)
f(a,b)=0
thats mean x=a or x=b
what is a simple example but with my metrics I can't get some results in this formeFri, 12 May 2017 01:50:21 +0200https://ask.sagemath.org/question/37574/solve-with-many-variables/?comment=37578#post-id-37578