# FindMaximum inconsistency

The code below seems to work for n<11. But for n=11, and above, it outputs newa then just outputs "beep" sound.

WhyTheBeep says "The kernel Local has quit (exited) during the course of an evaluation.".

On two separate occasions, (after making trivial changes) it gave the correct output for n=11. I then increasing n and it failed again. After setting n=11 again, it it failed to output and gave the "beep" sound again. Nothing was altered other than n between success and failure in this instance.

Why the inconsistency/problem with n>10? (I'm using Mathematica 8.0 on Windows7)

Any help would be much appreciated.

n = 10
c = 1.
e = 5.

newa = Table[(2 - i) Subscript[p, m] + (i - 1)/n, {m, 2 n + 2}, {i, 2}]

FindMaximum[
{((Subscript[p, 2 n + 2] - c (1 - Subscript[p, 2 n + 1]))/(Subscript[p, 2 n + 1])),
Subscript[p, 2 n + 2] == Sum[((n + 1) - m) Subscript[p, m] Subscript[p, n + m], {m, 1, n}],
Subscript[p, 2 n + 1] == Sum[Subscript[p, m] Subscript[p, m + n], {m, 1, n}],
Table[Subscript[p,m] == (Subscript[p,2 n + 1] (1 - Subscript[p, m + n]))/(((e*n)/(1 +   e)) Subscript[p, n + m] - (1 - Subscript[p, n + m])^2), {m, n}],
Table[Subscript[p, m] >= 0, {m, 2 n}],
Table[Subscript[p, m] <= 1, {m, 2 n}],
Sum[Subscript[p, m], {m, 1, n}] == 1
}, newa, MaxIterations -> 10000]

-
Care to share your system specs (OS, RAM etc.)? –  Yves Klett Apr 12 '13 at 9:41
This might help. Make the values for {c,e] exact, and change the relevant constraint to Table[Numerator[ Together[-Subscript[p, m] + (Subscript[p, 2 n + 1] (1 - Subscript[p, m + n]))/(((e*n)/(1 + e)) Subscript[p, n + m] - (1 - Subscript[p, n + m])^2)]] == 0 –  Daniel Lichtblau Jan 13 at 16:18

It seems to me that you have probably run into a bug in Mathematica 8. For some reason not entirely clear to me, when n is large, FindMaximum becomes deeply recursive. With n = 12, it hits $RecursionLimit, i.e. 256 recursive calls in version 8. If you have noticed this and set $RecursionLimit larger, or even infinite, then that could easily explain the kernel crashes you observe.
Interestingly, version 9 does not show the same behavior. Although its default $RecursionLimit is larger at 1024, setting $RecursionLimit = 64 does not produce any messages relating to this, even with n = 12. However, 10 000 iterations is not enough actually to converge to the maximum in this case.
My suspicion (and it is only that) would be that this problem becomes sharply more difficult for n = 12, so that FindMaximum performs so many recursive subdivisions of the search space (or a similar kind of recursive operation) as to actually be problematic in version 8. In version 9, the behavior of FindMaximum seems to have been changed so as not to be as deeply recursive under the same circumstances, so that the problem is avoided.
+1 for pointing out the \$RecursionLimit and FindMaximum changes. –  Alexey Popkov Jan 13 at 6:22