# Identify where a non-increasing function changes sign

### Description

Let f be a non-increasing (or non-decreasing) function that changes sign within the
interval specified. If 'pos.side'=TRUE (or FALSE) then
`unirootDiscrete`

finds the value x such that f(x) is closest
to the sign change and is positive (or negative).

### Usage

1 2 3 |

### Arguments

`f` |
function for which a root is needed |

`interval` |
an interval giving minimum and maximum allowable values for root |

`lower` |
lower bound for root |

`upper` |
upper bound for root |

`tol` |
absolute tolerance, abs(true root-estimated root)<= tol |

`pos.side` |
if TRUE finds value x closest to the sign change in f, such that f(x)>0 |

`print.steps` |
if true prints interations |

`maxiter` |
maximum number of iterations |

`...` |
additional arguments to f |

### Details

The algorithm evaluates f(x) iteratively, and the change in 'x' is halved each iteration until the change in 'x' is less than tol. Then the root is returned according to the pos.side parameter.

### Value

A list with the folllowing elements,

`iter` |
number of iterations (times f is evaluated) |

`f.root` |
value of f(x), where x is the root |

`root` |
the root x, where f(x)>=0 if pos.side=TRUE |

...

### Author(s)

M.P. Fay

### Examples

1 2 | ```
test<-function(x,parm=10.987654321){ ifelse(x>=parm,1,-1) }
unirootDiscrete(test,lower=0,upper=100,tol=10^-4,pos.side=FALSE,print.steps=TRUE)
``` |