Re: Simplifying with assumptions
- To: mathgroup at smc.vnet.net
- Subject: [mg49057] Re: Simplifying with assumptions
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Tue, 29 Jun 2004 04:50:49 -0400 (EDT)
- Organization: The University of Western Australia
- References: <200406250658.CAA12398@smc.vnet.net> <cbi7jv$lep$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <cbi7jv$lep$1 at smc.vnet.net>, Daniel Lichtblau <danl at wolfram.com> wrote: > Mietek Bak wrote: > > Hello, > > > > I'm a complete newcomer to Mathematica, so please excuse this possibly > > silly question. > > > > I'm trying to determine if a formula will ever give an integer result, > > assuming that all variables used in it are integer. I've been searching > > through the built-in documentation, but my best guess didn't really do > > anything: > > > > Simplify[Element[Sqrt[48 - n^2 + 8*x],Integers],Element[{n, x},Integers]] > > > > It would be best if I could somehow determine the set of combinations of > > variables that would give an integer result -- if there are any. Is > > there a way to do that in Mathematica? > > > > Thanks in advance, > > Mietek Bak. > > > I'm not sure what would be a good way to do this sort of thing in > general. For relatively simple examples you can make progress if you > assign integer values to one parameter, as below. > > In[7]:= InputForm[Table[ > Reduce[{48-n^2+8*x==k^2, Element[{x,k},Integers]}, {x,k}], {n,10}]] > > Out[7]//InputForm= > {False, (C[1] \[Element] Integers && x == -5 + 4*C[1] + 8*C[1]^2 && > k == 2 + 8*C[1]) || (C[1] \[Element] Integers && > x == -1 + 12*C[1] + 8*C[1]^2 && k == 6 + 8*C[1]), False, > (C[1] \[Element] Integers && x == -4 + 8*C[1]^2 && k == 8*C[1]) || > (C[1] \[Element] Integers && x == -2 + 8*C[1] + 8*C[1]^2 && > k == 4 + 8*C[1]), False, (C[1] \[Element] Integers && > x == -1 + 4*C[1] + 8*C[1]^2 && k == 2 + 8*C[1]) || > (C[1] \[Element] Integers && x == 3 + 12*C[1] + 8*C[1]^2 && > k == 6 + 8*C[1]), False, (C[1] \[Element] Integers && x == 2 + > 8*C[1]^2 && > k == 8*C[1]) || (C[1] \[Element] Integers && x == 4 + 8*C[1] + > 8*C[1]^2 && > k == 4 + 8*C[1]), False, (C[1] \[Element] Integers && > x == 7 + 4*C[1] + 8*C[1]^2 && k == 2 + 8*C[1]) || > (C[1] \[Element] Integers && x == 11 + 12*C[1] + 8*C[1]^2 && > k == 6 + 8*C[1])} There is a pattern in the coefficients, easily determined using InterpolatingPolynomial. After some manipulation I get that the general solution can be expressed in the following form: sol[m_,p_] = {{m,p} \[Element] Integers && n == 4p && x == 8m^2 + 2p^2 - 6 && x == 8m^2 + 8m + 2p^2 - 4 || n == 4p + 2 && x == 8m^2 + 4m + 2p^2 + 2p - 5 && x == 8m^2 + 12m + 2p^2 + 2p - 1} Tabulating values for various m and p, vals = Table[ToRules /@ sol[m, p], {m, -5, 5}, {p, -7, 7}] we check that Sqrt[48 - n^2 + 8 x] is an integer: Sqrt[48 - n^2 + 8 x] /. vals Cheers, Paul -- Paul Abbott Phone: +61 8 9380 2734 School of Physics, M013 Fax: +61 8 9380 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul
- References:
- Simplifying with assumptions
- From: "Mietek Bak" <mietek@icpnet.pl>
- Simplifying with assumptions