enrico.foscolo2 at libero.it
2009-Apr-09 12:42 UTC
[R] Find a zero of a composition of functions
Good morning to all, I should find the zero of a specific function, func(x,f. me,c,t)=x+f.me*c-t where 'c' and 't' are constants and 'f.me' is an other function of 'x'. Actually, I am interested in considering 'f.me' as an expression(). Namely, uniroot.me<-function(f.me,c,t){ func<-function(x, f.me,c,t) x+eval(f.me)*c-t uniroot(func,c(0,1),f.me=f.me,c=c,t=t)$root } uniroot.me(expression(x*(1-x)),c=1,t=1) For instance, let me suppose that 'f.me=expression(x^a*(1-x))'. How should I do in order to introduce the new constant 'a' in function 'uniroot.me'? Thank you very much, Enrico Foscolo