ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 24 Nov 2015 08:54:05 -0600Linear Equations with infinite solutionshttp://ask.sagemath.org/question/31009/linear-equations-with-infinite-solutions/ I have 4 equations with 6 variables, which means I will have 2 free variables, which means I would have infinitely many solutions. I found one solution but I don't know what functions I should use in Sage to generate 10 different solutions (as that is what I was asked to do).
This is what I did:
M=matrix(QQ, [[1,2,3,4,5,6],[1,1,1,1,1,1],[1,-1,1,-1,1,-1],[1,2,1,3,1,4]]);
x=vector(QQ, [6,1,-1,4]);
M.solve_right(x)
It only gives me one solution: 0, -1, 0, 2, 0, 0, how do I get more?
Tue, 24 Nov 2015 07:54:29 -0600http://ask.sagemath.org/question/31009/linear-equations-with-infinite-solutions/Answer by vdelecroix for <p>I have 4 equations with 6 variables, which means I will have 2 free variables, which means I would have infinitely many solutions. I found one solution but I don't know what functions I should use in Sage to generate 10 different solutions (as that is what I was asked to do).</p>
<p>This is what I did:
M=matrix(QQ, [[1,2,3,4,5,6],[1,1,1,1,1,1],[1,-1,1,-1,1,-1],[1,2,1,3,1,4]]);
x=vector(QQ, [6,1,-1,4]);
M.solve_right(x)</p>
<p>It only gives me one solution: 0, -1, 0, 2, 0, 0, how do I get more?</p>
http://ask.sagemath.org/question/31009/linear-equations-with-infinite-solutions/?answer=31012#post-id-31012This is elementary linear algebra: the other solutions are obtained by adding vectors in the kernel... In Sage
M = matrix(QQ, [[1,2,3,4,5,6],[1,1,1,1,1,1],[1,-1,1,-1,1,-1],[1,2,1,3,1,4]])
x = vector(QQ, [6,1,-1,4])
v0 = M.solve_right(x)
K = M.right_kernel()
v1, v2 = K.basis()
From which you can build all solutions
sage: M * (v0 + 3*v1 - 19*v2) == x
True
sage: M * (v0 + 12*v1) == x
TrueTue, 24 Nov 2015 08:54:05 -0600http://ask.sagemath.org/question/31009/linear-equations-with-infinite-solutions/?answer=31012#post-id-31012