This seems useful, but it is important to note that the approach may not work well unless the system of nonlinear equations is very well behaved and a good starting point is chosen. A good explanation of the problems with this exact approach, that is adding up the sums of squares of the individual functions, is described in Numerical Recipes for C, second edition, p 382 (see http://www.nrbook.com/a/bookcpdf.php) Briefly there will often be a great number of local minima even when there is only a single root of the original equations.
Rob Ravi Varadhan wrote: > Hi, > > I have written a simple function to solve a system of nonlinear equations. I > have called it nlsolve(). It actually minimizes the squared-norm of the set > of functions by calling optim(). It uses the BFGS algorithm within optim(). > Apart from this restriction, the user can pass all the arguments available > in optim(). All the control parameters can be passed as in the call to > optim(). I have attached a text file containing the source for nlsolve() > and also a number of test problems illustrating the use of nlsolve(). Any > feedback and suggestions to improve it are welcome. > > Hope this is useful. > > Best, > Ravi. > > ---------------------------------------------------------------------------- > ------- > > Ravi Varadhan, Ph.D. > > Assistant Professor, The Center on Aging and Health > > Division of Geriatric Medicine and Gerontology > > Johns Hopkins University > > Ph: (410) 502-2619 > > Fax: (410) 614-9625 > > Email: [EMAIL PROTECTED] > > Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html > > > > ---------------------------------------------------------------------------- > -------- > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan > Sent: Wednesday, June 20, 2007 5:23 PM > To: r-help@stat.math.ethz.ch > Subject: [R] Creatiing an R package for solving nonlinear system of > equations was: RE: finding roots of multivariate equation > > Hi All, > > Replying to this and numerous other requests in the past has made me realize > that a nonlinear solver is very much needed for R users. I have > successfully used a nonlinear solver based on the spectral gradient method, > in FORTRAN. I can readily translate that to R and make it available as an R > function, but what I would really like to do is to make that into a package. > I can provide the R function and several test examples. But I am not good > at creating a good/reliable package. So, it would be ideal if one of the R > gurus is interested in collaborating with me on this project. Any one > interested? > > Ravi. > ---------------------------------------------------------------------------- > ------- > > Ravi Varadhan, Ph.D. > > Assistant Professor, The Center on Aging and Health > > Division of Geriatric Medicine and Gerontology > > Johns Hopkins University > > Ph: (410) 502-2619 > > Fax: (410) 614-9625 > > Email: [EMAIL PROTECTED] > > Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html > > > > ---------------------------------------------------------------------------- > -------- > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Bill Shipley > Sent: Wednesday, June 20, 2007 1:37 PM > To: r-help@stat.math.ethz.ch > Subject: [R] finding roots of multivariate equation > > Hello, > I want to find the roots of an equation in two variables. I am aware of the > uniroot function, which can do this for a function with a single variable > (as I > understand it...) but cannot find a function that does this for an equation > with more than one variable. I am looking for something implementing > similar > to a Newton-Raphson algorithm. > Thanks. > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > ______________________________________________ R-help@stat.math.ethz.ch 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.