Ok. Then there are two problems witht the inputs you're using:

(1) One-dimensional optimize doesn't take a single starting point, it takes a 
bracket in which you think the minimum occurs.

(2) You need to use floating point inputs.

Things will work if you do optimize(f, -10.0, 10.0) or something similar.

 -- John

On Jul 8, 2014, at 12:03 PM, Mathieu Taschereau-Dumouchel <[email protected]> 
wrote:

> Thanks for the quick reply!
> 
> My problem is one-dimensional. Here is the code:
> 
> using Optim
> a=2
> f(x)=-(x-a)^2
> optimize(f,3)
> 
> 
> I get:
> ERROR: no method optimize(Function, Int64)
> 
> I am running Version 0.3.0-prerelease+3884 (2014-06-25 10:41 UTC) and have 
> updated all packages.
> 
> Thanks for your help
> Mathieu
> 
> On Tuesday, July 8, 2014 2:48:24 PM UTC-4, John Myles White wrote:
> This should work, except that you're not providing any initial values for x. 
> Is your problem one-dimensional or multi-dimensional? 
> 
>  -- John 
> 
> On Jul 8, 2014, at 11:44 AM, Mathieu Taschereau-Dumouchel <[email protected]> 
> wrote: 
> 
> > I am trying to optimize a simple function that takes a parameter as an 
> > argument. Something like: 
> > 
> > a=2 
> > f(x)=-(x-a)^2 
> > optimize(f) 
> > 
> > Is there any way to do this? I have played quite a bit with optimize 
> > without success. 
> > 
> > Thanks a lot 
> > Mathieu 
> 

Reply via email to