y|[gۑiUj𓚗z

 

1D

vO

yf_ex6_1.mz

function y=f_ex6_1(x)

% y=f_ex6_1(x)

y=5*x^4-10*x^3-5*x^2-10;

> x1=fminbnd('f_ex6_1',-10,10)

x1 = 1.7808

> y1=f_ex6_1(x1)

y1 = -32.046

 

 

2D

vO

yf_ex6_2.mz

function y=f_ex6_2(x)

% y=f_ex6_2(x)

y=10*cos(2*x)+1.5*x;

yex6_2.mz

t=-10:0.01:10;

y=f_ex6_2(t);

n=length(y);

k=0;

z=[];

for i=1:n-1

    if y(i)*y(i+1)<0

        k=k+1;

        z(k)=fzero('f_ex6_2',[t(i),t(i+1)]);

    end

end

z

plot(t,y,z,f_ex6_2(z),'o')

grid('on')

legend('line','zero')

> ex6_2

z =

 

 Columns 1 through 8:

  -6.41970  -6.07004  -3.63835  -2.55266  -0.73050   0.84927   2.18892   4.27506

 

 Column 9:

   5.06619