15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Minimizing Functions and Finding Zeros<br />

The iterative algorithm for fzero finds smaller and smaller subintervals <strong>of</strong><br />

[-1 1]. For each subinterval, the sign <strong>of</strong> humps differs at the two endpoints. As<br />

the endpoints <strong>of</strong> the subintervals get closer and closer, they converge to a zero<br />

for humps.<br />

To show the progress <strong>of</strong> fzero at each iteration, set the Display option to iter<br />

using the function optimset.<br />

options = optimset('Display','iter');<br />

Then call fzero as follows:<br />

a = fzero(@humps,[-1 1],options)<br />

This returns the following iterative output:<br />

a = fzero(@humps,[-1 1],options)<br />

Func-count x f(x) Procedure<br />

2 -1 -5.13779 initial<br />

3 -0.513876 -4.02235 interpolation<br />

4 -0.513876 -4.02235 bisection<br />

5 -0.473635 -3.83767 interpolation<br />

6 -0.115287 0.414441 bisection<br />

7 -0.115287 0.414441 interpolation<br />

8 -0.132562 -0.0226907 interpolation<br />

9 -0.131666 -0.0011492 interpolation<br />

10 -0.131618 1.88371e-007 interpolation<br />

11 -0.131618 -2.7935e-011 interpolation<br />

12 -0.131618 8.88178e-016 interpolation<br />

13 -0.131618 8.88178e-016 interpolation<br />

Zero found in the interval [-1, 1]<br />

a =<br />

-0.1316<br />

Each value x represents the best endpoint so far. The Procedure column tells<br />

you whether each step <strong>of</strong> the algorithm uses bisection or interpolation.<br />

4-23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!