Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: System of linear equation

  • To: mathgroup at
  • Subject: [mg112351] Re: System of linear equation
  • From: Peter Pein <petsie at>
  • Date: Fri, 10 Sep 2010 04:49:56 -0400 (EDT)
  • References: <i6a5hh$kmp$>

Am Thu, 9 Sep 2010 08:23:13 +0000 (UTC)
schrieb mfduqued <mfduqued at>:

> Hi community,
> I have a system of linear equation 8x8. So I use LinearSolve but I
> obtain
> LinearSolve::matrix: Argument (<<1>>) at position 1  is not a nonempty
> rectangular matrix.
> I don't know why doesn't work this program.
> Please help.


Say you've got a system of equations like this:

Out[1]={4 a-4 c+9 d+2 e+7 x-9 y-6 z==2,4 a+5 c+7 d-7 e+5 x+9 y+7 z==3,-2
a-2 b+9 c-9 d+8 e+2 x+2 y+9 z==0,5 a-4 b+3 d-2 e+7 x+5 y+8 z==1,6 a+6
b+3 c+2 d+8 e+8 x+6 y-2 z==2,2 a-2 b-5 c+d-3 e-2 x+2 y+z==2,-2 a-3 b+4
c+3 d-2 e-x+4 y-4 z==-5,-6 a+6 b-c+9 d+3 e-9 x+6 y-3 z==9}

get the names of the variables:

In[2]:= vars=Variables[List@@@Flatten[eqns]]
Out[2]= {a,b,c,d,e,x,y,z}

and the coefficients:

In[3]:= mat=Coefficient[#,vars]&/@eqns[[All,1]]

call LinearSolve with this matrix and the right hand side of the

In[4]:= sol=LinearSolve[mat,eqns[[All,2]]]

and verify the result:

In[5]:= eqns/.Thread[vars->sol]
Out[5]= {True,True,True,True,True,True,True,True}


  • Prev by Date: Re: A slow start
  • Next by Date: Re: locating overlow/underflow (and the issue of accuracy)
  • Previous by thread: Re: System of linear equation
  • Next by thread: Display Workspace