Message Boards Message Boards

0
|
2578 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

NMaximize an element of a Table

Posted 11 years ago
Hi,

Can you tell me what is wrong with it ?

Clear
Ntest[m_?NumericQ] :=
  Table[NIntegrate[m*i, {x, 0, 1}], {i, 1, 10}];


AbsoluteTiming[NMaximize[{Ntest[[2]], 500 <= m <= 1500}, {m}]]

I have the following error :

Part::partw: Part 2 of Ntest does not exist. >>
Part::partw: Part 2 of Ntest does not exist. >>
Part::partw: Part 2 of Ntest does not exist. >>
General::stop: Further output of Part::partw will be suppressed during this calculation. >>

I guess the problem comes from ?NumericQ, but I must put it (or the Integrand is non numerical fot NMaximize)

Thank you,
Mich
POSTED BY: Thibault Michel
2 Replies
Function arguments are wrapped in one pair of square brackets.
List indices are wrapped in two pairs of square brackets.

You called the function Ntest with two pairs,
AbsoluteTiming[NMaximize[{Ntest[[2]], 500 <= m <= 1500}, {m}]]
POSTED BY: Bruce Miller
It looks as though you don't have an argument for Ntest inside NMaximize.  However, copying  Mathematica code into a text window can corrupt the code.
I suggest you repost your code in a "spikey" window.
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract