On Thu, Jul 5, 2012 at 7:48 PM, Chris Smith <smi...@gmail.com> wrote: > On Thu, Jul 5, 2012 at 5:56 PM, Andrew <zxwand...@gmail.com> wrote: >> Hi, I am very new to sympy and python, so pardon my simple question >> >> I have a matrix right here like this (4 equations, 3 unknowns) >> mat1= >> [ 0, 15.0, 10.0, 700.0] >> [ 1, 1, 1, 100.0] >> [ 0, 10.0, 5.0, 200.0] >> [-5.0, 0, 0, 0] >> >> and a list of unknowns >> unknown=[y0,y1,y2] >> > > Which columns do those variables correspond to? If you multiply the > matrix by a length-4 column vector of variables and pass this to solve > it gives
I think the way solve_linear_system is supposed to work is that the last column represents the right hand side of the equation. So a row [1, 2, 3, 4] would represent 1*x1 + 2*x2 + 3*x3 = 4. In other words, it's an augmented matrix. > >>>> v = var('a:d') >>>> v > (a, b, c, d) >>>> v = Matrix([list(v)]).T >>>> e=m*v >>>> solve(e) > {c: -160.0*d, b: 60.0*d, a: 0} > > And the determinant of the matrix is 0: > >>>> m.det() > 0 I don't think that the determinant has anything to do with it. The row [1, 1, 1, 100] clearly corresponds to the solution given. The problem seems to have something to do with using floats. If you do mat1 = mat1.applyfunc(Integer), you get the correct solution. The problem also exists when using mat1.rref(). This is clearly a bug. Can you report it at code.google.com/p/sympy/issues/list? Aaron Meurer > > So it looks like there are infinite solutions. I don't spend much time > working with the individual solver routines, so I'm not sure how you > should pass the variables, but perhaps you can start by reading the > docstring (help(solve_linear_system)) where you will see that you > should be passing an augmented system. I don't think you are doing > that. > > /c > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sympy@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.