       Re: Converting set of equations to matrix

• To: mathgroup at smc.vnet.net
• Subject: [mg26736] Re: Converting set of equations to matrix
• From: Brian Higgins <bghiggins at ucdavis.edu>
• Date: Fri, 19 Jan 2001 02:14:13 -0500 (EST)
• References: <9462b7\$gc8@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Helge,

Here is one way to do it if each equation consists of more than 1
term. In the set you gave your last equation reduces to 3a[0,2]=0. I
have modified it  for this illustration. I am sure the Mathematica
gurus have a slicker way that even works for your case.

myeqns = {3 a[0, 0] + 2 a[0, 2] + 4 a[2, 0] == 0,
-1 a[0, 0] + 0.3 a[2, 0] == 0,
4 a[0, 2] - 1 a[0, 1] == 0}

In:=
Map[Drop[#, -1] &, Map[Cases[#, x_?NumberQ, 3] &, eqns]]

Out=
{{3, 2, 4}, {-1, 0.3}, {-1, 4}}

Cheers,

Brian

In article <9462b7\$gc8 at smc.vnet.net>,
Helge Kreutzmann <helgek at studserv.stud.uni-hannover.de>
wrote:
> Hello !
> I have a set of equations I create following some rules, like
>
> 3 a[0,0] + 2 a[0,2] + 4 a[2,0] = 0
> -1 a[0,0] + 0.3 a[2,0] = 0
> 4 a[0,2] - 1 a[0,2] = 0
>
> The numbers of coefficients (the a[i,j]) is different in each run
> but fixed. For further calculations I would like to transform the
> above equations into the matrix
> {{3,2,4 },{-1,0,0.3},{0,4,-1}}
>
> Currently I have a list (called coeffli) where I can get the
equations
> from. The existing coefficients are stored in a second list (klist).
> I also have a list where the values i,j are stored (cplist).
>
> The above list I would create by
> For[i = 1, i <= Length[kflist], i++,
>   Print[Collect[coeffli[[cplist[[i]][]]][[cplist[[i]][]]], klist]]]
>
> I can create a list of the equations but I do not know how to tear
> apart the sum into matrix elements.
>
> Thanks
>
>         Helge
>
>

Sent via Deja.com
http://www.deja.com/

```

• Prev by Date: Re: Multiple choice question
• Next by Date: Solving a System of Nonlinear Equations with FindRoot
• Previous by thread: Re: Converting set of equations to matrix