: y=(x+2)*(x-4)
,
y=(x+2)*(x-4)
-10
10
? =1 =00
:0.1
:-9.8 :107.64
:-9.6 :103.36
:-9.4 :99.16
:-9.2 :95.04
:-9 :91
:-8.8 :87.04
:-0.2 :-7.56
:-2.0539e-015 :-8
:0.2 :-8.36
:0.4 :-8.64
:0.6 :-8.84
:0.8 :-8.96
:1 :-9
:1.2 :-8.96
, , .
dx = -0.1000
:1.1 :-8.99
:1 :-9
xeps
? =1 =0 1
? =1 =0 1
= 1 = -9.800 =107.640
= 2 = -9.600 =103.360
= 3 = -9.400 = 99.160
= 4 = -9.200 = 95.040
= 5 = -9.000 = 91.000
= 6 = -8.800 = 87.040
= 54 = 0.800 = -8.960
= 55 = 1.000 = -9.000
= 56 = 1.200 = -8.960
= 57 = 1.100 = -8.990
= 58 = 1.000 = -9.000
=1 ( ):0.1
=-9 ( ):0.01
:58
:
,
; ; .
. 2.5.
, .
. 2.5 , :
. (1)
, (1) (2) :
. (2)
(2), :
, (3)
:
. (4)
:
. (5)
, :
. (6)
R |
3 |
1 |
2 |
4 |
min |
max |
. 2.6.
(. 2.6) X 1 = X min + k ² a X 2 = X min + ka, [ X min, X max]. X min, X 1, X 2, X max. R X 1, [ X min, X 2], X 3 = X min + k ² a, ka [ X min, X 2] R X 2, [ X 1, X max], X 4 = X 1 + ka, ka [ X 1, X max]. . s :
|
|
. (7)
, .
function[]=ZolotSechenie1D_170809();
function y=f(x)
y=(x+2).*(x-4);
end
disp(' ');
disp(' : y=(x+2)*(x-4)');
disp(' , ');
function [x,y,xleft1,xright1,nn]=ZolS1()
eps=input('=');
xleft=input(' =');
xright=input(' =');
xleft1=xleft; %
xright1=xright; %
k=(sqrt(5)-1)/2; % ,
x1=xleft+k*k*abs(xleft-xright);
x2=xleft+k*abs(xleft-xright);
z=0;
j=0;
nn=1;
disp(' ');
while abs(xleft-xright)>eps
R1=f(x1);
R2=f(x2);
if R1<R2 % 1
z=x1; %
j=R1; %
% xleft,x1,x2
xright=x2;
x2=x1;
x1=xleft+k*k*abs(xleft-xright);
%
mas1x(nn)=x1;
mas1y(nn)=R1;
else % 2
z=x2;
j=R2;
% x1,x2,xright
xleft=x1;
x1=x2;
x2=xleft+k*abs(xleft-xright);
%
mas1x(nn)=x2;
mas1y(nn)=R2;
end % if
%
string=strcat(' :',int2str(nn),' :',num2str(mas1x(nn)),' :',num2str(mas1y(nn)));
disp(string);
nn=nn+1;
end % while
%
x=z;
y=j;
nn=nn-1;
end
%
[x,y,xleft1,xright1,nn]=ZolS1();
%
choiceTab=input(' ? =1 =0 ');
choiceGraf=input(' ? =1 =0 ');
%
if choiceTab==1
disp(' ');
for i=1:nn
string=print(= %4i\t= %7.3f\t= %7.3f,i,mas1x(i),mas1y(i));
disp(string);
end
end
disp(' ')
sx=strcat(' =',num2str(x),' :',num2str(abs(mas1x(nn)-mas1x(nn-1))));
sy=strcat(' =',num2str(y),' :',num2str(abs(mas1y(nn)-mas1y(nn-1))));
sn=strcat(':',num2str(nn),' ');
disp(sx) %
disp(sy)
disp(sn)
%
h=0.1;
x1=xleft1:h:xright1;
y1=f(x1);
plot(x1,y1,'k-');
grid on;
title('y=(x+2)(x-4)');
|
|
xlabel('X'); ylabel('Y');
text(x,y,\leftarrow Minimum);
zeroMas=x1*0;
hold on;
if choiceGraf==1
plot(mas1x,mas1y,r.);
legend(plot with minimal step,points by Gold method,0);
else
legend(plot with minimal step,0);
end
hold on;
plot(x1,zeroMas,k-,zeroMas,y1,k-);
end
, :
: y=(x+2)*(x-4)
,
=0.1
=-10
=10
:1 :5.2786 :-7.1486
:2 :0.55728 :-7.1486
:3 :-0.55728 :-8.804
:4 :1.2461 :-8.804
:9 :0.92089 :-8.9997
:10 :1.0214 :-8.9997
:11 :0.95928 :-8.9997
:12 :0.99767 :-8.9997
? =1 =0 1
? =1 =0 1
= 1 = 5.279 = -7.149
= 2 = 0.557 = -7.149
= 3 = -0.557 = -8.804
= 4 = 1.246 = -8.804
= 5 = 1.672 = -8.939
= 6 = 0.983 = -8.939
= 7 = 0.820 = -9.000
= 8 = 1.084 = -9.000
= 9 = 0.921 = -9.000
= 10 = 1.021 = -9.000
= 11 = 0.959 = -9.000
= 12 = 0.998 = -9.000
=0.98301 :0.038388
=-8.9997 :0
:12
. 2.7.