Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Problems with NMaximize.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69172] Re: Problems with NMaximize.
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 1 Sep 2006 06:40:17 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ed6935$jie$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nacho wrote:
[...snipped...]
> I don't know how to say Mathematica that a variable can take just some
> values (as for r being even), but I just said it is between 0 and 16.

In[1]:=
Or @@ Thread[r == {0, 2, 4, 6, 8, 10, 12, 14, 16}]

Out[1]=
r == 0 || r == 2 || r == 4 || r == 6 || r == 8 ||

   r == 10 || r == 12 || r == 14 || r == 16

In[2]:=
NMaximize[{1 + 1/(r - 1),
    Or @@ Thread[r == {0, 2, 4, 6, 8, 10, 12, 14,
        16}]}, {r}]

Out[2]=
{2., {r -> 2.}}

Regards,
Jean-Marc


  • Next by Date: Re: efficient term collection algorithm
  • Next by thread: Re: Problems with NMaximize.