8-3 ?數????

fzero OiΩܼƨƪDڡAϥλykpUG

x = fzero(fun, x0)

䤤 fun ODڪơ]Hrܡ^Ax0 hO@Ӱ_lIΰ_l϶CziH x0 w@Ӱ_lIΰ_l϶ӶiDڡAfzero O|ھ x0 PӰUCʧ@G

ҦpAYnX humps b x = 1.5 񪺮ڡA⤧AiJpUG

Example 1: 08-@ƾǨƪBzPR/fzero01.mx = fzero(@humps, 1.5); % Da 1.5 񪺮 y = humps(x); % aJD fprintf('humps(%f) = %f\n', x , y);humps(1.299550) = 0.000000

bWCAfzero 1.5 ܸIAY 1.26 1.6697AMAڥHX humps sIC

Yw humps b x = -1 1 AY humps(1)*humps(-1) < 0A hڭ̥iHO x0 = [-1, 1] _lϨӧX humps sIApUG

Example 2: 08-@ƾǨƪBzPR/fzero02.mx = fzero(@humps, [-1, 1]); % D϶ [-1, 1] y = humps(x); % aJD fprintf('humps(%f) = %f\n', x , y);humps(-0.131618) = 0.000000

fzero 쪺Ot@ӹsICYneXHWoӹsIAiJpUG

Example 3: 08-@ƾǨƪBzPR/fzero03.mfplot(@humps, [-1, 2]); grid on z1 = fzero(@humps, 1.5); z2 = fzero(@humps, [-1, 1]); line(z1, humps(z1), 'marker', 'o', 'color', 'r'); % eXĤ@ӹsIm line(z2, humps(z2), 'marker', 'o', 'color', 'r'); % eXĤGӹsIm

YܨDѹL{GAiϥ optimset Oӳ]wܿﶵAAN optimset Ǧ^cܼưeJfzeroAҦpG

Example 4: 08-@ƾǨƪBzPR/fzero04.mopt = optimset('disp', 'iter'); % ܨC iteration G a = fzero(@humps, [-1, 1], opt) Func-count x f(x) Procedure 2 -1 -5.13779 initial 3 -0.513876 -4.02235 interpolation 4 -0.513876 -4.02235 bisection 5 -0.473635 -3.83767 interpolation 6 -0.115287 0.414441 bisection 7 -0.115287 0.414441 interpolation 8 -0.132562 -0.0226907 interpolation 9 -0.131666 -0.0011492 interpolation 10 -0.131618 1.88371e-07 interpolation 11 -0.131618 -2.7935e-11 interpolation 12 -0.131618 8.88178e-16 interpolation 13 -0.131618 8.88178e-16 interpolation Zero found in the interval [-1, 1] a = -0.1316

bDsIL{A|ΨGk]Bisection^Τk]Interpolation^AoǤkܦbW Procedure ĥ|줤CYw@Ӱ_lIAh fzero b̪쪺ӨBJ|X@ӾA϶ӷjMsIC

Hint
  • optimset q`Ω]w̨ΤƪﶵANbU`ԲӤСC


MATLAB{]pGig