# newton: A function to find the roots of univariate functions. In OOmisc: Ozgur-Ozlem Miscellaneous

## Description

Finds roots of univariate functions by the usual Newton-Raphson (N-R) method.

## Usage

 `1` ```newton(fun, derf, x0, eps, maxit = 20, silent = TRUE, tun=1) ```

## 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. `silent` a logical statement which decides whether the iterations should be printed. `tun` a numeric value to decrease the steps

## Details

`tun` is used to decrease the N-R steps, since it sometimes might miss the root value by taking large steps. `tun=1` corresponds to usual N-R.

## Value

Returns a numeric result of the root.

## Author(s)

Ozlem Ilk, Ozgur Asar

## References

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

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```# function and the derivative f1=function(x) x^3+sqrt(x)-1 df1=function(x) 3*x^2+(1/2)*x^(-1/2) # searching for a reasonable initial x0=seq(0,2,,100) plot(x0,f1(x0),type="n") lines(x0,f1(x0)) abline(h=0,lty=2) newton(f1,df1,0.5,10**-10,silent=FALSE) ```

### Example output

```Iteration: 1 , Result= 0.6152237
Iteration: 2 , Result= 0.6055087
Iteration: 3 , Result= 0.6054234
Iteration: 4 , Result= 0.6054234
Solution: 0.6054234
[1] 0.6054234
```

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