Re: May we trust IntegerQ ?
- To: mathgroup at smc.vnet.net
- Subject: [mg107515] Re: May we trust IntegerQ ?
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Mon, 15 Feb 2010 05:48:26 -0500 (EST)
- References: <hl8t3l$26h$1@smc.vnet.net>
Artur wrote: > Procedure: find such x that ChebyshevT[x/2, x] isn't integer > aa = {}; Do[ If[IntegerQ[ChebyshevT[x/2, x]], , AppendTo[aa, x]], {x, 0, > 20}]; aa > and answer Mathematica is set: > {3, 5, 7, 9, 11, 13, 15, 17, 19} > where occered e.g. number 7 > N[ChebyshevT[7/2, 7],100] > 5042.00000000000000000000000000000000000000000000000000000000000000000\ > 0000000000000000000000000000000 > evidently is integer 5042 > Some comments ? > > Best wishes > Artur > > > > IntegerQ tests to see if an expression is a Mathematica integer, but it doesn't simplify the expression first. Thus ChebyshevT[7/2, 7] evaluates to Cos[(7*ArcCos[7])/2], which can be resolved to 5040 by using FullSimplify. IntegerQ[Cos[(7*ArcCos[7])/2]] correctly returns False. IntegerQ[FullSimplify[Cos[(7*ArcCos[7])/2]]] returns True. I guess you could wrap FullSimplify round your ChebyshevT call, but it is important to bear in mind that FullSimplify attempts to find a simplification where one exists, but cannot be guaranteed to do so. A numerical test may be safer. David Bailey http://www.dbaileyconsultancy.co.uk