# fzero

Find a root of a univariate real function within an interval.

## Syntax

x = fzero(@func,interval)

x = fzero(@func,interval,options)

[x,fval,info,output] = fzero(...)

## Inputs

`func`- The function whose root is to be found.
`interval`- A two-element vector containing the root.
`options`- A struct containing option settings.

## Outputs

- x
- The location of the approximate root.
- fval
- The function value at the approximate root.
- info
- The convergence status flag.
- info = 1
- Function value converged to within tolX.
- info = 0
- Reached maximum number of iterations or function calls.

- output
- A struct containing iteration details. The members are as follows:
- iterations
- The number of iterations.
- nfev
- The number of function evaluations.
- xiter
- The function values of the interval end points at each iteration.
- fvaliter
- The interval end points at each iteration.

## Examples

```
function y = func(x)
y = (x-3)^4 - 16;
end
options = optimset('TolX', 1.0e-8);
interval = [1, 6];
[x,fval] = fzero(@func, interval, options)
```

```
x = 4.99999999
fval = -4.18902e-07
```

```
function y = func(x, offset)
y = (x-3)^4 + offset;
end
handle = @(x) func(x, -8);
[x,fval] = fzero(handle, interval, options)
```

```
x = 1.31820717
fval = 3.55271e-15
```

## Comments

fzero implements ACM Transactions on Mathematical Software algorithm 748, which does not require derivatives.

Options for convergence tolerance controls are specified with optimset.

To pass additional parameters to a function argument, use an anonymous function.

- MaxIter: 400
- MaxFunEvals: 1,000,000
- TolX: 1.0e-7