Hi Toros, It is actually quite easy to do this with existing real-root finders. If you want to solve for F(z) = 0, where z = x + iy, you simultaneously solve for the zeros of the real and imaginary part of F.
Here are a couple of examples using the package "BB": fn1 <- function(x, a){ z <- x[1] + 1i * x[2] f <- exp(z) + a c(Re(f), Im(f)) } fn2 <- function(x, a){ z <- x[1] + 1i * x[2] f <- sin(z)^2 + sqrt(z) - log(z) c(Re(f), Im(f)) } require(BB) # First example > BBsolve(par=c(1,1), fn=fn1, a=1) Successful convergence. $par [1] -4.799024e-10 3.141593e+00 $residual [1] 4.819472e-10 $fn.reduction [1] 0.0002550771 $feval [1] 81 $iter [1] 5 $convergence [1] 0 $message [1] "Successful convergence" $cpar method M NM 2 50 1 So, the complex root is: 0 + i*pi, as you might have guessed. # Second example > BBsolve(par=c(1,1), fn=fn2) Successful convergence. $par [1] 0.2555197 0.8948303 $residual [1] 9.079212e-08 $fn.reduction [1] 0.0002494436 $feval [1] 168 $iter [1] 92 $convergence [1] 0 $message [1] "Successful convergence" $cpar method M NM 2 50 1 Here the complex root is: 0.2555 + i*0.8948. In these two examples the function F(z) is scalar. We can readily extend this to vector F using the method that I just described. Hope this helps, Ravi. -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Toros Caglar Sent: Wednesday, September 15, 2010 11:33 PM To: r-help@r-project.org Subject: [R] finding complex roots in R I am looking for a way to find the roots of a non-polynomial expression. I know R has a few ways to deal with polynomials, but, I could not find a method that deals with functions involving e^(x) type arguments, that have complex roots as well as real roots. Any ideas? Thanks, Toros ______________________________________________ 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. ______________________________________________ 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.