ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 18 Jul 2018 05:01:30 -0500Turning system of linear equations into a matrixhttps://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/I have a very long list of equations (10^3 order of magnitude), but all linear. There are around 10^2 variables.
I would like to solve these equations in $F_2$, that is, in the field of 2 elements. Questions:
1. Is there a handy-dandy "solve" command in Sage that allows me to list these equations, specify the field in which I want these equations to be interpreted, and Sage returns an answer?
2. Or, is there a handy-dandy way I can input a list of linear equations, and Sage automatically returns a matrix? So long as I can read off which entries/columns of the matrix correspond to which variables in my original equations, I'm happy to then use commands taking matrices as inputs, and use the answer to the question "Solve large system of linear equations over GF(2)" (I would put the link in, but I don't have the karma).Thu, 23 Mar 2017 12:03:46 -0500https://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/Answer by danny for <p>I have a very long list of equations (10^3 order of magnitude), but all linear. There are around 10^2 variables.</p>
<p>I would like to solve these equations in $F_2$, that is, in the field of 2 elements. Questions:</p>
<ol>
<li><p>Is there a handy-dandy "solve" command in Sage that allows me to list these equations, specify the field in which I want these equations to be interpreted, and Sage returns an answer?</p></li>
<li><p>Or, is there a handy-dandy way I can input a list of linear equations, and Sage automatically returns a matrix? So long as I can read off which entries/columns of the matrix correspond to which variables in my original equations, I'm happy to then use commands taking matrices as inputs, and use the answer to the question "Solve large system of linear equations over GF(2)" (I would put the link in, but I don't have the karma).</p></li>
</ol>
https://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/?answer=37060#post-id-37060I give an answer for question 2. See the following :
![image description](/upfiles/14903644766190781.png)
The definition of GenerateMatrix is:
def GenerateMatrix(equsys, vars):
A=matrix([[equ.lhs().coefficient(v) for v in vars] for equ in equsys])
b=matrix([[equ.rhs()] for equ in equsys])
return (A,b)
Fri, 24 Mar 2017 09:10:53 -0500https://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/?answer=37060#post-id-37060Comment by slelievre for <p>I give an answer for question 2. See the following :
<img alt="image description" src="/upfiles/14903644766190781.png"></p>
<p>The definition of GenerateMatrix is:</p>
<pre><code>def GenerateMatrix(equsys, vars):
A=matrix([[equ.lhs().coefficient(v) for v in vars] for equ in equsys])
b=matrix([[equ.rhs()] for equ in equsys])
return (A,b)
</code></pre>
https://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/?comment=43063#post-id-43063What is `show_equtions`?Wed, 18 Jul 2018 05:01:30 -0500https://ask.sagemath.org/question/37053/turning-system-of-linear-equations-into-a-matrix/?comment=43063#post-id-43063