Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Compile[] and NMaximize[]' topicStudent Support Forum > General > Archives > "Compile[] and NMaximize[]"

Next Comment >Help | Reply To Topic
Author Comment/Response
dami
10/28/09 5:15pm

Hi all,

Consider the following function:
f = Compile[{{x, _Real}}, x-x^2];

When I call:
NMaximize[f[x], x]

I get the error:
CompiledFunction::cfsa: Argument x at position 1 should be a machine-size real number.

Does anybody knows how to fix that? I assume NMaximize is passing a symbolic x to the compiled function. Note that setting:
SetSystemOptions["EvaluateNumericalFunctionArgument" -> False];

solves the problem if I use FindMaximum, but not if I use NMaximize. Any advice would be extremely appreciated. Thank you very much!

URL: ,

Subject (listing for 'Compile[] and NMaximize[]')
Author Date Posted
Compile[] and NMaximize[] dami 10/28/09 5:15pm
Re: Compile[] and NMaximize[] Peter Pein 10/31/09 06:31am
Next Comment >Help | Reply To Topic