15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4 Function Functions<br />

You can verify that the function value at a is close to zero by entering<br />

humps(a)<br />

ans =<br />

8.8818e-016<br />

Using a Starting Point<br />

Suppose you do not know two points at which the function values <strong>of</strong> humps<br />

differ in sign. In that case, you can choose a scalar x0 as the starting point for<br />

fzero. fzero first searches for an interval around this point on which the<br />

function changes sign. If fzero finds such an interval, it proceeds with the<br />

algorithm described in the previous section. If no such interval is found, fzero<br />

returns NaN.<br />

For example, if you set the starting point to -0.2, the Display option to Iter,<br />

and call fzero by<br />

a = fzero(@humps,-0.2,options)<br />

fzero returns the following output:<br />

Search for an interval around -0.2 containing a sign change:<br />

Func-count a f(a) b f(b) Procedure<br />

1 -0.2 -1.35385 -0.2 -1.35385 initial interval<br />

3 -0.194343 -1.26077 -0.205657 -1.44411 search<br />

5 -0.192 -1.22137 -0.208 -1.4807 search<br />

7 -0.188686 -1.16477 -0.211314 -1.53167 search<br />

9 -0.184 -1.08293 -0.216 -1.60224 search<br />

11 -0.177373 -0.963455 -0.222627 -1.69911 search<br />

13 -0.168 -0.786636 -0.232 -1.83055 search<br />

15 -0.154745 -0.51962 -0.245255 -2.00602 search<br />

17 -0.136 -0.104165 -0.264 -2.23521 search<br />

18 -0.10949 0.572246 -0.264 -2.23521 search<br />

Search for a zero in the interval [-0.10949, -0.264]:<br />

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

18 -0.10949 0.572246 initial<br />

19 -0.140984 -0.219277 interpolation<br />

20 -0.132259 -0.0154224 interpolation<br />

21 -0.131617 3.40729e-005 interpolation<br />

22 -0.131618 -6.79505e-008 interpolation<br />

23 -0.131618 -2.98428e-013 interpolation<br />

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

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

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

4-24

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

Saved successfully!

Ooh no, something went wrong!