[R] vectorized uni-root?

ivo welch ivo.welch at gmail.com
Thu Nov 8 16:05:48 CET 2012


dear R experts--- I have (many) unidimensional root problems.  think

  loc.of.root <- uniroot( f= function(x,a) log( exp(a) + a) + a,
c(.,9e10), a=rnorm(1) ) $root

(for some coefficients a, there won't be a solution; for others, it
may exceed the domain.  implied volatilities in various Black-Scholes
formulas and variant formulas are like this, too.)

except I don't need 1 root, but a few million.  to get so many roots,
I can use a for loop, or an lapply or mclapply.  alternatively,
because f is a vectorized function in both x and a, evaluations for a
few million values will be cheap.  so, one could probably write a
clever bisection search here.

does a "vectorized" uniroot exist already?

/iaw



More information about the R-help mailing list