MathGroup Archive 2010

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

Search the Archive

Re: Simultaneous -> Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113190] Re: Simultaneous -> Matrix
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Sun, 17 Oct 2010 06:10:16 -0400 (EDT)
  • References: <i9cn12$k6n$1@smc.vnet.net>

Brussels Sprout wrote:

> Is there a function for converting a set of simultaneous equations to a matrix equation?
>

If you want to convert a system of linear equations, you may use
CoefficientArrays as in this little example:

eqs = {a x + b y + c z == u,
  	d x + e y + f z == v,
  	g x + h y + k z == w }

X={x,y,z};


In:= cA=CoefficientArrays[eqs,X]
Out= {SparseArray ....}

Normal makes a Matrix out of the sparse Array and the following will
produce the vector r and the matrix A such that A.X+r==0

In:= {r,A}=Normal[cA]

Out={{-u, -v, -w}, {{a, b, c}, {d, e, f}, {g, h, k}}}

You get the old system of equations back like this:

In:= A.x == -r //Thread

Out= {a x + b y + c z == u,
      d x + e y + f z == v,
      g x + h y + k z == w}

This is the given system eqs.      
-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Special permutation pattern ascending groups sum of subset
  • Next by Date: Platform LSF and Mathematica
  • Previous by thread: Re: Simultaneous -> Matrix
  • Next by thread: evaluation of a non-visible dynamic[]