Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Simultaneous -> Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113181] Re: Simultaneous -> Matrix
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 17 Oct 2010 06:05:18 -0400 (EDT)

Clear[a, b, c]

eqns = {a + 2 b + 3 c == 19,
   3 a  + 5 c == 29,
   -2 a + b - c == -8};

vars = Cases[eqns, _Symbol?(! NumericQ[#] &),
   Infinity] // Union

{a, b, c}

m = Outer[Last[CoefficientList[#1, #2]] &,
   First /@ eqns, vars] /.
  Thread[vars -> 0]

{{1, 2, 3}, {3, 0, 5}, {-2, 1, -1}}

rhs = Last /@ eqns

{19, 29, -8}

eqns == Thread[m.vars == rhs]

True

soln = Thread[vars -> LinearSolve[m, rhs]]

{a -> 3, b -> 2, c -> 4}

soln == Solve[eqns, vars][[1]]

True


Bob Hanlon

---- Brussels Sprout <rayoconnorsam at gmail.com> wrote: 

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




  • Prev by Date: Re: Re: something nice I found today, return multiple
  • Next by Date: Re: Simultaneous -> Matrix
  • Previous by thread: Simultaneous -> Matrix
  • Next by thread: Re: Simultaneous -> Matrix