MathGroup Archive 2006

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

Search the Archive

Re: Problems with NMaximize.


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.