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?