muller.RdMuller's root finding method, similar to the secant method, using a parabola through three points for approximating the curve.
muller(f, p0, p1, p2 = NULL, maxiter = 100, tol = 1e-10)Generalizes the secant method by using parabolic interpolation between three points. This technique can be used for any root-finding problem, but is particularly useful for approximating the roots of polynomials, and for finding zeros of analytic functions in the complex plane.
List of root, fval, niter, and reltol.
Muller's method is considered to be (a bit) more robust than Newton's.
Pseudo- and C code available from the `Numerical Recipes'; pseudocode in the book `Numerical Analysis' by Burden and Faires (2011).
muller(function(x) x^10 - 0.5, 0, 1) # root: 0.9330329915368074
#> $root
#> [1] 0.933033
#>
#> $fval
#> [1] -5.551115e-17
#>
#> $niter
#> [1] 9
#>
#> $reltol
#> [1] 5.828663e-11
#>
f <- function(x) x^4 - 3*x^3 + x^2 + x + 1
p0 <- 0.5; p1 <- -0.5; p2 <- 0.0
muller(f, p0, p1, p2)
#> $root
#> [1] -0.3390928-0.4466301i
#>
#> $fval
#> [1] 2.220446e-16-5.551115e-17i
#>
#> $niter
#> [1] 10
#>
#> $reltol
#> [1] 4.568803e-16
#>
## $root
## [1] -0.3390928-0.4466301i
## ...
## Roots of complex functions:
fz <- function(z) sin(z)^2 + sqrt(z) - log(z)
muller(fz, 1, 1i, 1+1i)
#> $root
#> [1] 0.2555197+0.8948303i
#>
#> $fval
#> [1] -3.608225e-16+2.220446e-16i
#>
#> $niter
#> [1] 8
#>
#> $reltol
#> [1] 3.656538e-13
#>
## $root
## [1] 0.2555197+0.8948303i
## $fval
## [1] -4.440892e-16+0i
## $niter
## [1] 8
## $reltol
## [1] 3.656219e-13