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

Description Usage Arguments Value Author(s) References Examples

Description

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

Usage

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

Author(s)

Ozgur Asar, Ozlem Ilk

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

1
2
3
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)

Example output

Iteration: 1 ; Result= 1.318883
Iteration: 2 ; Result= 0.8868571
Iteration: 3 ; Result= 0.6656977
Iteration: 4 ; Result= 0.6085951
Iteration: 5 ; Result= 0.6054324
Iteration: 6 ; Result= 0.6054234
Solution: 0.6054234
[1] 0.6054234

OOmisc documentation built on May 1, 2019, 10:17 p.m.

Related to damped.newton in OOmisc...