Calculate
by finding the zero of the sine function near `3`

.

Find the zero of cosine between `1`

and `2`

.

Note that `cos(1)`

and `cos(2)`

differ in sign.

Find a zero of the function *f*(*x*) = *x*^{3} – 2*x* – 5.

First, write a file called `f.m`

.

Save `f.m`

on your MATLAB^{®} path.

Find the zero of *f*(*x*)
near `2`

.

Since `f(x)`

is a polynomial, you can
find the same real zero, and a complex conjugate pair of zeros, using
the `roots`

command.

ans =
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i

Find the root of a function that has an extra parameter.

Plot the solution process by setting some plot functions.

Define the function and initial point.

Examine the solution process by setting options that include plot functions.

Run `fzero`

including `options`

.

Solve a problem that is defined by an export
from Optimization app.

Define a problem in Optimization app. Enter `optimtool('fzero')`

,
and fill in the problem as pictured.

Select `File > Export to Workspace`

,
and export the problem as pictured to a variable named `problem`

.

Enter the following at the command line.

Find the point where `exp(-exp(-x)) = x`

, and display information about the solution process.

Func-count x f(x) Procedure
2 1 -0.307799 initial
3 0.544459 0.0153522 interpolation
4 0.566101 0.00070708 interpolation
5 0.567143 -1.40255e-08 interpolation
6 0.567143 1.50013e-12 interpolation
7 0.567143 0 interpolation
Zero found in the interval [0, 1]
x =
0.5671
fval =
0
exitflag =
1
output =
intervaliterations: 0
iterations: 5
funcCount: 7
algorithm: 'bisection, interpolation'
message: 'Zero found in the interval [0, 1]'

`fval`

= 0 means `fun(x) = 0`

, as desired.