Re: Newbie solving mod M linear equations
- To: mathgroup at smc.vnet.net
- Subject: [mg29075] Re: Newbie solving mod M linear equations
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sun, 27 May 2001 18:04:42 -0400 (EDT)
- References: <9epn86$1na@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
> I can't figure out how to use mathematica to solve systems of linear > equations in which all the arithemetic should be performed modulo m. Bob, The queries ?*Linear* ?*Solve* will each lead to LinearSolve[{{0, 1, 1 ,1 ,0}, {1,0, 0, 1, 1}, {1, 0, 0 ,1, 0}, {1, 1, 1, 0, 1}, {0, 1, 0, 1, 0}},{1,2,3,0,1}, Modulus->5] {4,2,0,4,4} and Solve[{{{0,1,1,1,0},{1,0,0,1,1},{1,0,0,1,0},{1,1,1,0,1},{0,1,0,1,0}}.{a,b,c, d, e}=={1,2,3,0,1}, Modulus==5},{a,b,c,d,e}, Mode->Modular] {{Modulus -> 5, c -> 0, e -> 4, a -> 4, b -> 2, d -> 4}} {a,b,c,d,e}/.%[[1]] {4,2,0,4,4} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Bob Harris" <nitlion at mindspring.com> wrote in message news:9epn86$1na at smc.vnet.net... > Howdy, > > I can't figure out how to use mathematica to solve systems of linear > equations in which all the arithemetic should be performed modulo m. Can > anyone give me a few pointers? > > For example, I might want to solve this system, modulo 5 (this is matrix > times vector = vector): > > [ 0 1 1 1 0 ][A] [1] > [ 1 0 0 1 1 ][B] [2] > [ 1 0 0 1 0 ][C] = [3] (mod 5) > [ 1 1 1 0 1 ][D] [0] > [ 0 1 0 1 0 ][E] [1] > > The solution to this is > > [A] [4] > [B] [2] > [C] = [0] > [D] [4] > [E] [4] > > I know how to solve these things manually, but it gets rather difficult on > the larger systems that I actually use. > > Any help would be appreciated. > > Thanks, > Bob Harris > >