Re: Diophantic equations
- To: mathgroup at smc.vnet.net
- Subject: [mg32769] Re: [mg32746] Diophantic equations
- From: BobHanlon at aol.com
- Date: Sat, 9 Feb 2002 05:11:39 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2/8/02 4:22:23 AM, ulbrich at biochem.mpg.de writes: >I try to solve equations where only integers are allowed, like > >a + b + 10 c = 100 >5 a + 2 b + c = 100 > >a, b, c should be integers and positve. > >How can I do this? Using brute force Needs["Algebra`InequalitySolve`"]; var = {a,b,c}; ] eqn={a+b+10 c==100,5 a+2 b+c==100}; ineqEqn = (eqn /. Equal -> LessEqual) {a + b + 10*c <= 100, 5*a + 2*b + c <= 100} rng = Sort[((InequalitySolve[ineqEqn /. {#[[1]]->1,#[[2]]->1}, #[[3]]] /. x_?NumberQ -> Floor[x])& /@ NestList[RotateLeft[#,1]& , var, 2])] /. LessEqual[x_,y_] :> Range[1,y]; soln = Thread[var->#]& /@ Select[Flatten[Outer[List,Sequence@@rng], 2], And@@(eqn /. Thread[var->#])&] {{a -> 11, b -> 19, c -> 7}} eqn /. soln {{True, True}} Bob Hanlon Chantilly, VA USA