Re: [R] functions with function inputs and optimisation

2013-05-11 Thread Uwe Ligges
On 10.05.2013 08:19, Sachinthaka Abeywardana wrote: Hi all, Would be great if you could help me get my head around the "further arguemnts" in the optim function. Let's say we have f and g as shown: f<-function(x,a,b){(x-a)^2+b} optim(100,fn=f,gr=NULL,2,5) #the NULL is annoying g<-function(x

[R] functions with function inputs and optimisation

2013-05-09 Thread Sachinthaka Abeywardana
Hi all, Would be great if you could help me get my head around the "further arguemnts" in the optim function. Let's say we have f and g as shown: f<-function(x,a,b){(x-a)^2+b} optim(100,fn=f,gr=NULL,2,5) #the NULL is annoying g<-function(x,a){2*(x-a)} optim(100,fn=f,gr=g,2,5) 1. How does opti