Learn R Programming

OOmisc (version 1.2)

damped.newton: A function to find the roots of univariate functions.

Description

Finds roots of univariate functions by modifying the usual Newton-Raphson method by decreasing the step sizes when necessary.

Usage

damped.newton(fun, derf, x0, eps, maxit = 20, damp = seq(0, 40),silent=TRUE)

Arguments

fun
a function for which the root is searched.
derf
a function which is the first derivative of the function to be solved.
x0
a numeric value to be used to start the algorithm.
eps
a numeric value to be considered as the tolerance for convergence of the algorithm.
maxit
a numeric value which denotes maximum number of iterations to be consumed.
damp
a vector beginning from zero and increasing by one unit to decrease the step sizes.
silent
a logical statement which decides whether the iterations should be printed.

Value

Returns a numeric result of the root.

References

Bose, K. S. (2008). Numeric Computing in Fortran. Alpha Science.

Conte, S. D., de Boor, C. (1980). Elementary Numerical Analysis: An Algorithmic Approach, third edition. New York: McGraw-Hill Publications.

Ilk, O. (2011). R Yazilimina Giris [Introduction to R Language]. ODTU Yayincilik [METU Press].

Examples

Run this code
f1=function(x) x^3+sqrt(x)-1
df1=function(x) 3*x^2+(1/2)*x^(-1/2)
damped.newton(f1,df1,2,10^-10,maxit=40,silent=FALSE)

Run the code above in your browser using DataLab