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

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Peter Pein
10/31/09 06:31am

Hi,

the good old "NumericQ-trick" helps:
In[1]:= f[z_?NumericQ]:=Compile[{{x,_Real}},x x^2][z];
In[2]:= NMaximize[f[x],x]
Out[2]= {0.25,{x->0.5}}

this functiona can't be used to find exact values:

In[3]:= Maximize[f[x],x]
Out[3]= Maximize[f[x],x]

In[4]:= Maximize[x-x^2,x]
Out[4]= {1/4,{x->1/2}}

HTH,
Peter


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
< Previous CommentHelp | Reply To Comment | Reply To Topic