The package rootoned on http://r-forge.r-project.org/R/?group_id=395
has an all-R version of zeroin (the algorithm of uniroot). This should also be in Rmpfr by Martin M., as it was set up for that use. I suspect it can be vectorized fairly easily. However, it may be simpler to write, or else abstract from that code, a vectorized false position or secant code (same formula, FP must have end points with opposite sign function values, so is `safer'). This avoids the bisection step and simplifies things, but may be a bit less efficient sometimes.

JN



Date: Fri, 9 Nov 2012 14:58:55 +0000
From: Ravi Varadhan <ravi.varad...@jhu.edu>
To: "'ivo.we...@gmail.com'" <ivo.we...@gmail.com>
Cc: "r-help@r-project.org" <r-help@r-project.org>
Subject: Re: [R] vectorized uni-root?
Message-ID:
        <2f9ea67ef9ae1c48a147cb41be2e15c32e8...@dom-eb-mail1.win.ad.jhu.edu>
Content-Type: text/plain

Hi Ivo,

The only problem is that uniroot() actually uses Brent's algorithm, and is based on the C code from netlib (there is also Fortran code available - zeroin.f). Brent's algorithm is more sophisticated than a simple bisection approach that you have vectorized. It combines bisection and secant methods along with some quadratic interpolation. The idea behind this hybrid approach (which by the way is a fundamental theme in all of numerical analysis) is to get faster convergence while not sacrificing the global convergence of bisection.

So, the existing uniroot() will not be deprecated unless you can vectorize Brent's hybrid root-finding approach!

Best,
Ravi

______________________________________________
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.

Reply via email to