Re: Number Theory - Chinese Remainder Theorem
- To: mathgroup at smc.vnet.net
- Subject: [mg27976] Re: [mg27954] Number Theory - Chinese Remainder Theorem
- From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
- Date: Tue, 27 Mar 2001 01:26:12 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Just open the package NumberTheoryFunctions.m which is one of the Standard Packages provided with Mathematica and look at the definition of the ChineseRemainder function. Alternatively get hold of Stan Wagon's book "Mathematica in Action" or of Bressoud and Wagon "Computational Number Theory". -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ http://sigma.tuins.ac.jp/ on 3/26/01 11:27 AM, lee.stone at hqasc.army.mil at lee.stone at hqasc.army.mil wrote: > Hello, > > I am studying the Chinese Remainder Theorem. I am using have been using the > following code to solve CRT problems. > > PairwiseQ[m-List] := Apply[LCM, m] == Apply[Times, m] > > CRT[a_, m_] := Module[{M = Apply[Times, m]}, > If[PairwiseQ[m], Mod[Apply[Plus, a * PowerMid[M/m, -1, m] * M/m], M], > {}]] > > I would like modify this code to also be able to solve moduli that are not > relatively prime and to return the empy set ({}) if the congurences have no > solution. > > Lee Stone > >