Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Maximisation question

12 views
Skip to first unread message

J.Jack.J.

unread,
May 18, 2012, 5:24:50 AM5/18/12
to
For any integer j, suppose we have a function f(j). Then how would I
find the highest f(i) such that 100 <= f(i) <0 ?
With thanks in advance.

Bob Hanlon

unread,
May 19, 2012, 5:46:36 AM5/19/12
to
I'm guessing that you meant 100 <= i < 0 rather than 100 <= f(i) < 0

f[n_] := PDF[BinomialDistribution[100, .1], n]

Maximize[{f[j], 0 < j <= 100}, j, Integers]

{0.131865, {j -> 10}}

Maximize[{f[j], 0 < j <= 100, Element[j, Integers]}, j]

{0.131865, {j -> 10}}

If f and cons are linear or polynomial, Maximize will always find a
global maximum. In cases where Maximize only finds a local maxima,
you can use an exhaustive search.

data = Table[{n, f[n]}, {n, 0, 100}];

Select[data, #[[2]] == Max[data[[All, 2]]] &]

{{10, 0.131865}}


Bob Hanlon

Bill Rowe

unread,
May 19, 2012, 5:47:37 AM5/19/12
to
On 5/18/12 at 5:23 AM, jack.j...@googlemail.com (J.Jack.J.)
wrote:

>For any integer j, suppose we have a function f(j). Then how would I
>find the highest f(i) such that 100 <= f(i) <0 ? With thanks in
>advance.

Use NMaximize. For example:

In[14]:= NMaximize[{4 x - .57 x^2, x \[Element] Integers}, {x}]

Out[14]= {6.88,{x->4}}

and by doing

In[15]:= Solve[D[4 x - .57 x^2, x] == 0, x]

Out[15]= {{x->3.50877}}

you can see the true maximum is not an integer


Oleksandr Rasputinov

unread,
May 19, 2012, 5:52:43 AM5/19/12
to
Exists[f[i], i \[Element] Integers, 100 <= f[i] < 0]

False

While not wishing to be unkind or discouraging, may I suggest that, rather
than repeatedly asking for the code necessary to solve a given problem,
you instead focus on specifying your problems correctly to start with? So
far all three of the problems you have asked about have been misstated, as
well as being very similar to one another such that one wonders if you are
really asking for help in good faith or just hoping for someone to solve
your problem for you.

Best,

O. R.

J.Jack.J.

unread,
May 19, 2012, 5:54:14 AM5/19/12
to
Sorry that should be 100 <= f(i) < 200.
f(j) is a function for j ranging over all the integers.

0 new messages