On Thu, Apr 28, 2011 at 11:08:23PM -0400, Chee Chen wrote: > Dear All, > I would like to define a function: f(x,y,z) with three arguments x,y,z, such > that: given values for x,y, f(x,y,z) is still a function of z and that I am > still allowed to find the root in terms of z when x,y are given. > For example: f(x,y,z) = x+y + (x^2-z), given x=1,y=3, f(1,3,z)= 1+3+1-z is > a function of z, and then I can use R to find the root z=5.
If solving the equation for z with given x and y is the main purpose, then try the following f <- function(x,y,z) x+y + (x^2-z) uniroot(f, c(0, 10), x=1, y=3)$root [1] 5 Hope this helps. Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.