MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: problem with EvenQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105950] Re: [mg105923] problem with EvenQ
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 27 Dec 2009 02:26:49 -0500 (EST)
  • References: <8534260.1261873319290.JavaMail.root@n11>

The trouble is that EvenQ[y] returns False unless y is manifestly an even
integer.

You could obtain a result in the following manner:

FindInstance[2 y < 100 \[And] y == 2 x, {x, y}, Integers, 3]
{{x -> 24, y -> 48}, {x -> -247, y -> -494}, {x -> -245, y -> -490}}

Here is another example. Find some odd integers between 6 and 25.

FindInstance[6 <= y <= 25 \[And] y == 2 x + 1, {x, y}, Integers, 4];
y /. %
{23, 7, 21, 17}

Here is the case using a RandomSeed. This gives different results each time
you evaluate.

FindInstance[6 <= y <= 25 \[And] y == 2 x + 1, {x, y}, Integers, 4,
  RandomSeed -> RandomInteger[{0, 100}]];
y /. %
{13, 21, 11, 17}  one example

But if we ask for just a single instance then RandomSeed appears not to
work. That looks like a bug to me.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/ 



From: dvholten [mailto:info at dvholten.de] 

Hi folks,
i puzzled all afternoon, but couldnt get this one solved:
what is the proper way of using EvenQ[] within FindInstance[] ?
I cant use it like
    FindInstance[ y*2 < 100 && EvenQ[y], {y}, Integers ]
or even
    FindInstance[ EvenQ[y], {y}, Integers ]

Actually, the expression used in FindInstance is much more complex,
but i condensed the problem to be EvenQ[] - i expect some kind of 
special notation to help here.

thanks
dvh




  • Prev by Date: Re: Figure quality
  • Next by Date: Re: Replace and ReplaceAll -- simple application
  • Previous by thread: Re: problem with EvenQ
  • Next by thread: Replace and ReplaceAll -- simple application