Вы находитесь на странице: 1из 353

M A T L A B

M A T H E M A T I C A L

E X P L O R A T I O N S

W I T H M A T L A B

Ke Chen, Peter Giblin, Alan Irving

I CAMBRIDGE
1
UNIVERSITY PRESS

. . . .

2001
519.68
32.973
443

., ., .
443 MATLAB : . .
.: , 2001.-346. .
ISBN 5-03-002821-8

MATLAB' , -
--
. MATLAB
-
.
,
-
.
, MATLAB.
, ,
-.

32.973

Cambridge University Press 1999


ISBN 5-03-002821-8 (.) ,
ISBN 0-521-63920-4 (.) , , 2001

. -
-

-
,
, '.
-
,
-
.
-

.
MATLAB , -
20 -
,
-. -
-
,
1970- ., -
. -
.

( ) . -

MATLAB', . -
, , -
-, , -
.
-
6

MATLAB'a . -
-
MATLAB'a.
MATLAB'a -
,
-
. -
, , ,
MATLAB -
. MATLAB'a -
, , , -
,
MATLAB .
-
.
MATLAB'a
, .
, ( 2000 .),

.
MATLAB'a -
- -
- MAPLE, MATHEMATICA, MATH CAD, -
. , -
MAPLE ( -
)
MATLAB. MATLAB, -,

,
.
, -
* ,
-
,
. -

7

, , -
.
, -
.
, .. ,
, -
.
-
. , , ,
. -

.
-
. , -
(, , -
, -
) , -
,
. ,
, , -
.
MATLAB'y -
. -
Math Works Inc.
. -
MATLAB'y,
, -
, -
, , , ,
MATLAB'e. , -
,
-,
-
MATLAB.

MATLAB'y .
8


^'
. -
.
MATLAB
, -
,
iss@niiit.ript.in.ru .
. . ,
. .

,
. , -

,

, .
-
,
.
, -

, , -
, -
,
. -
, -
MATLAB. -

, -
.
MATLAB, - ,

. MATLAB -

-
.
, -
. , -
, , -
.
, -
, -
. -

, , ,
10

, . ,
,
.
, ,
, , ,
, , ..,

.
, . -
-
MATLAB'a,
MATLAB'OM. -

MATLAB'a, -
. , -
MATLAB'a: , -
,
, -
, -
, . ,
, MATLAB'a, -
, .
, -
, -
, -
, ; -
-
,
;

..

, .
, -
,
, . -
-
, -
. , -
MATLAB'a
-
11

. ,
.
-
( ), -
-
( ).
,
.
, , -
.

, ,
.
, -
MATLAB'a, -
( )
MATLAB'a , , , -
, .


. -,
-
. -, -
-
. -,
,
, .
, -
, -
. -
.1 .
, ',
.2. ,
.1.
-, , .
. -
-
.
MATLAB .
, MATLAB
12

Microsoft Windows. , -


, - -
, . -
,
.

,
.
, , , ,
, . , -
:

, , , -
. , , . .

, -
.
, 1998 ,
,

MATLAB The Math Works,


Inc.
I

1. 15
1.1. MATLAB'e 15
1.2. 18
1.3. - 21
1.4. 28
28
2. 30
2.1. 30
2.2. 35
2.3. : 37
40
3. 44
3.1. 44
3.2. : + 1 46
3.3.
47
3.4. 49
52
3.5. 55
4. 57
4.1. 57
4.2. 58
4.3. 61
4.4. polyfit 62
4.5. 64
4.6. 65
68
4.7. 72
14

74
5.1. 74
5.2. 78
85
5.3. 87
90
6.1. 90
6.2. 92
6.3. 94
6.4. 94
6.5. 95
98
6-6. 100
105
7.1.
() 105
7.2. 108
7.3. 111
113
1

1.1. MATLAB'e
', , ,
-
() .
, -
, -
. * -
,
Windows. , -
Microsoft Windows -
matlab <Enter>. , -
, - UnixlK
, MATLAB'

. , -
>>, MATLAB'a:
, , >>, -
.

1.1.1. MATLAB'e
MATLAB'e : + (-
), - (), * () / (). -
"" ,
5*5+12"2
<Enter>,

169
^
, Windows.
16 1.

<Enter> , -
. ,
. -
,

ans

,
, .
sqrt(5~2+12~2)

expClogCl.7))
; , sin(pi/2)? .
MATLAB
= 3-1415926... pi, .
:
>> pi
>> format long
>> pi
>> format short
MATLAB , -
format short.

1.1.2.
-
.
>> =3

=
1.1. MATLAB'e 17

- , ,
>> rad=2; ht=3;
vol=pi*ht*rad~2

vol =

37.6991
,
! MATLAB
; ( ) ,
. ,
, ,
>> rad=4;
ad

rad =

; -
. ,
.
, -
,
. , -

i = ~2 + 2** + ~2

??? Undefined function or variable
. =4; -
f .
,
MATLAB'a - (t)
, . -
.
, -
, . -
, -- ( >)

2-4196
18 1.

Delete,
. , -
,
2 1/4. ?
-
who whos. -
. ?

1.2.
, -
MATLAB'a, . -
:

(i) -, ..
;
(ii) = /(), .. -
;
(iii) .
, , -
- , MATLAB .

1.2.1.
,
. , .

=[2,2,3]
=[2 2 3]
v=[l,0,-l]
>> w=u-2*v
range=l:13
odd=l:2:13
down=20:-0.5:0
even=odd+l
xgrid=0:.05:1; x=xgrid*pi
y=sin(x)

, -
.
, .
1.2. 19

, [1+1 2 3] , [ 2 , 2 , 3 ] , [1 + 1 2 3]
, [ 1 , 1 , 2 , 3 ] !
, .
, , ,
>> w'
ans =


2
5

(). MATLAB'e -
, -
.
, , -
.
,
, .
- .
, , sin(x), -
.
, -
.
MATLAB
. .

wJ*w

>> u*u
?
?
z,
2
z ~ ,
. ,
z=y*y
MATLAB'a.
>> z=y*y J
20 1.

,
-! MATLAB -
,
z=y.*y
*
. u./v .""2 -
.

1.2.2. -
whos, , -
, . 1 21- (..
-).
.
>> plot(x.y)
. , -
sin ; %.
.
. -
. :
t i t l e ( ' G r a p h of y=sin(x)')
xlabel('x')
ylabel('y')
yl=2*x;
>> hold on
plotCx.yl,'r')
, .
, yl=2*x ~ 2,
hold on MATLAB' ,
a plot (x,yl, ' ' ) . -
, 1^
.

. , ,

^ , MATLAB 4- . -
, -
.
1.3. - 21

, , .

>> hold off


>> plot(x,y,'+')
plot(x,y,'g*')
J
>> plot(x,y, w.')
MATLAB , ? -
| , ?
'.
, .
>> help plot
>> help hold
>> help sin
..

1.3. -
,
.
, :
-
, -.
, .
, - -
,
= (1,0, 2) b (2,3,1). ,

d = b-a

\d\2 - d - d ,
-
':
=[1,0,-2];
=[2,3,1];
>> d=b-a;
dd=d*d';
>> dist=sqrt(dd)
22 1.

. , , ,
,
. ,
() , -
.

1.3.1.

.
, Windows
Microsoft Windows, -
.
MATLAB ,
- . ,
e d i t ,
MATLAB'a
>> ' e d i t fname
fnarae , ,
.
, -, -
, .
Windows
Windows -
(Notepad), -
-
(Accessories Group). MATLAB'a Windows
, .
myf i l e .,
MATLAB'a, :
(i) MATLAB Command Window F i l e ,
(ii) New, M-file.
(iii) , ,
, ,
, myfile.m
'/, () .
7, ,
'/, MATLAB .
dispC I am an M-file')
1.3. - 23

(iv) F i l e Save As.


(v) F i l e Name, ,
myfile.m.
(vi) .
, MATLAB
.
MATLAB Command Window, -
MATLAB, .
>> type myfile
, . -
, (i)
F i l e MATLAB Command Window, Open M-f i l e .
, myf i l e . m. -
, ,
-, .

1.3.2. -
,
-. ,
>> myfile
-
I am an M-file
- . -, -

. , ,
- distab.m, -

7. distab.m
7,
7. ...
(, %), -
, . -

d=b-a;
dd=d*d';
dist=sqrt(dd)
24 1.

, File, a
Save As, mfile.m.
, . -
, ,
File Exit. ,
, , -
.
.
, -
:
=[1,0,-2];
=[2,3,1] ;
,
>> distab
? ,
.
,
, -
, , s (1,2,3) = (1,1,3).
=[1,2,3] ;
=[1,1,3];
>> distab
, -
MATLAB'e, what. -
-, help
( , MATLAB'a):
help myfile
help sqrt
help sin
help -
-. -
( %) -.
.
, myfile MATLAB'a (,
), myfile. m -
, .
1.3. - 25

1.3.3.

.
-
-. - .
,
, .. - distf n, , ,
dab=distfn([l,2,3],[1,1,3]);

=[1,2,3]; =[1,1,3]);
>> dab=distfn(a,b);
dab
- .
- distab.m.
- distf n.m.
, :
(i) MATLAB Command Window File.
(ii) Open M-file, , -
-, ..
.. { , *.txt
File Name * .m).
(iii) distab.m.
(iv) .
, ,
MATLAB'a ,
:
, distfn.m
. ,
'/ b
, :
, dist=distfn(a,b)
. : , ( )
, : distfn -
function dist=distfn(a,b)
d=b-a;
dd=d*d';
dist=sqrt(dd);
26 1.

(v) Save As.


(vi) File Name, ,
distfn.m.
(vii) .
MATLAB Command Window, , -
help distfn, , . -

d i s t - d i s t f n ( [ l , 1 , 1 ] , [2,2,2])

>> dist=distfn(a,b)
dist.
, -
; . -
, .
-- ( -), .. -
function . . . ,
. ( distfn),
(a, b, dd ..)
. -
, . , -

>> who
>> clear
>> who
dist=distfnC[l)l,lj,[2,2,2])
>> who
clear .
dist=distfn(. .)
-.

1.3-4-
, -
. -
(. ).
. ,
>> diary sectl.txt
'/. 1
1.3. - 27

>> '/,
>> myfile
>> d i s t = d i s t f n ( [ 1 , 1 , 1 ] , [ 2 , 2 , 2 ] )
>> diary s e c t 2 . t x t
>> '/, -
>> = 0 : . 1 : 1 ;
>> =.*
>> p l o t ( x , y )
>> diary.off
. diary f name -
MATLAB'y -
( ) fname. diary off
.
, . -
, ,
. ,
F i l e , fJpen -
* . t x t . s e c t l . t x t
sect2.txt.
s e c t 2 . t x t , , , ,
= 2 . , -
. -
, .
MATLAB'OM
. .

>> clear
. -
, , , .
>> save monday

>> save monday x,y



monday.

>> load monday


28 1.

, ,
.. . , ,
, -.

1.4.
1-4-1- Windows
Windows ,
, , -
-, .
MATLAB -
. , -
MATLAB'a.
- -
,
(. ). File,
Print. ! , ,
Print Setup , ,
. -
.
, .
, -
File Print , -
( Figure No. 1).

1.4-2. , nod Windows


Windows ,

!print fname.txt
-
(, 1 lpr Unix).
MATLAB'a print
, -
. , help
print. ,
.
29

1.1.
plot(,) plot(x,y,'*') plot(x,y,'+g')
title xlabel ylabel
'') (' ') (' ' )
sqrt() sin(x) exp(x)
hold on hold off
=-1:.2:1 y=x.*x dotprod=x*y' i )
format long format short
help sqrt help myfile save fname
diary f i l e l . t x t diary off load fname
1
= )

, , -
.
, . 1.1. -
.
1.1
1 2 3
2x3' 3x4' 4x5'
1.2 t ,
0.2 0 6 . -
,
f(t) = sm(irt)

g(t) = (t) sin(7r()


, ,
. ,
MATLAB'a, help exp ..
, , = 0.
1.3 , -, -
,
= [1,2,3], b [2,3,4]
= [3,4,5].

2.1.
2.1.1.
, .
= (-1,2,4) = (1.5,2,-1).
,

= [-1 2 4]
b = [1.5 2 -1]

= [-1,2,4]
= [1.5,2,-1]
, , -
.
-
, , 1.2. -
, -
, . 1.

>> =.*

* ,
b [1.5,4,4].
:

>> sum(c)

b 1.5.

>> sqrt(sum(a.*a))
2.1. 31

. , MATLAB'a norm -
() . 9
, = arccosa b/(jaj jb|).
MATLAB'e arccos acos, ,
,
>> theta = acos( 5(.*) / sqrt (sum(a. *a)*sumCb.*b)) )
= 1.693 .

2.1.2.

MATLAB'e

=[-1 1 2;3 -1 1;-1 3 4]


-, ,

= [-1 1 2
3 -1 1
-1 3 4]
, <Enter>, -
. MATLAB'a
, -
J. -
, , . ,
:


MATLAB'a,

>> format compact
- help format, , -
MATLAB'a.
32 2.


xi + x<i + 2: = 10,


= , (2.2)
, , - (!,2,) , a b --
(10, 20,40) . MATLAB'e -
b -
=[10 -20 40] '
= , -
,
."1 , .. , ~1
~1 = / (I 3 3). ,
,
det(A)
: 10.
= ~* ^ ,
MATLAB'e
>> x=inv(A)*b
- (

, -
*, -
, MATLAB .
, * , b, a
1, . 3. -

=*
det(C)
D=A~3
det(D)
, = A2, D ~ 3 ,
, det(P)det(Q) = det(-PQ),
100 1000, .
2.1. 33

, , (2.1)
(2.2), .
,
b. MATLAB
1^.
= \
II . -
,
= b .
-
. MATLAB , -
. ,
=~2+2*+1

= 2+ 2

1 2^.
, 1, ,
diag([i 1 1])
ones(3,3)
diag -
, a ones
. ,
diag(ones(l,3))
diag.
(,
3 x 3 ) ,
()
, , -

F - [ ]
*' . . 16, .
' , *1 , ,
MATLAB'e 1 .

3-4196
34 2.

, -
.

,
, -
1, ,
, .
-
, , , -
. -
. 8.

G=rref(F)

F. -

/ 1 0 0 1
G = 0 1 0 19
\ 0 0 1 _4

, -
G, = 1, = 19, z = 4,
.

MATLAB'a, rref. -
, , -
,

r r e f ( [1 2 3; 456; 7 8 9])

, ()
,
. , , -
.

>> rrefmovie(F)

-
.
2.2. 35

2.1.3.
.4 n-, - n x 1-
(), ,
= ,
.4, -
.1' -
, det(A XI) 0,
1 n x -.

>> A = d i a g ( [ l 2 3])
eig(A)
P = [ l 2 3;4 5 6; 5 7 8]
>> det(P)
B=inv(P)*A*P
eig(B)
[Y,D]=eig(B)
.4
1, 2 3.
\det(P) = 3), = ~1 -
. , MATLAB
-. -
:
, -
D ,
, -
D, , ..

. , ,
2.1.2.

2.2.
MATLAB i (/),
. MATLAB' /1
j.
>> clear
^ , , -
, , -
, , .
36 2.

i
J

, .
: -
, MAT LAB i -
1. , i -
, (
for; . 3.1).
,
>> clear i , j
-
i .
, -
2.1. MATLAB
. .
a=l+i; b=2-3i;
>> c=a*b
>> d=sqrt(a)
5 i,d 1.0987 + 0.455. ,
.
(-1/2)

1 + i. -
1
, .
, ( < 7 )

abs(a)
>> angle(a)
real(a)
.
>> imag(a)
, . a = 1- 1.
>> conj(a)
2.3. : 37

a . ( + iy,
, iy.) ,

>> a*conj(a)-abs(a)~2
0 ( , ,
1.7764-015, .. 1.7764 1 5 ) .

>> exp(i*pi)

'77 = 1.

2.3. :
-
, ,
. -
-
- .
, , -
, -

-
.
.
. .
,
0-5, 6-19. 20-59 60-69.
, , .
-
.

-
, .. -
.
69 !
60-69 -
d_\% 0-5
di% .

20-59 % .
38 2.

2.1. .

'
3J
0

3


5 -S
/ ;
g gg
S

V
2
iS
?S 1 ti
5- :

0-5 6
d,
Too"1 ~ Too)Ul \ ^ ~ 100^

6-19 2 14 0 2 it ^) 6

20-59 3 40 0 . Hi
40 14
60-69 4 10 714 (l 100 J \ 100 J 'ft 40

-
= (n1(2),7i2(2),n3(2),7i4(2))T

2-
-
N(l)=,tn1(l),n2(l),n3(l),n4(l))T
1- . , , , -
.
, ,
. 2.1.
: ; -
;
(, 0, 1, 2, 3, 4. 5
); : -
; ,
( ,
60-69, ); -
, ,
.
, -
. -

, -
, ,
. -
2.3. , : 39

, -
.
, N(2)
2- -
N(1) 1-

L

/ 1 -&)
I ( - AL.\ 13 n
L= 6 V 100 14

) -L 39

U
14
U
40
\ 40 10 I 1 lOoJ /


N(3) = LN{2) = L 2 N(1)
. .,
N(t + 1) =LN{t).
, , t ~ 0, , d/ 1,

. , -
, -
.
- l e s l i e . m . -

>> leslie
4 4- L, -
.
() , 2.5,
(, dj = 1) (, d& 10)
.. , ,
N = [ 3.6 11.4 29.6 1 0 . 6 ] '

1996 . . .
:
N L 4 (N1=L*N, N2=L*N1,. . .), -
-
40 2.

2000 . ? ,

L~4
N50=L"50*N

[Y D] = eigCL)
-
L. -
.
, , 50 . L o 0 N. -
:
N50=L"50*N
N50./
N50 -
.
, , 50 , ,
, -
.
,
?

2.1 -
,
. 13. { 2.2 : -

clear i.) - , ,
z=3+4i

z=(z~2~l)/(2*z)
-[, -
. % ; -
3 + 4 %.
, z -
, : ~i? (
41

, . -
. 13.)
= 0, MATLAB
inf, NaN, NaN ...,
1^. ,
2 = 2, .
? (
.)
2.2 -
.
- ( -
,
):
=[1 1/2 1/3
1/2 1/3 1/4
1/3 1/4 1/5]
=[1 0 0] '
det(A)
X=inv(A)*b
- , -
, ch2q2.m.
- -4 -
- b . ,
.4.
det(.4) 0. -
.
, det(.,4) . -
.2'

(a) ch2q2.m. , ch2q2a.m -


, ,
1/3 0.333.
(b) , 1/3 0.33;
- ch.2q2b.rn.
1
' MATLAB' inf () NaN (
), .
( -
10 3 0 ). 0/0, inf-inf ,
NaN. NaN
. . .
2>
. . 16, .
42 2.

- MATLAB'e -
. ( 1)
diary ch2q2.txt, ch2q2.
-, ch2q2a,
-, , , ch2q2b, .
, diary off. -
ch2q2.txt, -
. ,
. , -
, -
,
.
2.3 - leslie.m , -
, -
0-1, 2-5, 6-10 11-15 -
:
15 .
2-5 (% ).
0-1 ,%
.
2-5 .
6-10 dp% ,
11-15 &% .
- cats.m.
(a) b = 15, 1 5, UR 2
d-A = 30. (, , diary ch2q3.txt, -
-, cats ,
diary off.)
(b) ,
[20, 20, 20, 20]? -
sum, -
. diary ch.2q2q3.txt,

: -
. ,
, -
. diary off ,
.
(c)

43

. ,
V=C(:,1)
V . ,
- , -
, .
(d) (), , -
(N) 50 -
(). , -
. ,
VI./V2
, V I V2.

MATLAB', -
.

3.1.

>> f = [1 1]
f(3) = f C D -* )
>> f
f(4) = f(2) f ( 3 ) ;
>> f

[ 1 1 2 3]. , f (1)
f, f C2) , ..
:
f = [1 ;
for k = 1:15
f ( k + 2 ) = fCk+1) + f ( k ) ;
end
f

, MATLAB , ,
end. for. . .end
1,2,... ,15 -
f f(fc + 2). , = 1 f
[1 1 2]; 2 [1 1 2 3] ..
f ( + 2)
15 .

plotCf,'*')
3.1. 45

, (,f()) -
*. p l o t (f )
, . f -
1,1. 2, 3, 5.8,13, 21, 34,... . -
, , f(l) f(2) = 1; f(k+2) = f(fc+l)-t-f(fc)
> 1.
-.
while:

f=[l 13;
k=l;
while f(k) < 1000
f(k+2)=f(k+l)+f(k);
k=k+l;
end
f
plot(f)

- fibno.m , -
fibno. ,
-, .
while end
, {() < 1000 . -
f (16) = 987 f (17) 1597, ,
while, ~ 16. ,
-, 17, -
1 .
for while:

for ( ) -
1 .
,
d, 6, -

for k = a : d : b

end

while (, )
.
, k=k+l.
46 3.

3.2. : + 1
. -
: , /2;
, + 1. , = 10, -
5,16,8,4,2,1. -,
(-
) . hail.m. , rem(a,b)
MATLAB'e .

n=input'Enter n ' )

while >1
k=k+l;
if rem(n,2)==0
n=n/2;
else
n=3*n+l;
end
f(k)=n;
end
barCf)

, h a i l ,
, 25 <Enter>. ,
, .
1000 . 3.1.
- , -
, 1,
1. (, , 8 -
8,4,2,1, 4- .) 1000
112 ,
. 3.1. -
maxCf), , -
.
1000 9232.
h a i l . m .
(i) while.
, -
f(k) .
3.3. 47

20 40 60 100 120

, 3.1. = 1000.

(ii) if. . . e l s e . . .end.


end. -
if. . .end else.
(iii) = . -

2, rem(n,2).
(iv) ; if (
).
,
1. , 1,
.
[13].

3.3.

()
, > 0, :
= bq + , where 0 < < .
q , ,
r=rem(a,b)
3.

3.1. .
6
1 69 15 4 9
2 15 9 1
3 9 6 1 3
4 6 3 2 0

( , q , q=f 1(/).)

(, ) = ( - bq, ) - (, ) = (, ). (3.1)
, ( -
\ ' 6'),
b 71.
(3.1),
(3.1) , ' . :>;. ,
bq . . , ,
d\a d\b. = aid, b = b\d \ \,
a bq d(ai biq), d bq.
II , ,
a bqiib . (3.1)
, ,
.
,
; . = 69, b = 15. -
. 3.1. (69,15) = (15, 9)
0(9, 6) = (6, 3) = 3, 6 3 ,
, 3.
MATLAB'e, -
, . -
, > 0,
b > 0, ,
, , .
-, !
, , -
, ?
'/, b.
, , ,
, gcdiv(69,15)
3-4. 49

.
, ,

function h=gcdiv(a,b)
if a<0 a=-a;
end
if b<0 b=-b;
end
while b > 0
r=rem(a,b);
a=b;
b=r;
end
h=a;

-, gcdiv.m, -
. , h,
, .
- g c d i v ( a , b ) , an b -
MATLAB'y ,
, 69 15. -
, gcdiv(0,4) ? :
? gcdiv(4,0) ?
3.7, -
h
(. , ) = ((, ), ). ,
, h (:, ). -
,
. (. 9) ,
-
. -,
gcdiv, .

3.4.
-
,
1640 .,
1736 .

.

4-4196
50 3. .

, , [7].
.
, > 0,
, 1 .

. ,
. ~ 1 .

rem(ap~l,p) = J.
, ''" 1 1 ~1 =
1 mod . = , ^
mod , ,, 0, ,
.
, -
, , -
,

. "
?
, , ~ 1000000, ~ 2
"
, 2 1 0 0 0 0 0 0 300000
. MATLAB : ,
, rem(7~2,10) = 9,
(7"20,10) = 0, !

3.4-1
n
rem(a ,rn) .
, -
3.5.1. , -
, , ; 2 .
rem(a",m) -

>> pow(a,n,m)

, - pow.m,
help pow.
, , -
. . 16 1 9 9 8 = 1 mod 1999,
1999 .
3.4. 51

(i) pow(3,118,119) 32. . 119 -


1. ,
119 = 17.

(ii) pow(2,1993002,1993003) 1121689, 1993003 -


( , 997 1999).

(iii) pow(2,10"6+2,10*6+3) 1, ,
6 +3 = 1000003 , -
.
pow(3,10~6+2,10~6+3)
pow(5,10~6+2,10~6+3)
1. -
, 10 + 3 , -
. ( , 10 6 + 3 .) .
3.4.2, , -
* !

, MATLAB'e -
- . , 10 + 7
,

pow(2,10"9+6 ! 10~9+7)

1. , MATLAB
-
. - 1 '.
. -
(
, 100 ) ,
.

.
[12].
. 9.

*' , -
15-- , 2 s 2 ft; 4.5036 + 15.
, 2. . .
52 3.

3,4-2.
, -
, .
, reinfn'"" 1 , "' = 1
> 1, . ,
.
, rem(7 2 4 ,25) = 1, rem(2 3 ' 1 0 , 341) = 1. 25 = 52
7, 341 1 1 x 3 1 -
2. , -
. , rem(a' n ~ 1 ,m) = 1,
-
.
,
.
. 9.
561 (= 3 11 17) ,
, ( 5 0 , 561) = 1 . -
, 3, 11 17. . ,
, -
, . 1992
, -
.

3.1 - iibno.m, f ibno MATLAB'e. -


f l e n g t h ( f ) .
f ? , -
1000 ?
3.2 h a i l , , -
1 27,
, .
h a i l . m , -
,
. - hail2.m.
h a i l 2 . m, ,
hail3.m. n = input (' ' ) ; ,

53

for k=50:100


end % for k=50:100
. 1- ? , ,
.. h a i l 3 MATLAB'a. 1 '
( 1.3.4) -
hail3.m, 50 100.
-
, 27.
, -
1.
3.3 format s h o r t <Enter>. 6 7
, -

. . G.j = 6666 .. -
gcdiv, 6 7 1, 2, 3 . . . . .
? ?
format long -
. -
? , ,
?! ?
3.4 pow(17,1000,100). 1.
1.71000 1 100, .. 17 1 0 0 0 1
1000
100. 17 ?
10
, 17 1 99 101.
, 17 1 0 0 0 1 99 100 101?
( , 99, 100 101 -
.)
pow, 19" 0 0 0 .
\71 3313 1 7 112643.
.: MATLAB'a rem , -
, ;' -
- pow. ,
3313
17 = 1 4-16 , 17 1
16? ( .) ,
*' () -
.
, while . . .end.
. . .
54 3.

3313 1 7 1 16?
17
( 1 7 - - 1,3313 - 1)?
13EM67f
3.5 pow, rem(2 \ 1394677). -
, 1394677 ?
3.6 -, , mypow .m:
m=10"7+l;
while m<l(T7+100
m '/, !
pow(2 ,m-l ,m) '/, !
m=m+2;
end
? (, -
, ,
pause), 107 10' + 100,
, , .
3.7 h=gcdiv3(a,b,c),
, . . .
-
function h=gcdiv3(a,b,)
= (, b), a h =
(, ),
gcdiv. ,
(; , ) = ((. ), ),
- . -
gcdiv3.m, , -.
h = gcdiv3 -
, , -
. ,
(414304,56496,3-51824) (19605475131,133407).
- gcdrand .m (
, -
6
1 10 ):
t = fix(clock)
= t(6)
randC'seed',n)
a = round(rand*10"6)
b = round(rand*10"6)
3.5. Tip 55

= round(rand*10~6)
gcdiv3(a,b,c)
( . 5.) -
- 20 (
, , ). , -
17 (. 9),
, -
1. , -
.

3.5.
3.5.1.
.
.
, rcm(ob,rn),

rem(a. m), q = rem(b,m). ;r = vem(pq, ). (3.2)


, . rem(973 58,10) = rcm(3 8,10) = rem(24,10) = 4.
, 973 58, -
10.

. .
>0
j. = (7 ,11). -, -
, .. 50.
2 3 4 5
50 = (0 1) + (1 2) + (0 2 ) + (0 2 ) + (1 2 ) + (1 2 ).
,
7 5 = 7 2 / | 6 " 3 2 . (3.3)
, . -
11 7 2 , 7 4 , 78, 7 1 6 , 7 3 2 .
-
2
(3.2). , rem(7 ,11)
, (5) -
. 3, 9. -
. :
rem(7 2 ,ll) = 5,rem(5 2 .ll) = 3. 9. rem(9 2 ,11) = 4, rcm(4 2 ,11) = 5.
(3.3) ,
. (. . 3.2).
56 3.

3.2. .

I) rem(k,ll)
] d=6vn x
7 i 0 1
72
5 1 5
74 3 0 5
7s 9 0 5
ie 4 1
7
9
32
7
5 1 1

,
, 1, -
, 2 -
(3.3).
. d rem(n. 2)
, .. -
.
( d)/2;
. = 50 -
:
d=rem(50,2)=0; = (50 - 0)/2 = 25:
d=rem(25,2)=l; = (25 - 1)/2 - 12;
d=rem(12,2)=0; = (12 - 0)/2 = 6;
d^rem{6,2)=0; n = (6 - 0)/2 = 3;
d=rem(3,2)=l; = (3 - 1)/2 = 1;
d=rem(l,2)=l.
- pow.m; ,
:

function x=pow(a,n,m)
b = ;
= 1;
while n>0
d = rem(n,2);
if d=-l
x = rem(x*b,m);
end
b - rem(b * b,m);
n = (n-d)/2;
end
1
' = rem(b.m)* 2;
15- 2 . ,, .
4

, , MATLAB.
= f(x),
, f(x) 0
.
( z = f(x:y) . . 17.)
, -
(. , ,
. . 5) , .
f(x)
0 . -
( ),
(-
).
.

4.1.
() 4 + 2 2 + 4 +
:

=[1 2-3 4 5]
, -
. -
, , -
, ,
.
(.. () 0) ,

>> roots(p)
58 4.

, ,
.

format long
:
=-4:.05:2;
>> y = p o l y v a l ( p , x ) ;
>> p l o t ( x . y )
-4 2
0.05; ..
= [-4.0 - 3 . 9 5 - 3 . 9 . . . 1.95 2.0].
, .
, -
, . (4)... .,(2).
,
( ) -
.

>> hold on
p l o t ( [ - 4 , 2 ] , [0,0])
. plot
, (4,0),
(2,0) ; -
. , . ,
4 2 -
3.18...
- 0 . 7 2 8 . . . . . . 4.1.

4.2.
( 1.2.2). -
, = sinx 0 2,

=0:.05:2*pi;
>> y = s i n ( x ) ;
>> p l o t ( x , y )
4.2. 59

3
. 4 . 1 . = + 2 + + 5
.

p l o t ( ) -
.
length() l e n g t h ( y ) . 126. -
,
. -
,

axis [0 10 ~2 2])
0 < < 10, 2 < < 2.
, . ( MATLAB'a 4.0
axis p l o t ( x , ) . }

, , , xsinx, -

=0:.05:2*pi;
>> =.*sin(x);
>> plot(,)
. * ( 1.2.1),
s i n ( x ) .
s i n ( x ) (
).
60 4.


>> = 0 . 0 1 : . 0 1 : 1 ;
>> =1/;
=1./;
>> p l o t ( , )
, 1/ ; -
1/ 0.01 < . < 1. (1.2.1).
./ : 1

. 1/ , 1
. ( MATLAB'a 4.2 =1, /
.)

>> t=0:.05:2*pi;
>> x=cos(t);
>> y=sin(t);
>> plot(x.y)
{(cost, sin )}, , ,
1 (0,0), -
- .

>> axis 'square')


. - -

>> axis('equal')

. ,
>> t=0:.05:2*pi;
x=2*cos(t);
>> y=sin(t);
>> plot(x,y)
>> axis('equal')
,
2:1. a x i s ( ' equal')
a x i s ( ' square') . !

.
4.3. G1

4.3.
-
, sin -,

X
5! "' v
' (2Ar 1)!'
- t s i n e . m ( -
), ,
<Entcr>,
.
, . :
-. t s i n e <Enter>.
. .
. 4.2 , , -
, 5 ( 2 1 9)
.
- tsine2.m ( -
), , -
( ).
a x i s ( a x i s ) plot - tsine2.m. -
, , = 4.

. 4.2. ( )
9 ().
62 4.

-
0. 10 -
0
2.
- t s i n e .
, -
, MATLAB'e
.
,
, 2-1
k=input(3
: ' ) ;
=0:.05:2*pi;
z=sin(x);
plot(x,z, 'g') ,
*/,
hold on
pause '/,
1 Enter
w=x;
=;
s=-l;
for j=l:k-l
w=w.*x.*x/(2*j*(2*j+l));
y=y+s*w;
s=-s;
end
plot(x,y,'r')
,
hold off
, ' g ' , -
(. 1.2.2).
p l o t (, , ' ' ) ; , -
. hold on,
-
. -
, hold off.
-
. *.
4.4. polyfit 63
4.4. polyfit
-
p o l y f i t ,
, -
,
. (. . 5.) , , -
polyex-m:

=0:.05:2*pi;
b=sin(a);
c=polyfit(a,b,5);
d=polyval(c,a);
plot ( a , d , ' r ' )
hold on
pause
plotCa.b,'g')
hold off
5-
0 G.3, -
. -
: ,
polyval. plot -

1 \

0.8 \
06
0.4

0.2 7 " \ :

0
-0.?.
V /

-0.4 \

-0.6

-.

. 4.3. () polyfit 3 (-
).
64 4.

. plot -
. , -
,
t s i n e . m 1 ~ 3.
. 4.3 polyex.m
3.

4.5.
', -
}- , -
, .
. -
10 . ,
?
. .

2(2 - 200) arccos (~) - \ / 4 0 0 - 2 + = 0. (4.1)

. 4.4 4.7.1. , -
arccos MATLAB'e acos. -
! -
(4.1)
- goatgr.m . (
. 4.4). - ~ 10. -

'' fzero. -,
. -
goatf n. m , (
, ):

function y=goatfn(x)
=2*(.*-200).*acos(x/20)-x.*sqrt(400-x.*x) + 100*pi;
end;
l>
* -.
-
(*.) , . -
,
. sin, cos. exp , -
- -.
( . - )
type. - -. .
4.6. 65

. 4.4. G. -
, . -
' (4.1), 4.7.1.
;\ .

, MATLAB'a goatfn
, , , goatfn(lO)
= 10. , goatfn(25)?
, ..
. ?

a=fzero('goatfn',10)
goatfn(x)=0 =10.
format long .

4.6.
MATLAB'a -
.
, - parnorm.m = 2,
t,y t2.
. *)
2 3
-t = -( - t), . . + 2ty - t - 2t = 0.

5-4196
66 4.

, p(t)x + q{t)y + r(t) = 0, p(t) = 1, q(i) 2t


r(t) = t 2t3. . q. MATLAB'e
p=ones(sizeCt));
q=2*t;
r=-t-2*t.*t.*t;
ones(size(t)), -
1. p(t) = 5
p=5*ones(size(t)). , .*
t. r=-t-2*t. "3 .
, q.r .
- parnorm.m :
(i) ( xl 2, 2, .. .
2 2);
(ii) ( yl = 1).
, -
, 4, -
;
(iii) t ( = 2, tu = 2,
t 2 2, ).
parnorm.m ( parnorm <Enter>)
, -
, -
.
. <Enter>
, ^
. . . 4.5.
- parnorm. m -
linenv.m,

p,q,r t -
t. - parnorm.m
linenv.m, p,q,r (. ). -
- , -
( <Enter>)
1>
MATLAB'a, 5.0,
. ,
vhitebg . . .
4.6. 67

I
1


2.5

1.5

0.5

W/i
0

4
-0-5 \\\\
i

_2 -1.5 -1 -0.5 0 0.5 1 1.5 2

. 4.5. = 2 (
).

. 4.7 -
.
. 10.
- linenv.m : -
, ., -
:

= , ,
q= , px+qy+r=0,
, p,q,r t.

, !! q=4
% , .
, - p,q,r
, , ,
, : k*ones(size(t)) .
, onesCsize(t)) -
, , t.
68 4.

( parnorra.m)
~ 2 (t,t2).
.

4.1

=1;
=-5:.05:5;
>> = . * . * - * + 1;
>> p l o t ( x , y )
. 1 , MATLAB ,
.*.*-*, -
= 5. = 4.95,
4.9,.... ~ 5. , 1 -
}' .
, -
;3 -+- 1 = 0?
>> axis([- 5 -3 3])
: MATLAB
5 < < 5 3 < ]/ < 3.
- cubics.m. -
, .
. , cubics <Enter>, -
, 5, 3, 3,1 <Enter> ,
= 3 + 1 5 < < 5, 3 < < 3.
= 1. . -
-. , .
cubics
, -
. .
. cubics 0.5 < < 1
0.05 < < 0.05. ,
, .
.
4.2 - tsine.m
plot (x,z, ' g ' ) p l o t (x,z. *z, 'g'').
p l o t ( x , y , ' r ' ) p l o t ( x , y . * y , ' r ' ) .
-, , tsine3.m.
69

-
? . -.
(),
0 <
. < 4. -- ? (: .)
4-3 (4.5), . 10, -
f zero. ?
( . .)
,
z 3 ( -
. MATLAB'a
-):

=-19:.05:19;
y-goatfn(x);
z=polyfit(x,y,3);
v=polyval(z3x);
plot(,,'g',x,v,'')

-
, - - . ,
19 19.
z, , z. -
r o o t s ( z ) , . -
,
?
4.4 =. 05: .01:2; ,
x'sin ^ 0.05 < < 2.
( ~. 4.2
.) , -
. 4.3, -
7 ,
. , -
?
4.5 - hypocy .m
( ), -

> . , -
d
.
70 4.

. 4.6. ,
a > .
, CQ ,
d- a 3,6 = \,d = 0.7 .

:

( b) cos ticos t.

( b) sin d sin t (4.2)

(. 4.7.2 . 4.6). - a,b,d


t, .. ,
0 ^ i < 7i7r. , hypocy .m 6 = rf = 1
= 2. . , -
(4.2).
a 3,4,5,6,7 = d 1
: (i) ,
; () -
( ) .

> 2?
71

4.6 , , , -
(,) (c,d) ,

2{ - ) + 2{ - d) ~ 2 - 2 + 2 + d2 = 0.
(: : -
(, ) ,
(, 6) and (, d) .

(x-a)2 + (y-b)^(x-c)2 + (y-d)2,)
, (0,1) (,0) -

2xt-2y + l- t2 = 0. (4.3)
- linenv.m,
2 < t < 2.
4.7 ,
+ qy + = 0 ' + q'y + ' 0 (4.4)
( p,q,T , . 4.6,
t)
:
r'q - rq' rp' ~ r'p
- , , , = ; (4.5)
pq'~p'q pq'~p'q
( .) -
, t,
, (, ) .
, ,
(,) t
p(t)x + q(t)y +
r(t) =0.
, (4.5) , -
.
, -
(4.5). ,
4.6
+ 2ty - t - 2t3 = 0 2 - 1 - 62 = ,

t. ,
72 4.

= -(l + 6t2).

. 4.5. -
,. t. 2 =
2 - 1, 2 6 = (2 - I ) 3 . 4/3 = -, 1616 = 2.
, 21Gx2 = 16(2 I ) 3 . ..
272 = 2{2- I ) 3
.

(4.3). , ,
?

4.7.

4-7.1. (4-1)
. 4.4 , , G
, G -
, G ,
, G.

(i) G , -
BG.GA
G ,
(ii) BG.

, G
, GCB.
CGA ( CGB). (i)
\2{2), ~ a r c c o s ^ , x 2 a r c c o s ^ . -
(ii)

() (ii)
, 507, (4.1).
4.7. 73

4-7.2. (4-
. 4.6 ,
,
,
= (( ) cos u, ( - ) sin it).
, ,
t -
,

. , Q o
Q. CPQ ,
. ,

., ,-.
ova + ) = . = -.

(4.2) ,
{( - ) ,( - b) sin ) + d(cos t, - sin t);
- , t -
.

, -
. -
-
-
.
, -

MATLAB'a.
, -
. ,
, , -
, -
.

5.1.
D = [d\, d2, . , dn\ -
(-
), , , (,
).
MATLAB'a max, min, mean, median.
D -, .
,
, ,

D - [2 1 3 4 7]
5.1. 75

5.1. ; ( D)
MATLAB'a
m = min(D) 1
= max(D) 7
= mean(D) 3.4
= raedian(D) 3
D pr = prod(D) 168
, D dsum = sum(D) 17
csum = curasum(D) [2 3 6 10 17]
s - std(D) 2.3022
D so = sort(D) [12 3 4 7]

5.1 1' , -
MATLAB'a. , -
; -
?
>> D1 = - sort(-D)
-
. MATLAB'a hist: .
hist(D) D.
min(D) < < rnax(D) 10 -
, -
. :
,
>> histCD, 3)
, 1 < < 3, 3 < < , 5 <
< 7 -
2, 4, 6. () ,
>> = hist(D, 3)
() () -
,
[ ] = hist(D, 3)
1
* D d,
() () -
s, ,

nd~
76 5.

= [3 1 1] ! ' [2 4 6].
: : help
bar, bar. ,
barfx, ) , h i s t ( D , 3).

5.1.1.
-
, . ,
-
.
- tomato.m,
-
.
tomato, .
. (. , -
. .) p l o t (,, ' g * ' )
(, ) (
) * .
p l o t ( , ) , ,
, ,
. :

>> [sx k] = s o r t ( x ) ;
sy = yCk);
>> p l o t ( s x , sy)

, -
.
sx. -
, .
[ sx sy]. .
. ,
,
s o r t , -
.

11
3 D -
. R MATLAB'a .
,
" . . .
5.1. 77

5.1.2.
, -
>1 ,
.
.
-
, . MATLAB'e
( ) 0
1. -
.
, ,
. , -

5 . -
, d ,
t ,
, x l y l ( t):

tomato;
>> d = >=5) ; , ! ! ! !
>> t = sum(d) 7, <<>>
>> [v k]=sort(-d); , <<>> -
,
>> k = k(l:t) */,
, 't ! ()
>> xl=x(k); yl=y(k); '/,
'/,
xl
y l . yl x l .
. t = 7.
.
42 (, ) ,
, ,
:

>> format compact; t = 0 : 0.15: 2*pi; n_count=length(t)


>> x = c o s ( t ) ; y = s i n ( t ) ; %
>> d = (y>=0) & (x<=0); 7, !
>> t = sum(d) 7 <<>>
'/,
>> [v i ] = s o r t ( - d ) ; 7. <<-
'/, >>
78 5.

7, -
7. ' t ' ()
xl=x(i); yl=y(i) 7 .
plotCxl.yl) 7,
. t 10?

5.2.
(, -
, ), , -
,
. , -
. ,
,
. ,
(xi.iji) i ~ 1, 2,... , .
:
= [2,.-. ,],

= 2/2,--- ,
-.

5.2.1.
( )
, , ,
,
= + /,
, ,

Yx = \ ( 1 \
2 = 1

Yn = + 0, \ 1 .,

Y{ = /i i.

= Y, = ( ). ? -
-
5.2. 79

/3, , -
1', j3.
Q \\ Fjj
i, -
-
. -
2 ' 3, -

R2 = | > , - Y'12-

,
. cv 4-

5.2-1.1. : \
'

>> =[ones(size(x)) x]
=\
, , -
.
= .
, (1) = {2) 0.
Q /3 ,

Y = Q + ,
:
,
Y = (1) + (2)*;
plot(x.Y)
(
).

^ , Y -
- . rank(A) < 2,
>: > 2, , .. !
2
5 .
SO 5.

2
, ( , , Y,
-)
Y = * ;
= - Y ;
R2 = ' *

5.2.1.2. : polyf it

= polyfit(x, , 1),
1 (. .
). (2) = (1) ,8. ,
-, -! -
, -
- ,
>> Y = polyval(C,x);
= - Y;
>> R2 = ' *
4.1, polyval -
. ,
.
-, Y .

5.2.1.3. :
5.1.1.
, help tomato. -
, 4.3985 [3 = 0.0966,
2
0.388.

.
(. 5.2.2)
, , .

5.2.2.

, -
.
2
Y = 2 + ( + .
5.2. 81

, 02, ,

i
Yi = /32? + /^ + Q.
MATLAB'e
= polyfitCx, , 2)
(1) = /, (2) = 0i (3) =
(>. -

>> Y = polyval(C,x);
= - Y ;
R2 = '*
help polyf i t , , polyf it -
.

Y = $ + + (322 + 0lX + a
MATLAB'a = polyf i t (, , ) -
-
= [&, . . . , /?2, Pi, a].
{
>> Y = polyval(C,x);
, polyf it -
. ,
5.2.3.
, \, -
, .
,
, polyf it
>> A=[ones(size(x)) . " 2 ] ; /, ." -
'/,
6-4196
82 5.

.
:
,
x
Y = foe-* + fae + a

Y = 02 sin 4- 0\ cos x - .

5.2.2-1. :
tomato.m , -
polyf it (x, , 2). -

[02 01 ] = [-0.0045 0.1776 4.1826]


2
R =0.217. polyfit(x, , 3)
.

[/33 /?2 01 ] = [0.0004 -0.0144 0.2451 4.1088],


R2 0.1905.
toms, ,
, ,
. { <Enter> , -
pause.) ,
!
- toms .m, , -
5-1.1. 1' :
[sx ] = sort(x);
sy = ();
>> = polyfit(sx,sy,2);
>> Y = p o l y v a l ( C , s x ) ;
>> p l o t ( s x , s y , ' * W ' , s x , Y , J w ' )

5.2.3.

, -
,
J
) .17, -
.
5.2. 83

* .
-
-
!
,
; -
, , -
. -
, ;
-
. , -
{1*,... ,^,

= + 1{1) + + , { \

' 1 ' 1. ,
, ( ) -
: :'1' , 1-2' ~
'3* = (
).

( -
) ( ) ,


= [\ ]

x
(i) . rT(D T
(i) ... X
W]T

(2) . (2) (2) ._. (2)-|


Xv LC, Xo Xn

(P) . rjp) (P) ... fp)lT


n
. ' L 1 2 1

~ 1, ,
^1' ,^2',... ,' '

= 3 ( ).

84 5.

(.. ),

= (a Pi ,3o


{2) ,(3) \
Yi \ 1

?2 "(2J .(3)
= Y =


V

( MATLAB'a)
= .
, , \!
-
( ).
, p o l y f i t .
, , p o l y f i t
. . 17
polyf it2.m, = 2.

- [ 8\ 62 ]
3
2 , MATLAB'a
( x l ^ , 2 ' 2 ' ..)

>> A = [ o n e s ( s i z e ( x l ) ) xl x2 ] ;
=\; Y=A*c; r=y-Y;
>> R2 = r ; * r

5.2.3.1. : d i a b e t i c . m
- d i a b e t i c . m ,

>> help diabetic


>> diabetic
, x l , 2, . ,
= [36,9601 -0.1137 -0.2280 1.9577],
a R2 = R2 = 567.6629.
85

,
(.. -
):

= ({1\{2\/(}) = 36.9601-0.1137 ( 1 ) -0.2280< 2 1.9577 ( 3 ) ,

^1) = , ^ ^ = .

5.1 - marks.m ,
-

. -, marks, -
m k d a t a .
>> x=mkdata(:,1);
>> y=mkdata(:,2);
-
( ) (
) . -
:
(a) (.
5.2)
rv 4- >3

' 7 + &-
, -
, ,
- . -
(.. -
),
.
, .
(b) -
. -
1 ). , ,
.
1;
.
, -
86 5-

:
tan0i - t a n 0 2
tan(0!
v - 0 2 ) = --~ji .
1 + tan 0i tan 0 2
5.2 - mannheim.m -
-
-
. mannheim -
mdata 22 3.
mdata , . -
:
(a) ,
sx sy.
(b) -
. = + ,3
.
(c) > - )
( -
):
) _ . < 7, (2) _ / 0. < 7,
[ 7> > 7 [ 7, > 7
7 = 3000.
-, x l = x | : l '
2
2 = ' ' . -, 5.2.3
= 2, -

. ,
,
p l o t ( s x , s y , ' * ' ,sx,Y), Y, , -
, 5.2.3.
,
? ( ) -
, , -
, .
: ,
? -
, h e l p mannheim. , ^
min(7,;) = ;' 1 ' + ^ .
5.3. 87

5.3.
R2 :
(. 5.2.1). , -
.
5.1 { .)
, 6 R." :

. (5.1)

, (i)
0, : 0 = 0.
(ii) , ,

Y^XjVj < ||x|j 2 ||v|| 2 (5.2)
i=i
, v R n . , ,
v Vj = sign(xj)sign(yj)yj 6 R71 j =
1,... ,7i, (5.1) ,
() (5.2), , R

j=i

, = |||| 2 /|}2, :

(5.2). (5.1).
88 5.

5.3.1.
R2 0, -
,
_
R2 = 0 - ^ R2 = 0.

..

, ( /3),

\ ( \ / 3/1 \
2
~

\ \ \

( )
2
() = ( ) = ( " -4) ( - ).


= . [5.3)

2x2,
,

, Xi !
..

= ( ,3):
.
^2(xi -x){yt -)
= 1
- '

/,
.
, ,
, (-
). -
,
'2
2
' _
.
2
"" ' (3 ~ ,3

.

- , -
,
2
=4 <0
\) \2 ) \32
T
. det(.4 A) / 0 | ^ | > 0 ^ ^ > 0.
,- (..
). , -
, .
-
. w 4- h 6
R 2 ( R 2 ):
$(w) = ( - Aw) T (y - Aw) = w T . 4 T . 4 w - 2y T .4w + y T y .
,
( + h) = () + (Ah)rAh + 2 h T ( . 4 T A c - ).

, , ,
2 2
( + ) = ( + ) - ( ) + ||.4||2 > ()= ().
, (5.3) -
.
6


,
.
, -
. -
-
.
-
, .
, -
, ,
.
-
,
MATLAB'a.

6.1.
MATLAB'a rand
(0, 1). -
, , -
! -
, ,
1'.
, , :
rand , (0,1)
randC 'seed' , 13) .
, >> 13-
1
' . -
. .
6.1. 91

1 = r a n d ( 2 5 , l ) , - (0,1)
>> rand( ' s e e d ' ,0) , <<>>
, .
>> = rand(3,4) , 3x4
. ()
>> rand( ' s e e d ' , 13) ,
, <<>> 13-
2 - r a n d ( 2 5 , l ) , !

, -
*, , seed
.

>> time=round(clock) , round fix,


7, c e i l f l o o r

time=[Fofl
],

>> r a n d C s e e d ' , t i m e ( 6 ) ) '/. rand( ' s e e d ' , t i m e ( 5 ) * t i m e ( 6 ) )


, , ,
: seed, -
.
10 000-20000 ( 0, -
).
MATLAB- rand -
(0, 1)
x=rand(n,l) x = r a n d ( l , n ) . ,
rand(n) ,
rand(m,n) n- (0,1).

(a,b), ( -> ), -
,

>> = r a n d ( l , 3 0 ) ; '/, 30 -
. (0,1)
>> = 12; = 99; '/,
>> = + (-) * ; '/, 30 , -
'/, (,)

,
(, ).
92 6. ,

6.2.
MATLAB'a ceil, fix, floor round, rand -
. ceil(x)
> , floor(x) < round(x) -
11
. fix ceil,
floor , -
, .
:

ceil(1.2)=2, ceil(3)=3, ceil 1.9)=2, ceil 1.5)=2,


fix(1.9)=l, fix(2)=2, fix(-1.6)=-l, fix(-2)=-2,
floor(1.2)=l, floor(3)=3, floor(1.9)=l, floor(1.5)=l,
round(1.2)=l, round(3)=3, round(l.9)=2,round(-l.5)=-2.
, -
0 , 1 . . . . , (.. -
[, ;]),
>> = rand(n,l); floor(k+1)*)
, -
1,... , (..
[1.&]),
ceil(k*x)
round -. .
round(10*)
, 0 , 1 , . . . . 10 -
. ( , ? -
, 0, , 1, -
round 9.99 + 0.5 ).)

1,2,... , , randperm. -
, :
>> = randperm(9)
>> = ceilC rand(9)*5 ) ,
7, (1,5)
>> = (,:) '/ ""
1
. . . .
6.2. 93

- 0 1, U -
| . ,
0, -
1.
r a n d ( ' s e e d ) ,0) ; x=rand(100,1); . : ()
>> =>1/3
0 , ()
> | 1, () .
, [0,1],
0s \ . .
sum(c)/100 |.
, =>1/3,
>> r a n d C ' s e e d ' , 0 ) ; x=rand(100,1) ; % : (0,1)
c=round(x + 1/6)
. ~t , -
| = ~, ! ,
? -
.
?1*
. seed=121,
2x6 [1,4] [0,3] ,

randOseed' ,121) ; x = randC2,6)


>> = ceilC 4*x ) , CD [1 ,4]
>> z =floor( 4*x ) , (2) [0 ,3]

= 1 2 2 1 3 2
3 3 4 2 1 1
z= 0 1 1 0 2
2 2 3 1 0 0

^ (
0.6900). .
94 6. ,

6.3.
, MATLAB'a rand ,
l
U(0,l) \ , ,
,
, 11(0.1) -
. -
unirand.m.
. 5000 , -

rand ('seed', 19) '/, 'seed'


7, 19
>> z=unirand(0.5,6.499,5000,3) ;*/,
7. (0.5, 6.499)
>> = round(z) ; 7. [1,6]
>> [ y]=hist(r,6) '/,
7,

6.4.
1000
, 0 1,

randnC'seed',12); x=randn(1000);
seed ; rand, -
randn! -
, m -
s,
>> = m + s*x;
- normrand.m.

.
, m 3 -
s = 5, 2000

>> randnf 'seed', 11) 7. 'seed' 11

) . , -
.
6.5. 95

= normrand(3,5,2000,2);'/, N(3,5) mean=3 & Std=5


>> h i s t ) 7,
7.

normrand.m

>> r a n d n ( ' s e e d ' , 11) '/, ' s e e d ' 11


= randn(2000,2) ; . '/, N(0,1) mean=0 Std=l
>> = 3 + 5*; 7.
>> h i s t () 7.
7.

, mean(x) = [0.0318 - 0.0346], mean(y) = [3.1591


2.8270] std(y) = [4.9989 5.0467].
, rand, ,
randn c e i l , fix, f l o o r round. , -

, = 3 -
s 4,

nl = 9; 2 = 7; = r a n d n ( n l , n 2 ) ; m=3; s=4;
>> = round(m + s*x);

. rand randn -
. rand -
. r a n d ( ' n o r m a l ' ) r a n d ( ' u n i f o r m ' )
rand !
,
, , , -
rand!

6.5.

1 ',
,
MATLAB'a rand. -
, , -
L :

. .
96 .

, U(0.1).
- exprand.m,
.
-
20 000 ,
(0,2.4) m 1.2;
m 1.2
s = m 1.2;
i = 1.2:1'
>> randC' seed 1 ,0) ; n=20000; 7,
7. ' s e e d '
>> m=1.2; s=1.2; '/,
7,
>> = i m i r a n d ( 0 , 2 . 4 , n , l ) ; '/, (0,2.4)
>> randnC' seed 5 ,0) ; '/,
'/, ' s e e d '
>> = normrand(m,s,,1); '/, (m,s)=(l 2,1.2)
>> rand 'seed',0) ; ,
, ' seed'
>> z = exprand(m, n , l ) ; , . ( )
subplot(131) ; h i s t ( x , 9 0 ) ,
subplot(132) ; h i s t ( y , 2 0 ) .
>> subplot(133) ; h i s t ( z , 4 0 ) '/,
- .. -
. 6.1, -
. , -
t m,
MATLAB'a mean std, z -
.
6.6, -
. ,

[1.3 2.4 5.1 6 8.3]. -
i n t _ a r r [1.3 1.1 2.7 0.9 2.3]. t = 0.
, -
exprand.m, -
?
1
> 4.0 s u b p l o t ( 3 , 1 , 1 ) , .. -
. .
6.5. 97

200 1

100

0.5 1 1.5 2
4000 i 1 1 -i 1 1

2000

-4 -3 -2 -1

0 1 2 3 4 5 6 7 10
. 6.1. .

() -
: int_arr

arr(l) = int_arr(l) = 1.3;


arr(2) = int_arr(l) + int_arr(2) = 2.4;
arr(3) = int_arr(l) + int_arr(2) + int_arr(3) = 5.1;
arr(4) = int_arr(l) + . . . + int_arr(4) = 6;
arr(5) = int_arr(l) + . . . + int_arr(5) = 8.3.
MATLAB'e -

>> t = cumsum(z) ;
. 6.1
z

tk = V 2 i , = 1,2,--- ,20000.

7-4196
98 6.

t ( l ) = 0.2966 t{20000) = 24036.2043.

,
(), -
. , ( )
131 9 -
. 50 ,
I |^ -
. ,

m = 180 / 131; rand('seed',0);


>> z = exprand(m,50,1) ; h.ist(z)

z ,
t

>> t=cumsum(z)

t(l) = 0.3396 (50) = 69.3055 .

6.1

140 -
, . (-
9 5 .) |
, -
; 50% Nintendo (Super
Mario) 50% Sega (Sonic the Hedgehog).
30 -
, .
(a) -
30 , .
.
(b) 30 -
, ( -
), (
+ 1, 1)
(Nintendo +1 Sega - 1 ) .
99

.
() (-
30):
.

Nintendo Sega.
6.2. , ,
0 1 | , | -
| . -
0 I 1 +1?
MATLAB
;
, . -
,
f p r i n t f s p r i n t f . ,
>> = p i , = 35 = 15
_1 = [ ]
f p r i n t f ( ' _ 2 = '/.5.3f '/.5d f/,d\n' , a , b , c )
3 = s p r i n t f (''/,5.3f '/.5d '/,d\nJ , a , b , c )
"?.5.3
-
, L%5d:
, 1%
. ,
'%6.1.
0.2 , 15
-
, .
, 75% -
, -
[0,80]. 25% -
, -
90 -
20.
(a) 15 5-, (0 -
, 1 = ) 15 5 .
( 6.2, , -
, 0 | 1
jj.)
(b) -
100 6.

15 15
5 . ( ,
, 15 5. -
.)
(c) () (), -
15 ,
5 .
(d) 15 -
5
(), ,
.
(e) -
5
.
. 15 5--
. -
15 5- cumpass, p l o t ( a r r , c u m p a s s )
5 . -
, help p l o t a r r (15, :)
cumpass(15,:)?

6.6.
6.6.1.

.

Uj+i Kui(Mod M), 1, 2, 3 , . . . ,
.Mod M , . -
, . i
, 0 < iti < . -
, { = ( [0,1).
, -
, ( ) , -
\. -
('seed'). -
, , ,
.
G.6. 101

MATLAB'a -

>> unew - rem ( * uold, M )
>> rand^num = unew /
\ = seed . ..
:

>> for j = 1:
>> seed = rem ( * seed + shift, M )
>> rand_num = seed / M
>> end
s h i f t , .
i ..
" - randme .m,
. randme. ,
(. . a-randme(4) seed=2
shift=O, ' == 32 / = 5,
:

K*seed = 64, seed = 4, rand = 0.8


K*seed =128, seed = 3, rand = 0.6
K*seed = 96, seed = 1, rand =0.2
K*seed = 32, seed = 2, rand = 0.4
rand, '.
. -
seed, s = rand ' s e e d ' ) , rand ' s e e d ' ,45)
seed 45. , -
seed MATLAB'.

>> rand( 'seed' ,0) ; , seed =


>> s = rand('seed') , s
>> rand(' seed' , 1) ; 7, seed = 1
>> s = rand(' seed' ) ; '/, ,
fprintf ('MATLAB Seed = 7.12.Of (initially set)\n',s)
>> for j = 1:5, r=rand; s=rand('seed');
>> f p r i n t f ('MATLAB Seed = '/12.Of r a n d = */,d',s , r ) ;end
MATLABV, , = 7
2'i] - 1, , randme.m -
, , r a n d
102 6.

shift! -
1^1'

seed = (A'seed-i- shift) (Mod M).

6.6.2.
(
) ( -
(0,1)). -
, -
() /. '
, xj ->, ,
\ < '2,

V(X! < X < 2) = I ' f(t)dt.


J .ci

() F, i;
F{x)=V(X<:v):

1' [
F(x) = / f(t)dt / f(t)dt 1.
J ; J -ex.-
.
[0.1]. -
U(0.1).


(), < 0:
Fix) - } . [0.1),
[l. 2:>1.
.

2,2

- 5.0 rand (
seed s t a t e ) , /
rand( ' s e e d ' ,, rand ira . .
.
6.6. 103

// <
N(/J.CT 2 ).
f.i = 0 1, N(0.1) -
, MATLAB'e -
randn. (/.2)
z -f- /;,,
N(0.1).
.
. , (
X) ,
:

;
( )
, ..
V { (. + /))
11 - - _ _ _ _ _ .
/i>0 .

V .

Z) =
^ \0, <0,
, ,

F(z) =
0, <0.
, -
( ), -
-
. , -
,

1 - " = ,
1
( = " )
z = /iog(l - .).
104 6.

, - exprand.m does. -
6.5, 131 ()
180 , h0 = ~
. ,
(t.t + h0) V = 1.
V{(U + h)} ( + /,)} = 1 3 1 / 1 8 0 = .
h->ho h h0

, I = 1/, .
7

, MATLAB

.

7.1.
()
, ,
dx
- = -*, (7.1)
,
dx . ,
= -Xdt

.
lnx = Xt + ,
. .
x{t) = xoe-xt, 0 = (0). (7.2)
, , ( -
) ( ).
,
(, -
. (7.1)
-.

, -
,

) (7.3)
106 7.

22 04 0.6 08 1 12 14 1.6 1.8 2

- 7.1. dx/dt x. -
.

, , -
.

xit) = (7.4)
- ( 1 -

MATLAB ;>: ,
.
-
. - f odesol .m -
. ,
>> help fodesol
.
, -
dx/dt /(, t) -
-- t.x,
. -
. . 7.1.
(t.x) f(t,x),
, dx/dt, -
7.1. () 107

t, .. . -
, , (t,x),
, f(t,x). -
. -
,
. -
( = XQ t ~ to)
(j.e. ). 1
(7.1) (7.3) : f odesol.
1]
f o d e s o K ' f n x t ' ,0,2.5,-3,3)
fnxt.m -,
. (
). f(t,x) ~- . .. -
(7.1) 1. , , ,
imax- xmin - ! -
. fodesol
, ,
.
, (fn,.xo). -
. .
, ,
.

, fnxt .m,
myfnxt.m.
(7.3),

= = 1.
fodesol -

( t -
).
x(t) XQ x(t0) < 1 z-0 > 1.
, ,

,
- 3 < t < 4, - 3 < < 4.
108 7.

, -
fnxt.m.

7.2.
MATLAB
. ,

dx/dt = f(x.y). dyfdt {,) (7-6)


, , , -
x(t) , . ,
. -
t. -
.
, -
(7-7). .

7.2.1.
(7.6) (\;/)
~, -
. . 7.2.
(,) , , ,
f(x.y) = 0 (,) = 0.
, (,) . -
-
. , -
, /(,) 0 (,) = 0.
,
,
.
-
(i) -
. .
() , -
. -
.
(iii) -
. .
7.2. 109

1 9 10

. 7.2. (7.7) -
.
.

(iv) -
.
.

7.2.2.
- species.m
, morn .

= ( ~ - ), = y(d- ex ~ fy), (7.7)
-- .
, , d . -
, -
. , -

..
110 7.

, ,
:
(i) = 24. b = 6. = 8, (1 = 2-1, = 8. / = 6,
(ii) a = 24. & = 4, = 6. <! = 24, = G. / = 8.
(iii) a = G; b = 0, = "1. (/ - - 4 . = - 1 . / = 0

.
(.): , (7.7).
= = 0.
,
. ( . ) = 0 .
y(d cr j ) = 0,
(,, ) . 6, , . . . . /.
, ... -
.
4 . -
. ( ),
> 0 > 0. ? (
.) -
,
.
species , ,
-
. -
, . ,
, . -
, .
- .

7.2.3.

-
. -
MATLAB'a
. t:

^_-+u' = 0 (78^
v
dt2 ' dt :
' }
7.3. 111

--, -
.
. -
v w v = chv/dt.
,
dw

^ = k(l-u?)v-w. (7.9)

- vderpol .m, -
(
vderpol ). , , -
0.1,
. -
,
. ,
., 7.2.1, -
.
.
- vderpol .m vdplfn.m.
(7.9). -
. -
, , -
-
. (. 22)
.
vderpol. m vdplfn.m, -
, , my solver . myslvfn.m.
-
. , .

7.3.
(7.1) ,

(). . .
-
.
-
x(t + 1) -- x(i), a
112 7.

, -
. , ()

.+1 - = -. . (7.10)
, ,
, , ..
x(t) - . t = 1 .
,
xn = xQ(l-\r (7.11)
(7.10).

1 .

, -
(7.2),

" a l - n A ( l - A ) n .
, ,
.
, -
. ,
, a -
.
-
, . ,

: (-
) .
-
, , -

:
+2 - 5 + 1 + 6 - 0. (7.12)
, -
+2 ~ %n+i x, 1+ i - . ( (7.12)
). , (7.11)
xn = zn. (7.13)
113

(7.12)
Z 7)4. - .? U

" ( ; 2 - 5 + 6) = 0.
z = 0,

z=2 3.
(7.13). -
}) ,
= 2

+ 3'
. , .
, -
. , -
, ,
. , (-
, M A T L A B ' O M ) , ], -
, . -
diffeqn.m
.
>> diffeqn
.
- dfeqfn.m, , -
,
.
, [.i'o,xi] =
[1.0,2.0], [1.0,1.8] ..

7.1 f odesol .m
myfunxt.m, -
:

7.14)

:
() (2), ;(0) = 1.5.

-4196
114 7.

(b) (3), (0) = 0.055.


(c)
,
.
7.2 7.2.2 -
:
(a) , ;
(b) :
(c) .
-
() , .. -
.
7.3 - vderpol .m vdplfn.m. (-
)

. ( ,
, t, -
.) - 3
:(4) w(t)
, :
(a) ;(0) = 0 , '(0) = 1:
(b) w(0) = - 1 : ?/:(()) = 1:
(c) (0) - 0 . w(0) = - 1 .
, w(t)
.
7.4 diffeqn.m, -

6?1+2 :,-, _|-1 + 2 = 2 + + 2
, . = 1 2. , ,
xiQ. ,
~ 8.
II


8. 117
8.1. 118
8.2. 3 3 118
8.3. 4 x 4 121
8.4. 5 x 5
() 123
9. , 124
A. 124
B. 128
10. : 133
A. 133
B. 136
C. 139
11. 147
A. 147
B. 156
12. 166
12.1. 166
12.2. 168
12.3. , 171
A. 174
B. 177
C. :
181
13. - 186
13.1. 186
13.2. z 2 + 1 ^ 0 187
13.3. 188
13.4. z 3 z = 0 191
116

14. 194
A. 194
B. 200
14.1. 201
14.2. miyipi. !'-J-footnoteiiiark 20.3
14.3. 209
14.4. ( ) 209
14.5. 213
15. 214
15.1. ID: 1 215
15.2. ID: 2 - 216
15.3. ID: 217
15.4. 2D: 221
15.5. 2D:
225
229
16. 233
16.1. 234
16.2. 235
1G.3. 239
16.4. _4 = b 240
16.5. ,
241
245
17. 249
17.1. : 250
17.2. ID-: - intdemol.m 252
17.3. ID- 252
17.4. ? 256
17.5. 257
17.6. 2D - intdemo2.m 258
17.7. , -
258
17.8. '\'- 263
17.9. 264
17.10. 264
266
18. 270
18.1. 270
271
8


. , -
,
. . .
- , -
. .
, -
[16].
.

, -
.
, 3 3-' -
R 9 R 9 . ( -
:
R".) -
. ,
" R" -
uoii X, ,
X . -
-
,
.
MATLAB'a
, ,
^ . 2. - -
:for' 'if', -
(. . 3). , -
: ,
, -
118 8.

5 x 5 -
.

8.1.
//-
:

, -
Ova ,
'. , , . -
.

= 6.
3 + 2 + 1 ( -
) 2 + 2 + 2 ( ).
-
,
1.2 ,/ . ,
71 3 .

(8.1)

MATLAB'a. magic (
magic (3)). -
, ,
, -
.

8.2. 3 x 3
(i) 3 3-
/ tt,2 ai3 \
.-4 = {a,j) 2i 022 ^23
\ 31 "32 33 /
8.2. 3x3 119

, ^- , -
, , -
. )"
AIv 0. 8 10-

- 1 1 1 1 0 0 0 0 0 0
-10 0 0 1 1 1 0
-10 0 0 0 0 0 1 1 1
-110 0 10 0 10 0
-] 0 1 0 0 1 0 0 1 0
-10 0 1 0 0 1 0 0 1
-110 0 0 1 0 0 0 1
V -1 0 0 1 0 1 0 1 0 0/

\. v -
( Ci,i2 <"'22
( -
.)

(ii) MATLAB'a rref.


/ 1^.
, . ,
:-' , , , -
, ? (-
, , -
- -
,

.4,

, .)
. -
3 3-

ai2 -1 21 22 23 o,3i -J ) R 9 ,

3.

lj
-
. . . .
120 8.

(iii) ,
/ 1 -1
Ei = -1 0 1
\ 1 -1

. , (ii) ,
3 3-

= 1] + 22 + X-AE?J
Ai, , A3 G R (: , -, -->, -$ -
.
\. ,
' R 9 .) ,-,
(8.1), ?
(iv) 3 3-

11 + 23 + 32- 12 + 21 + 33: 13 + 21 + 32; 1 2 + 23 + 3'-
,

, .
, n-
2 2 .
,
.
.
3 3- /, ,
, -
(, M l ) , , -
6 R. (
, /1 -
, -
, .)
(v) 3 x 3 .
(iii) ,
(XiEi + 22 + X3E2)(fi1E1 + fj2E, + fi3E3). (8.2)
8.3. 4 x 4 121

, E,Ej ( i ~ )
I.P.Ei, (I -
3 3-). , (S.2) -
.
, -
1 . 3 3 1,.-.
, .. -
3 x 3 . ( -
,
, 1., -
. .
: R g , -
1,.% .
, - -
. - -
, , -
1,,
EltE2,E3.)
(vi) , ,
3 3- , , (1.1.1)
-
. , -
, > 0 (1,1,1)

'\ ( -
.) (v).
. 3 3 -
1 ,
.

8.3. 4 x 4

(i) , ,
, 4 x 4 . 10 17. -
MATLAB, , 9. .
122 8.
Ul
R 4 x 4 -
8.
(ii) = \(\) (2) (3) ()} e r i 1. 2. 3. 4,
.. 1, 2. 3, 4 . .
, 4x4 -,
, A(i,p(i)) = 1 i ~ 1.2,3.4. , ,
= [3 1 2 4],

t 1 0
0
0
0
1
0
0 ] 0 0
\
(} 1 ) 0
, ! -
.
1. 2. 3. 4. -
. . -

MATLAB'e:
for a=l:4
for b=l:4
if b~=a
for c=l:4
if c~=a k c"=b
for d=l:4
if d~=a & d~=b & d"=c
p=[a b d] ;

end;
end;
end;
end;
end;
end;
end;1)
, -
, . -
,
11
; end , -
<Enter>. ,5.0
. ..
8.4. 5 x 5 () 123

/v 0. (i) 8.2. , ,
10 17-, , a v
17 1- - ( 1 . . . .) ' .
(iii) .
,
4 x 4 ( . (iv) 8.2). -
}- Ml.
? -
?
(iv) /1
, -
4 x 4

abc4- d 4- e a + b + c + d a + b cd 4- p. a + b + + de
b + c--d + e b 4- 4- de b + c + d + e bc + d + e
-. + 2 I a2c- h 2 e -a 4- 2b + 2c a
2b 2c 2d 2e

, ft, c. d, e . -, -
, M A T L A B ' O M .
.
? -
,
(vi) 8.2? (
, -
, ..,

.)

8.4. 5 x 5
( )
, ,
5 5 . -

? , , -
. ( -
[16].)
9
,

,
. 3.
(). -
.

.


. -
.
.

(-
, , -
). -
, ,
, -
. ,
-
, , : ,
,
, . . , 1?
MATLAB'a
- gcdiv.m . 3, -
.
-, .
- gcdran.m ,
< 1000, , -
. 1.
D, , 125

(i) - . , ?! 500,
. 1.
(ii) - gcdranx-.
, 2. . 1, 2.
i 3. , (4, 10). (6. 9), (12, 21)
(6.3-5) . 1, 2,
3, (5,10). (7. 35). (30. 50)
.
(iii) ,
{. ( , . 1000
) , 1 20. :
, , v. 20, -
, . -

v=zeros(l,20)
, /, < 21. -

v(k) = v(k) + 1;
bar(v) .
fiv) ,
( , .
, ,
, 1, .. . -
, . , | b
. , / .
(,) = h&h\n h \ b (/,/) = 1;
, , (. ) = h.
[l/li){l/h)x. (, , h -
. l/h.) - .

2 2
X l ^ i ( l / ^ ) ~ ?i" /6. ( -
. 1750 .
-
. .)
? -
? ,
126 9. ,

,
20?

() ( -
) . ,
a.b.c (,, ) = 1.
- ( gcdiv3.m . 3).
=1. -
. -
^/^/ 3 );
MATLAB'a, , . 50 ?

(vi) , -
(iv). . ,
. . ,
. 1/. -
, , 1 \ .
, -
, , ,
, ,


2, 3. 5. 7 . 1 1 , . . . .
, .
- primes.m. -
. < 5000. ( (1) =
2,(2) = 3 ..) . , , primes.
?
< 5000. (
.)
, (iv)?

(vii) , . , -
.
, , , , ,
.. , . 1. -
, , ()
, . , ?
9. . 127

: MATLAB'y ,r = = z 1,
.
x ==y== z ==l
' , ..
1, , . : ~ z = 1.
==1 ==1 & z==l
(viii) , -
. ,
. . . .
, a.b,c .

.
, .. .
- .

, ,
. ,

(9.1)

. . , -

.
2 , , ,
(9.1) . , ,
\ ,
(vi). , -
.
z .
-
?
(ix) a, ft, >
1 < .
7? ,
?
128 9. .

.

. 3 -
. . -
, .*
- , .

3.4.
rem(a". ), -
. MATLAB'a .
-
, . -
, ,
, .

MATLAB'a
- ,
, . -
gcdiv.m .
(i) - primes.m . -
, 5000, , .
, = [(1) (^')]^
/-- . . (1) = 2,(2) 3 ; (3) =
5.(4) = 7.(5) = 11 .. primes.
,
: , (5) , -
11.
() (. 3), -
71. tie , -
rem(n"~ l ,7i) = 1.
, -
;- ( ) -
(. 3-4).
() ,
, -
. ,
, ( -
), ,
, ( " ~ 7 , ) 1
9. ,, 129

, . -
, .
, - -
.
- psp2.ra < , -
2. , . , ,
2~1 1 . -
, 2~1 = 1.
, ,
, , -
. , -
, 3.
- , , -
. , , m 2000 ,
- 2~1 = 1 mod n, ..
I!"" 1 1 . , -

>> pow(2,n-l,n)
.
psp2.m, , -
< 5000,
(1) 2,
(2) 2 3,
(3) 2, 3 5.
, :
, -
. -
.

() < 5000? ( (i),


.) , , ,
1 < < 5000
rem{a"~" , ) = 1 = 2, 3 5.
, ? -
, .
>iv) ,
3, 2 3,
. 5.

9-4196
130 9. ,.7. i ices

, ,
3 10000?
() . remfa"" 1 , n)
1, (.. "~1 1 mod ) . , in
icopcMbf , .'- .
(.. -
1 ') , -. -
197G . ,
, [7]. . 5.
'- :. > 1
(.), . 'i.e. , (. ?>) = 1.
:
1. 1. ~ '//'. ). FA: ^ L - -
6, -
. ( , .
1. /( , /moo .)
' = 1.
.
2. : /2.
( \).
1:
1 = /) 1.
\
1 - 1. ,
.
, ,
. , /?.
, . , 1
.
- m i l l e r . m . ,
, . -. -
.
(vi) m i l l e r . ,
. . -
(i), .
1 . ,
. iw. . !
9. HO_i(, nc.e.n;ioupoci!,n: 131

(vii) , = 1373653 = 2 b = 3.
= : ^.- . -
. ?
reniffj"" 1 . N). (?, '.
MATLABa rem 5"~' -
. -. i m i l l e r .m . !)
( 1.) , . .. -
, 1 v.

(viii) , = 2532G001
2. 3 5. 7 (
, ). ~
rem(7"~ 1 1 ,). ( 1, ) ,
.

(:) > 5 10 7 . -
. , , . (-
, , -
. , , 50000002
.)
(<) ( (ii))
-
2?
(xi) 2000 3000, -
2. .
LCCT 3'.'

(\ii) . = mod n ( 11
'>) , | (- ) (.. ).
, = remfo, ), = mod .
, : =
= v mod , ~ v : yv mod . .
2 = 2 mod .
, 2~1"1 I ( 1).
> 0, (.) = 1. ,

,-:= bf"- n ' /2 " +1 1 mod ,j. (9.3)

(9.2) ;,). -
. . -

'
132 9. . .

,
| ( 2 1), (9.3).
h = ( 1,). h / 1 h , ..
. :
(a) h ~ 1 \ ( + 1). ( . ;.
| yz, (.);. ) = 1,=> \ z.)
?
(b) h = , | ( 1). . ?
, 10004681
2, -
. ,
. ( , -
10004681. ,
.)
2.
(ii), , -
.
,
.
10
:

-ha .
, -
;
, . 4,
,
,
.

.


! -
. (
[8].) ,
> , ,
.

,
, -
(4.6).
.
MATLAB'a
- . 4, -
.
. (. -
4.5), = 2m/(m + 1), fo = 1 d ~ 1.
> 0. . 10.1 4.
. - hypocy.m .
,
134 ). :

. 10.1. ."leneri Kiiii = 4 .

or ; (i) t. -
;
(ii) Miic.'io .,
! noinopnoo ; (iiij
- .
. -
/ = ( 1)0 ,
( 1.2).
,, , ,'-- fa-
cos -i- cos ;i 2 cos | 2

+J _____
sin a sin 3 = 2 cos
0
, -
. 2'-^j cos(mO) . ( -
, : = cos 0. = \.)
, , /{),
/ -- - (, ^. , () -
0 ~ , f[0 + ) = - / ( # ) , () = 2.
/(6 + ) -f(9), }'{ + 2~j = f(0) .
. (i).
(ii). (iii), ie , -
.
10. : ]> 135

) , ) ." + ~ = 1. -
icosf. shi t) ((). shiimt)).
.x(sinf - sin nit) - .(/(cos / cos nit) + sini'm 1)/ = 0. (.1)

(
sin((7 /)).] - linenv.m. .
-)"1>: . , 2, 3 4.
in .

(ii) ,
mvost -\- cus(-mt) . sinf - \[!)
4 1 ' + "1
.. ici i5O]jner (1U..L) ])). -
(10.1) /. ' -
-1.7. , (.r(t). i/(t))
oi . , ,
, , -
. 1.

iui) , (. 4.5).

. ( ,
)

( '"' \ , ( \ , ,
. .-- [ - I)-) cos ,- - dcos . = \ -\- \>\ sin + asm .
\ -!- / V" + /
. 10.2 = 5. = 1. d -- 1.
, -
- 0.
(!), . = mt .-
a.b.d. ' .
-\\ ; -
. , , /{ + 1) =
+ . \/{ + 1) = (I.
(iv) hypocy , ]) . -
: , -
. upper -
abs(a+b)+abs(d).
. t = t l : t s t e p : tu u = t l : t s t e p : t u .
136 10. :

. 10.2. , 1
5.

t l tu. -
. -
()
.
(v) ( -
(), ).

.

, -
. -
, , . 4 (-
4.6), . -
,
.

, -
, -
. . 4.
MATLAB'a
, -
. 4, - linenv.m. -
10. : 137

. -
-
.

1'
,
, (,0) ( -
, a > 0) ? + 2 1, -
(cosi.sint). -
,
2x{a -cost) - 2 j y s i n t + l - 2 = 0 (10.2)
(. 4.6). linenv.m, -
. -
, -
. a > 1
a < 1. "

, .
, (10.2),
4.7, ,
\

4.2 - 4. +
= 1 - 2.
1 - 2
t , (10.2)
t. *
, ,
sin t cost, . -
sin" t + cos2 t 1.
1?
?
/ 1. ' = |.

4 ' 2 + -^2 = 1-

? ,
.

Bisection . . .
138 10. :

- ,
, (.0) , ?
, , , > 1. (: ,
cos t ~ \/u '^* - 1 =
.)

/ " , -
.
. 10.3 .
. , , -
, /(.) ~ 0.
/(;;;} = 1 - 2 * + (a2 +- / - 1'2).2 + 22: - 2!'2.

/ 10 ti 2. , = 5
(. . \ -
), --- G i . -
([) (]) /.
r o o t s , . - paramc:.m
(., .) (x(t).y(t)).
= f{:r) = t,y = / i t ) .
paramc .m. (He -

. 10.3. : . /.
'; : ;(.1 -
. , . //
V.
). : l'.V.i

. ! -
]) ,
.)
- 2 = 5 / = 20. -
= 2. = ,1 = 9.582209. ?
, / ?
... , -
( !)
.
, ,
/. . 10.3.

+4 I.
cost suit
4.7.
. = Icns^t.y =
/sin3/,. /, , -

linenv.ra, -
.
,
.
?
9
, -

, .

.

,
,
.
.
140 10. :

-
, , . (
[5] -
.)


, 3 3--
; (. 4).

MATLAB'

-.

.
-
, ,
. ,
. . 10.4. -
:
, -
; -- (-
) .
, -
: 20 50
.

\
/
\ ^ //

. 10.4, -
2.
10. : 141

;
in ,
.
.
4.6 . 4.7.


h t. . 10.5 l(t) -
, {h(t) cost, h(t) shit),
.

ii) , l(t)
; cos t + sin t h(t). (10.3)

'ii) h(t) = 1 + |cos(3). - linenv.m ,


l(t) 0 < t < 2.
, ,
.

[) , l(t) ' .
(ii). , h h(t) +
h(l, + ) 2 t. ,
2 ,
, 2?

{h(t)c,Q%t, h(t)smt)

. 10.5. .
142 10. :

(iv) . 4.7. -
(10.3)
-xsmt + ycost - h'(t)t (10.4)
(10.3) t. ( ' -
, d/dt.) (10.3) (10.4).

x(t) - h(t)cost -ti{t)sint, y(t) = h(i)*mt + h'{t)cost. (10.5)
, ,
.
- paramc.m ,
, (10.) -
h (ii). - constwl.m.
, , -
(, ,
!), -
. ,
(ii). , , .
() , -
, , .
- ?

(v) , h(t) ( (ii)) a,


. -
? - constwl .m . -

0. 0.1. 0.2.... ,1.0 , -
- constw2.m. , hold on.

. hold off -.
,
,
.

(vi) , = 0.5 ()?


.
, 9
(vii) , h (ii) -

h{t) + h{t + ) = k7 (10.6)


ID. : 143

. 10.6. , -
rvre.'ibHbix, -
.

/. ( ; 2). .-
(10.G) - h.
(10-5) ? ( -
, !) h,
, (10.6) -
. .
. (10.5). -
R , -
.

(viii) h (10.6),
, -
(10.5). ,

x(t + ) = x(t) - k cost. y(t + 7) = y(t) - A-sin f.


in , , ,
t t + , l(t)
l[t + 7r) (. . 10.0).

,
. .
(. . 10.7). -
.. 2. -
144 10. :

'
(a cos r, sin t)

, 10.7. , -
.

2.

cost, sin , < t < -.

, ,
(acosf, sini), m(t), -
, 2 (. . 10.7).
(ix) , m(t)
2 2 2
cos t + sini = a 2/' sin t + cos 1. (10.7)

(x) (10.7) ,
(10.3) - .
m(t) ,
. r(t) (10.7) -
,

x(t) =r(t)cost-r'(t)smt)y(t) = -(r(t)smt + r'(t)co3t). (10.8)


a
-
2?
() - constwl.m - .
(10.8) /2 <t< 37/2,
t.
constw3.m.
10. : 145

(xii) :
a = 0.75, xl = - 1 . = 2, yl = -1.5;
= 1.25, 1 = -1.25, = 1.25, / = -1.25;
= 3. ? = - 3 , xv = 1, / = - 2 .
, xl.xu.yl -
. -
. ,
, ..
.

') ( )
, ,
.
> 0.
^xiv) -
, > 0,
. (10.7)
px + qy = ,
,
. ( , , '
)
q r
' q' T'
" " "
t /2 /2. = cost.q = asint,
,
+
" = 0 (, ). , ,
v 0,
2( 2 - I)2 sin 2 t cos 2 / 2(a 2 - l)(cos 2 t - sin 2 t)
;
v 2u + a-\

/(a2 sin2 t + cos2 t).


() -, -
V.
t=-pi/2:0.01:3*pi/2;

10-4196
146 10. :

v= ;
plot(t,v)
hold on
plot([pi/2,3*pi/2],[0,0])
hold off
1 1
plot .
, , : v
0.7>, 1.25.3 ,
(xii) ,
v . I.
. is
. ?
11

[ , 1 -
(]: , - -
, -
.. , .

.

,
. ; , , -
, , -
, ,
. -

'). [1].

, 2 2-. -
. ,
- .
MATLAB'a
.
)', -
.

.


-
,
.

*
148 11. ,

(0,0)

. 11.1. , . 100 / .
Bi.$2- \ pi (?] ir di .

, -

, . (
. 10.)
. 11.1.

100. -
I. / < 0, ,
, (100 + /. 0).
, .
, . . Oi^Oo
( ).
100 (100 + I, 0) 9\
( ).
(100 + / + 100cos#i, 100sin(?i).
I 02 ,

(lOO + J + lOOcosfl! + J cos 0 2 : 100 sin01 + / s i n 0 2 ) .
?.
100. I, a
:)'!
-2 . .
2#i 2#2 ,
30j 3#2 ..
11, JIoMRiibie 149

-
:
,
? ( ,
, - .)
, .
?
( ,
, 1 ').
,
: ,
, 1, 2. 3 . . . . . ,
. -
,
, .
- zzl.m , . ,

,/ < < xu,yl < < ).
. , ,
, -
. zzl .m ,
. xl ~ yl. yl + xl.
;\ zzi.m I 40, 0\ =
15. 0-2 = 9, 40, xl 320. = 460; yl = 15.
I 50. \ 175. 02 = 185. 72.
/ . 0. = 150. yl = -74.

,
100 h I
/2. vi,V2 - 1\-2 -
, \.2
#i,#2- 1', , v (, 6),
\ v
os#i -sin6 1 ] \ (
iin cos -i \ b
\ \\
0} \. 2 6\
11
ii ^ , -
. .
. .
150 11.

. 11.2. <;
\ ] .

#2- ,
(. . 11.1):
V, + Vo + -2\'-2 -Pi

l
+ (v 2 +/? 2 v 2 +/J2V2 + . .p5~ vL>). (11.2)
(.2) -
. -
' -
, 1\ . V],
. 11.2. ci ,
Ci ( ) . -
.
, :
vi = ci - pici. (11.3)
Vi + /)ivl + p j v i + . . . + p f ~ 4 i = cj - p f c i . (11,1)
( (11.2), (11.4)
11. , 151

( vo)

Cl - \\ +-2 - 22- (11-5)


ci ^-
(.) , 2,
.

,
, , - .
(, -
), ,
, .
. , \. 9-2 -
.
(VI.5) , ,
ci = \\ 2 = pk>c2- ( ,
, .
? -
.) , ci
< />, 0j .
, 360. , ,
IT
360
* =

, -, -

3G0 360
(,01)
, ,
, s,
_ 360
5
(360^^)'
( , , s
, . ,
. )
(11.6). (.. -
) zzl.m,
- gcdiv.m . -
- zz2.m. ,
152 11.

. -. -
, , -
.


, -
. -
(11.5) ci + > ,
.. (^(xl + xu), ~(yl + )).
(11.5).

, (11.3), pi
(11.1), V] = (h,0)T ( -) ,

-1
Cl = ; fl
I "- i 1 -cos0i

sin - 0 ] , cos -i
2 ' 2
: -

1 1
1 - cos 0i = 2 sin - 0 i , sin 91 2 sin -0i cos -B\.
, 2 -
1 2.
\.
&0J.,
cos kOi sin k9\

\ (11.5), ,

( sin ( + )
cos(o-f-b).) , = ci +2 ,
11. 153

(11.7),
.


, (11.7) -
. , ,
. , ,
(11.7) ,

d= ^ - + - (.8)
2sin 7>9\ 2sin 02
(, ). , -
,
2d. ,
xl = a ~ d, xu = a + d} yl b d, yu b + d.

zz2.ra zz3.m 3 zigzag-


, ,
. -
, , , -
. ,
h = 100.


, , -
1,2,3,... . -
(11.7),
, -
1,2,... ,s, s ( (11.6)),
0 s. , [0,s],
, 1000 , :
-1:1000;
k=s*n/1000;
, 1000 s/ s.
, (11.7),
, -
zz4.m. . . 11.3 /i 100,
12 40, 0i = 45, 02 = 9.
?
154 11.

-300 -200 100 200 300 400

. 11.3. ( h = 100, l2 = 40, 0, = 45, 2 = 9; . . 11.1)


, -
1-2-

9\ = #2
, 9\ = 9 (11.7), -
,
1
(h +/ 2 )sin ( k- - -h +I2)cos{k- -
2 sin
('(, ()), , , -
1 , , (A", Y)

sin 1
. (, ,
, (11.7) .) -
,
. ,
? . ?


(11.7) ,
( . 10, -
), ,
, .
,
11. 155

, 11.4. ()
.

, , d
(. . 11.4 -
, , d ,
),

= b= d=
202 sin U 2 sin i 0 2
( .) -
b = d, , -
.
. , ,
/i0i sin |02
02 sin 10i
zz4.m zz5 .m, -
I2, 0j.,02 (, h = 100).
. -
, ?
156 11.

.

-
: ,
, -
. , -
{., , [17]),
,
, ,
.
[9].


: .
. -
, -
. .
, ,
.

MATLAB'a
quad8, -
f mins, -
f s o l v e .
- .

( )
, ,
,
. -
.
, ,
, -
, . -
. ,
, :
, -
. ., , [17].
, : .
,
.
11. . 157

. 11.5. , (0,2) (4,0).

, (0,) (d,0) -
, . 11.5, = 2, d ~ 4.
,
,
(0, ). ,
-
, , v
t,
,
2
-mv =mg(c-y), i.e. v = \/2(-), (11.9)

^ , . v =
ds/dt, s , t -
. , -
.
( 10), , -,
0.1.

(0, ) (d, 0) ,
-
, . ,
. -
158 11.

, -
MATLAB'a quad.8.

.
(0, ) (d, 0), ,
> 0,d > 0 ,

(11.10)

(i) ' djdx,


(ii) , , , , djd9, a OQ
0\ (0,) (d,0) .
,
, 0 (i) = $ (ii)
= ,
. ,
= , { -
]).
MATLAB'e quad8,
, -
.
1 ): quad8,
,
= 0 ( #Q), -
. , ,
.
-
.
- ,
, .

,
(0, ) (d,0)), ,
.
2
(i) = + f3x + , -
(0,). > 0 ,
. , ,

*> -
, .
11. 159

(d, 0),

2am.
d(2m - d)'
, > 0 ,
> ~d. =
0 /. ^/ < < d. ,
(d.O), > d,
.
(ii) = 2,d = 4. m
2.5.3,4 5. ( , -
paramc.m, , -
, .) -
, (0,2)
(4,0) .
() - s l i d e l . m MATLAB'a quads,

0 < < 0.01 (. ),
(i) (11.10) .
,
.
- (--
), , -
slidelfn.m. -,
. -
, ( ),
- . -
, , -
yl.
2 d = 4,
2.5,3,4 5.
- ( s l i d e 2 .m) ,
, , ^d+0.1 d 0.1,
. r e s u l t , ,
, .
:
m=d/2+.l:.l:d;
result=2eros(length(m),1);
for i=l:length(m)
160 11.

result(i)=time;
end '/, i=l: length (m)
plot Cm,result)
, global s l i d e l . m
for! s l i d e l f n . m .
= 2, d 4 -
,
. -
. ( ?!) ~ 2,d = 3
, -

.


, (0,) (d, 0) -
, (,) (. .
11.6). .
, cud , & .
(iv) ,
( b{x - d)
= [x > a).
ad

(v) ,
(11.10). -
{,) (\,\)\ ,

(0,)

(d,0)

. 11.6. , (0,) (d,0), -


(, ).
11. 161

. dx dy/m, ,
, \
yi
l 2vTT^, v ,
.II)
= 2, d = 4, ( 0 < < d, 0 < b < ),
,
2

MATLAB'a
fmins, , -
(11.12). -, , slide3fn.m, -
, .
function realtime=slide3fn(p)
g=.l; c=2; d=4;
=(1); b=p(2);
realtime = ;'/, ,

fmins fmins ( ' s l i d e 3 f n ' ,


[*,*] ' ) ,
, . (
, ' .) -
,
.. (, -
, , a = 1, 2.1 > , , -
, fmins .)
, . -
.
.
(vi) (11.12), 6 = 0,
0/0.
-/2-

, = 0 ( = 2, d = 4,
a < d)

11 -4196
162 11.

, 0 4,
, 2/\/3-

,
, .

(. . 11.7).
9; :
= ( - sin^), = - r + rcosO. (11.13)
. 11.7 0 < < 2.
, = 0 (, ) ~ (, ) = (0,2).
, d .
(d, 0); ,
> 0 0 < # < 2 7
0, (11.14)
9, -
, , ,
. ,
MATLAB'a

. 11.7. , (0,2)
1.5
= 2. .
11. 163

, f solve. ( - -
MATLAB'a f solve,
- full_new.m gauss.ja.m
. 15.)
(vii) = 2, d = 4, (11.14) -
. -, , cycfun.m,
:
function q=cycfun(p)
=2; d=4;
r=p(l); theta=p(2);
q=zeros(2,1);
q( l)=r*sin(theta)-r*theta+d;
q(2)=r*cos(theta)-r+c;
(11.14) = 2, d 4
fsolvef'cycfun', [rO, thetaO] J )
thetaO 0. ,
' .
. {:
1.)
0 \ ( -
thetal). = 0
0 = 01, .. (0,2) (4,0).
- slide4.m (11.10) -
, 0.
0 9^. - -
slid.e4fn.mTeM , siidel.m
slidelfn.m.
? -
, ,
, , ,
.
( ), ?
(viii) , ( ) -
~ 0, ..
.
(d, 0) . -
, = 0,d 4? ,
0i , -
slide4.m. ,
'
164 11.

, -
,
.


,
= / + ,
(0, ), (d, 0). -
2,
d = 4 . -
slidel.m slide5.m, -
slide5fn.m, yl -
slidelfn.m.
?

( )
(11.9)


ds _ ds dx __ fidz
dt dx dt dt
( ' ~ dyjdx), (11.10)(i).
, -
MATLAB'a , -
-
,
(11.10) (i) 0.01 < < d, -
0 < < 0.01 -
. , ,
' = dy/dx 0 < < 0.01.
, (11.11).

(, ' ).
, ,
' = 0.01.
11. 165

( )

, . ,
(11.9) -

v = /2{ - - ) ,
, () . ,
, , -
,
/. v
( ,
!).
(11.10) (i) -

/
s l i d e 1 , slidelfn.mTaK, -
/j = 0.3. -
slide6.m slide6fn.m . , fi,
0.5, -
. ?
12


, -
.
. () -
, , ()
.
() -
, -
. ,
( 12.1-12.3) .

12.1.

+
-\-\ : , T2 = U , 1 , . S , O . . . . ,
+
a, b,c.d . XQ -
,
. -
. -.
mobius.m a, b,c,d, XQ , -
, .. , -
.
.
- mobiusl .m
Xi -, format long
.
(i) (a,b,c,d) = (1, 2,1,1), = 3. mobius .m mobiusl .m (
20 ) , . -
.
12.1. 167

0 . -
, -
, , , = 1.5. ( % = .)
, ,
, +\ /. -
-
. (
, -
.)
- mobius.m ,
, .
(ii) (a,b,c,d) (1,1, 2,1),; = 3. 500
mobius.m . 20
raobiusl.m ,
.
, .
() (,6,,d) (1,1, 1,1), = 3.
3, 2, ~, | ,
-. -
.
, .
-4 I, ;4-1 ~> ^ 0

_ l+ l 2
_

(,
). -
/,
. ,
-
,
.
!
,
, .
2- He , -
168 12.

, . -
, ,
, -
. , I = /2
, XQ = /2.

- mobius.m. ,
''; , ~\ = die.
+\, xn+i = /.

, MATLAB'e Inf.

'/, "~
7, .
7 - ,
7( (ax+b)/(cx+d) .
7, a,b,c,d .
7.
, .

a=input' ' ) ;
b=input' b ' ) ;
c=input' ' ) ;
d=input ' d ;

xO=input(' ' ) ;

n=input' ' ) ;

= [] ;

for j=l:n
if x(j)==Inf j x(j)==-Inf
x(j+l)=a/c;
else
x(j+l)=(a*x(j)+b)/(c*x(j)+d);
end
end;
bar(x)
12.2. 169

12.2.

. /{), -
, xi = /(XQ), 2 = /(a-'i)
.. = f(x), =
. (',0) -

(xo,xi),
= (xi,xi). : (x\,xi)
-
(2,),
= (2,;) ..
.
. 12.1 :
,
( -
). ,
, !

- . -
, f(x) (ax + b)/(cx + d).
a,b,c,d,xo -
. 30
, .
.
, -
/, ,
. -
:
1. (i) 3, -
3, # = 2 2.
, , , 1.3 < < 1.5
.
2. (ii) 10,
10, XQ ~ 2.
3. (iii) 5,
5, 3.
, .
, / = ,
170 12.

0.9

-
\
0.85
0.8 -
0.7

0.7

0.65

0.6

0.55
/
2' 2
0.5

0.45

0.4 \ '

0.4 0.45 0.S 0.55 0.6 0.65 0.7 0.75

. 12.1. : -
, .

, .. -
= f{x), f(x) = .
-
.
12.3. 171

12.3.

\ 7
d ~"~ cxn+d
, -
. -
.
1. (i) ( )
,
Xn+1
= a I
1 } \ 1
,
. ( \ ( 1 A Wi

= . +-\ .

lii) > 1 0
( ) ,


= . - -

1 2
= ( 1 1
) , = 3.
v ( 3 , 1 ) ,4v = (5, 4 ) , (i)

1 4, a xi = |. = 4 {ii); AAv
(75,53) = 1.4151; (5 53.
2

format long
A=[l 2; 1 1 ] ;
172 12.

v=[2 1 ] ' ;
w=A"20*v;

formatshorte
1.41421356237310, ,
s q r t ( 2 ) . () 1, 2,
= 2.
1 : (i)
+d.
(ii) . 1
(i) 0. (ii) ,

,
, /3 ,
(i) .
(ii) .
, . . XI, I
2 2-,
{ 0 \ __ . ( 0

{ 1 )- {
(ii) 1, .. -
XQ.
,
.
: , -
XQ,
_ Zxn + 5
+ 2
XQ = 2. , ,
7 , -
XQ + 2 . ,

/3.
2 2 6 5 8
( _ J- (( \\ (( "
V 1 / V 1 I \ 12649
12.3. 173

,
" (-6)* [-2 1 ] '
5
=(3
[l 2
(, , -22658
-22657.999!) , 0 = -22658/12649 =
1.7913. mobiusl.m, xi
( XQ -
), ,
. $ 3.
-
w Akv .
2,
[X D]=eig(A)
,
w, 2. ,
xl=X(:,l)
y=xl./w
,
w .
. ,
-
.4.
, 3 x 3 ,
,
.
=[1 2 3;-1 2 -3;1 -2 -3]
() v. -
(0.5433,0.2849,0.7897), -
, [X,D] = eig(A). -
, Anv .

-
, ,
,
n
A v .
-,
,
Anv. Av, A2v, .4 3 v,...,
174 12.

,
. matit2.m 2 2-
matit3.m 3 3-. -
v. , .
, ,
.
2. Anv ,
.
. A"v/||>l n v|| > w
w 0 ~> , ( 7 1 /||,4 ||) > Aw,

j 4w
\\An+lv\\ \\Anv\\
> w, -
.
Aw = aw, , w
. , , Anv
,
, ,
.

.

, -
. 12.1-12.3.

, , -
,
.
12.1-12.3 .
'
-, -
, -
.

(i) a, b,c,d, . 12.1, , -
- mobius.m / mobiusl.m , -
12.3. 175

12.1.
-

a d
2 1 1 -2
3 2 4 3
3 2 1 2
1 3 -2 1
1 -/3 1
-1 1

, -
,
( ). -
,
.
- cobm.m -
.
<Enter>. -
, , -
,
-
.
:
s q r t ( 3 ) MATLAB -
.
(ii) , , -
(, , , d)

d
MATLAB', -
, -
( ) -
, ..

XI- (

/ 2 2-.
. , (a,b,c,d) ~ (1,1,-1,1), -
176 12.

,
.

(Hi) .
/, , -
4 (. 12.3)?

(iv) (i) - matit2.m -


.4"v? -
v, , -
. ,
.
.

(v) (,,,d) = (1,2,1,1), -


(, inv(A)). -
() XQ, *> = .
XQ, X$Q ?

(vi) -
, 3 Z-.
12.3. : , -
. t 0 10 ,
, . t = 1,
:
(a) , -
;
(b) ;
(c) .
t = 2, 3 ..
(, , ).
-
t ,
? (
t = 0)? ?
: }'
12.3. 177



. -
, -.
(vii) f(x) = (ax + b)/(cx + d), ad 0.
/ ,
f(x) .. , ( d)2 + 46 > 0,
, , 0.
(viii) , +] f{xn), f(a) = a, f(0) = /?, ,

(^\ (
-
: , ~ ( 4- )(
( + d),
_ (ad )( )
x i -r-j
(cx n + aJ(cQ + a)
n +

+\ /3.
(12.1)
\, 2 , . . . ,
- a fc0 + d\n fxQ - a
- \ + dj \ - /9

(ix) , /'() - (/ + d)/{ca + d), a /'(/3) = { + d)j


( + d).
2
: , f'(x) = (ad be)/(ex + d) . -
2
, a 0 ex (a d)x h = 0,
, ( + d)(c0 + d) = ad be.
(x) , j f'{a) |< 1, > - .
(xi) , (a d)2 + Abe < 0,
. ,
{} ?

.

, -
( 2) . -
,

12-4196
178 12.

, -
.
, -
.
[2] 1 '.
, .


,
.
, -
.

MATLAB'a
-
, -
.

-
; -
. f(x) (1 ) xn+i = f{xn), n 0,1,2,... ,
XQ,XI,X2-,
, -
XQ.

/ , -
2
/, . . } {) = f{f{x)),f'(x) = f(f{f(x))) ..
p
= f (xo). . , ,
, ,

(I) I
:
, (12.2), q, -
, , | , / ( | ) , i = 1,... ,q 1
-. , XQ
(0,1) /, -
k
f {xo), k 1,2,3,... ,
q .
1
> : M.J. Feigenbaum. Universal behavior in
nonlinear systems. Los Alamos Science, 1980, v.l, JY* 1, pp. 4-27,
.
, 1983, . 141, . 2, . 343-374. . .
12.3. 179

(i) 2 , /2{) = 2.(1 - )(1 \ + 2), -


, (12.2) 3 - 42 +8 = 0.
v ( -
) r o o t s ( v ) , -
. .
2; , /(-) = ^.
cobq.m , . -
XQ, -
. ,
- .

(ii) - quadn.m / (
) ~
~ \- -
. . ,
, , <Enter>,
'.
0, , 1,
.
( | , | ) ,
, (12.2). ( , -
/ .)
/ 3 ,
3.83, (12.2).
,
-. , -
cobq.m, , XQ -
3-,
(i). , 3-. XQ,
, , -
,
.

(iii) = 6 (12.2) 3.63. -


, quadn.m, -
cobq.m, (
6-), .
16 , 3.55. -
16-? (,
-).

5 2"
180 12.

(iv) , (12.2) = 3

7 - 86 + 165 + 164 - 643 + 128 = 0.


v (
1 )
r o o t s (v). He -
.
2; , / ( | ) ^. -
cobq.m, ,
3-, , -
( , . (0,1)
).

(v) = 4 = 3.5.
, quadn .m,
cobq.m,
4-.
(vi) , = f(x) = , = 0
= 1 j . , 0 < < 1 f(x) -
= 0 < < 1. -
,
, XQ 0 < < 1
0.
1 < < 2 , 0 < < 1 f(x)
= , = 1 j .
= f(x) ,
. -
, -
0 < XQ < 1.
?
, -.
(vii) - perdoub.m ( period doubling -
!) 100 11
12. \,... , { XQ = | )
, 75-,
. ,
, , 11 < < 12 0 < < 1. . 12.2
1 < < 4.
0, 12 = 2.
(vi)?
12.3. 181'

. 12.2. , .
, ,
. , 3.5
.

= 2, 12 ~ 3.5. -
?
(viii) ( .) ~ 3.9 4
. ,
- . (
.)

.
;

II ,
, -
. -
: ( ) -
2
, , 2 , 2' ' . . ( -
[2].) ,

. - -
( . 12.1). ,
182 12.

12.2. -
.

-
. -
.
MATLAB'a
-. -
-. -
.
.


12.2.
- cobq.m -

, > ,
.. = f(x) = .(1 ). -
, , = 3.9221934. xl = 0, 1, yl = , = 1,
0.5. ( , xl ,
, a yl,
.) 20 . 7-
7-.

.
(i) - cobq.m , -
. 12.2. -
, { , -
(-
/ / ). 12.2
; .

; ,
-
, . ,
, -
. -
, -
, h,... Jk
12.3. 183

12.2. -

xl XU yi
2.5 0.5 0.5 0.7 0.5 0.7 20
3.2 0.5 0.4 0.9 0.4 0.9 20
3.4 0.5 0.4 0.9 0.4 0.9 40
3.5 0.5 0.3 0.9 0.3 0.9 20
3.8 0.5 0 1 0 1 50
3.83 0.5 0 1 0 1 20

-
. ( , , c i o = l\,
h,--- 1-[. -
, , l\,... ,h- -
-.) , , -
, ,

.
(ii) - cobq.m, -
, , -
, , ,
. ( - cobexp.m.) -
- cobq.m
~ . , -
. , -(*>
.. .
, - ,
. ~
, , ,
XQ 0, , , -
. ,
, .
cobexp.m,
:
fc = 0.05, z/ = -0.1, xu~l.l, i//=-0.1, yu = l.l;
0.5, xl -Q.1, = 1.1, ! = 0.1, = 1.1;
1.4, xl = 0, = 5, yl 0, ~ 5;
1.5, xl = 0 , ~ 10, yl = 0, 10.
184 12.

,
1.4 = 1.5, , = -
= . , , = 1^.
= 1/*. : ' = eln'3e''x
, 1/* 1{\ 1())/2.
, ? (-
, -
.) -
?


/ , ,
f(x) = . f(x) = ( + b)/(cx + d), 0.
/() = (1 ), > 0.
( )?
.
, | /'() |< 1;
, | f'(a) \> 1;
, ] / ' ( ) |= 1.
, -
,
, . . > > . , -
, Xi
.
.
, (vii),
, 0 < XQ < 1.
(iii) /() = (1 ) (
, !), > 0,
, = 1
3. -, ,
.
(iv) , /() = ( 2)/(4: + 3)
. -,
.
, /() = ( + )/( -4- d)
, a + d~Q nad bc= 1.
(v) f(x) =
12.3. 185

(vi)
(f(x) = (ax+b)/(cx+d)) (/() =
(1 )) -
-, -
. ( -
, , , -
.)

(vii)
f(x) = f(x) = 2 + . ( , ,
XQ 0 < XQ < 1.)
13
-


-
, -
.
. -
, -
( !).
-
. 15. -
, ., , [14].


,
. , -
. -
, .

MATLAB'a
MATLAB'a
. -
1 '.
-, ,
.

13.1.
, , -
f(x) = 0. ,

*J
+ {:, ) . . .
13.2. z2 + 1 = 0 187

XQ -
\, %, , . . . .

+1 = ~ ^ \ , : = 0,1,2,... . (13.1)


1 ).

13.2. z2 + 1 =
, . ( -
, z.)
- (13.1)

Zk _ fL+i = fLnl.
+ 1 k
2zk 2zk
N(z) ^2~^> zk+\ = N(zi?)- -
z ( 0),
N(z),N2(z) = N(N(z)), N3 (z) = N(N2(z))
. .
,
, , ..
, N, -
. , ,
N(z), , -
4, (N(z))4.
. ,
. , Nk(z)
-> ( ).
(i) T(z) T(z) |^4 (, ,
, z2 + 1 = 0 ).
N(z) , T(N(z)) (()) 2 ; -
,
T{N2(z)) = (T{N(z)))2 = (T(z))\
? T(z)
k
T(N (z))'? (: 2. -
T(N3(z)).)
i
' .
. . .
188 13. -

() \T(z)\ 1 , z
? {, \z a\ -
z .) I, z,
. L? -
. ,
L fTfz)! > 1,
|()| < 1.
?

(iii) , |()[ < 1. ,


(T(z))r -* 0 -> ? (: \(T(z))r = \T(z)\r.)
, -> T(Nk(z)) -4 0.
, Nk(z) -> i?
|T(z)j > 1 ? (-
: ljT(z) U(z), [Lr(^)| < 1;
( U(N(z)) = (U(z))2), -
, U~i(0) = .)

(iv) :

R+ = {z:Nk(z) - fc -^ }; R^-{z:Nk(z) -t -i -* }.
, , L -
i . R+ +i, ,
, R- .
, z L (
TO k
+ R-)-, N (z) L
. ( , ,
X.)
1 '.

13.3.

(i) - cnrl.m (enr complex NewtonRaphson -


)
1
' .

k i
N(z),
/() = 0. fc- 2 ~ Zi L
1
{ 1
0, > 1 z, '*~ () = 0),
L . -
,
Z{(k) . . .
13.3. 189

, q
z2 + ,2 + 6 = 0, (13.2)
. ,
, q. b = pq. -
(13.1) - z

- z
(2)> 2 (), 3 ()....
, q (-
, ). -
, -
.
, <Enter>. -
.
- .

, , xl < < xu,yl < < ,
/, , yl ( ).
, , i;
.
-, , -
, 1 + 2 3 + 4 0 < < 5 , 0 < < 5 .
, 1 + 2,
3 + 4?
() - cnr2.m 500
,

z2+az + b = , q. q -
. , -
().
, , -
(), .
, (i), . -
q, ,
L, -
, , . (
z,
, .)
190 13. -

, L,

? (i)?

(iii) , -

p,q.
(13.3)

, , q
(13.2). L z ,
|(.)| = 1,.. \zp\ |{j|. ,
L q.
, T(N(z)) = (T(z))2, 13.2. , -
, T(Nk(z)) = T(z) - ( ?)
.
, L
z. |T(z)| < 1
|()| > 1. , 13.2, ,
\T(z)\ < 1, T(Nk(z)) -> 0 k -J- , , ,
Nk(z) -* . , \T(z)\ > 1, (, -
k
, U = 1/, 13.2), N (z) q. , L
.
k
, z L, N (z)
L?
, q? c n r l . cnr2.m
, -
. . (-
: T{z) = z p.)
(iv) q, , ,
z -
2
L1 + 1 = 0 , ,
, L \ (iv) 13.2 -
, z L, N(z):
2 3
N{z),N (z),N (z),... L.
, c n r l .m .m , -
= , g = ,
10 < < 10, 10 < < 10,
3
13.4. z = 0 191

, z L. -
100

plot(real(z),iraag(z),'wo')
z ( -
, -
L) xvalue. ,

xvalue= [] ;
z
xvalue= [xvalue, r e a l ( z ) ] ;

,
plot([0:100],xvalue) ^
. , -
, , -
, L1
.

13.4. 3 z 0
3 z = 0, -
= 1, = 0 = 1, ,

, . .
_1 = {z : Nk(z) - - 1 -> }
RQH R\. ,
.
(i) cnr2.m , -
:

^ plot(real(z)).
L . 13.2.
. .
192 13. -

. 13.1. -
1 z 0.

(,) , -
- z + -
. 1000
. - cnr4.m.

(ii) xl ~ 2, xu 2, / = 2 (
2 2).
.
xl = 0.6, = 0.4, yl =
0.1,
. (
.) -
.
,

, -
,
( ). 13.1 -
, 4., ,
13.4. 2 3 - = 0 193

,
.
= 1 xl = 0.6,
= 0.4, yl = 0.1.
-
. -
:
,
.
, -
!
14

. ()
, -
. () , -
, -
.

.

MATLAB, * -
, . -
[5]
, -
.
() : ., -
, [11].

-
, , -
.
{) -
. ,
,
, . :
:
7271 TTI, 72.
MATLAB'
- -
1,2,... , , -
. ,
14. 195


.
-
.

1,2.... , -
. , = 8
1 2 3 4 5 6 7 8 \
7 3 8 6 5 4 1 2 ^ 1 ^ >

1 7, 2 3, 8 .. -
, .
-
. (17)(238)(46)(5),
, 7 , 5 ; -
4 6, 6 4; 2 3, 3
8, 8 2 1 7, 7 1.
(46) 2- , (238) -
3- . . 1- () -
, . (
) -
. (14.1) 4. (
, -
, ,

. ,
7 (5)(382)(71)(46),)
S(n)
1,2.... , . ! , -
1, 1 2 . .,

( 1){ 2 ) . . . 1 = \

(i) MATLAB'e randperm(n), -


1,2,... , , . . S(n).
randperm(lO),
1,2,... ,10. -. -
s o r t , randperm.m.
( s o r t , help sort.)

13-
196 14.

-, 1000 -
,
1000 .
:
n=input' ')
-
.
p=randperm(n);

for j = 1:1000
.

bigpCj,:)=p;
j- .
,
{ ')
>> clear bigp
-.
= 5
. ( ,
hist(v,I:5)
v ,
1, 2, 3, 4, 5.)
, ,
, 1, 2, 3, 4, 5 -
(, , randperm.m
).
(ii) - cycles.m
, -
. , , -
, ,
, . -
, 1
, -
. -
, , . , , ,
= 10,
.
14. 197

(iii) cycles, m . (-
) , . -
, , , clength, -
:
clength = []
,
:
clength = [clength newlength]
newlength* . -
, : / = 0(1, 2 , ,Xk)^

lk-i /. ,
,

(,&)= ff
(, )
...
gcdiv.m,
.
,
'
ord=clength(l);
for i=2:length(clength)
ord=(ord*clength(i))/gcdiv(ord,clength(i));
end
, , -
ord. -.
(iv) randperm.m , -
7 S(n)l\
, = 1,... , -
() 1,
0. = zeros Cn,n),

for i=l:n
A
end;
1
^ , randpenn
. . .
198 14.

(, , , -
, (14.1).)
- =
(1,2,... , ) , , -
, ? , '
u = [ l : n ] '. ,
1 ' A2u,A3u, -
()
, -
(. . > 1, = ).
: , -
-, ,
, .

(v) cycles., -
( 1-)
. ,
(
1000) -
.
, -
.

(vi) , -
,
(v). . -
.
!
S(n). , ^() ^-
S(n).

v ) + 2() + + {)
=
\

, = 3. -
5(3)
(1)(2)(3), (1)(23), (2)(31), (3)(12), (123), (132).
, (3) = 6, 2 (3) = 3, 3 (3) = 2, - -
.

' . . .
14. 199

S(n) , , 1-
(1)? 1
, ( 1)! . -
1- (2),... , (). ,
1- ( 1)! , -
1-. ( 1)! = \
1-,
S(n). Pi(n) = \.
2-. 2-, ,
(12), ( 2)! S(n), -
^"~ ' 2- (?). ,

, P${n) . (
3-,
(, , ) 1 . ,
3 , 3-,
(a, b,c) (b, , )~(, , ), 3.)
Pk{n)? -
1
(v).
(vii)
. , 1 < < . -
,
1,2,... ,, , .
, = 4, 2
1 2 3 4 \ / 1 2 3 4
2
2 1 4 , ) ' ^ " ^ ! 3 4 2
(12)(34) , 1,2, 3,4.
2 = (1)(234) .
cycles.m,
, , 1000 , -
{
). : , .
testnum.
count, -
, . -
, , ,

while i<n
200 14.

while Km
, ,
;

if p == zeros(sizeCp))
count=count+l;
end
, ?
, , = 8
, .
(viii) (vii) .
, ,
, ,
.
,
. 1,2,... ,.
, ?
, .

.

-
. -
( ) -
, , -
.
52 -
. , ,
( ) -
, . ,
, -
,
.
[6].


, -
, 1 . -
14.1. 201

(. . -
). :
= mod mt , , 0, ,
= , > 0, < 0
. , -
, , -
, .
( ,
!
.) -
.
: -
: 7271 ^, -
72

MATLAB'a
-, -
, .
MATLAB'a s o r t .

14.1.
14-1.1. ()
,
1, 2, 3, 4, 5, 6. , (-
) , 4, 1, 5, 2, 6, 3
. ()
1 2 3 4 5 6
2 4 6 1 3 5
1{) = (
) ,
, ,
( ).
-
. , ,
,
4, 5, 6 1, 2, 3 .
, .
, -
2, 6, 3 4, 1, 5, 2,
202 14.

4, 6, 1, 3, 5 . , ,
,
( 7 ):
1 2 3 4 5 6

: -
2, 4, 6 1, 3, 5 ,
1, 3, 5, 2, 4, 6. (
) , ,
1 2 3 4 5 6
1 4 2 5 3 6
,
1 2 3 4 5 6
4 5 6 1 2 3
( 1 4 ..).
, (14.2) "72.
,
, ,
2.

TTI, . . .
7 _1... TTI. , -
=
= .
,
.
1, 2,... , . ( 14.3)
.
, .
1,2,... ,52. -
,2,... , 10,J,Q,K
(, 2, . . . , 10, , , ) .

14-1-2. MATLAB'a sort


MATLAB'e -
() , -
s o r t . , -
1, 2, 3, 4, 5, 6. MATLAB'e
14.2. 203

= [2 6 4 1 5 3] ; '/. :
[v q]=sort (p) ;
q
, q (-
). ,
v , ,
s o r t 1 ) . , q -
, ,
.
, ,

.
, sort,
-.

14.2. 2^
, 1,2,... , ,
, . -

.
, , ,
.

14-2.1.
, .. = 2,
1, 2,... , + 1, 4- 2,... , 2. + 1 -
, ,
:
fc + l,l,fc + 2,2,fc + 3,3,... ,2k,k.
. 14.1 = 3.
, , ,
( , , = 6, = 10),

' ' B v = sort(p) v = [ 1 , 2 , . . . . ].


1,2,... , , q -
q(p) 1 : . ,
s o r t . *, .
2
> : ins and out-shuffle.
. . .
204 14.

4
5
6

. 14.1.
1, 2,3,... .


7() = 2 (mod 2fc + l),
, , , () 2 2 + I 1 ' .
() 2, 2 (2 + 1).
, , ,
,
, :
2
7 () = ((:)) = (2:) = 4 (mod 2k + 1). (14.3)
, , -
, 4 (mod
2k + 1). = 6.
-
=6, ?
'' mod n, , : =
= d, (i) = d (ii) = bd. , = , =
> 0.
14.2. 205

, -,
- r i f f l e i . m -
. -:
. , , s o r t ,
,
. ,
14 , -
.
- r i f f l e l a . m . -
2 mod 2&+1, .. -
2 + 1. = 7; -

14 , .
. -
, (14.3), ,
,
,
7() = (mod2fc + l).
, 2 ~ 1,
! ,
, , , 1-
1- , 2 = 1. ,
,
, , 2 = 1 (mod 2k + 1).
-
, . (, -
, , -
( ) .)
r i f f lela.m,
40 52 .

.
.

14-2.2.
= 2k , 1 ,
:

l,fc + l,2,&-f-2,3,fc + 3 , . . . , k,2k


206 14.

. 14.1 = 3. , , ,
6, = 10, ,
7() = 2 : - 1 (mod 2 - 1) 1 < < 2 ~ 1,
(2) = 2. :
2 1, 0. ,
{) 2 1 2 1, ,
0, 0 2 1.
, -
remm.m. , rem,
0. ,
remm(19,ll) 8,

retnm(22,ll) (11,11)
11.
, remm.m, riff l e i .m,
. -
'-, 2fc 1, -
store (2*k)=2*k; i-,
position_perm=store.
- riffle2.m , , 52
-
.
52 ,
rifflela.m?
, , -
, ,
2 , ,

2 1 (mod 2fc-l).
. , , -
2fc,
, = 2
. , -
, -
72,
2
{) = 2(2 - l ) - l = 4 i - 3 (mod 2k - 1).
, ,
{) = 2 - (2 - 1) (mod 2k - 1).
14.2. 207

, 2 = 1, -
, () ~ . ,
, -
, 2- , 2 + 1 2 + 1 ~ 2,
.. 2 = 1. , ,
, -
, 2 = 1 (mod 2k 1).
r i f f I e 2 a . m (
r i f f lela.m), , -
, -
= 2 40 52 .

14-2.3.
, 2 + 1, -
, + 1 .
, ,
-f 1 , -
( + 1 ).
: 1,... ,
( ), +2,... , 2+1 (-
). . 14.1 ~ 2. ,

7() = 2 (mod 2 + 1) () = 2 - 1 (mod 2k + 1). (14.4)
r i f f l e i .m (
- r i f f l e 3 . m r i f f l e 4 . m ) -
, 15 -
. , em.
remm.m, .
, , -
, ,
, ,
r
2 = l (mod 2k + 1). r i f f l e l a . m , -
= 2 + 1
39 51 .

14-2.4-

, -
, .
208 14,

, - -
-, , , .
, . . -
, ,
. , 1, 2, 3,
4, 5 3 ,
4, 5, 1, 2, 3. ,
, . ,
, ,

+ 1, + 2 , . . . , 1,, 1,2,... , - 1, - .
, {) = (mod n).
, 2k + 1. -
(14.4)
, (:) = 2 2 1 (mod n).
,

7 =

-
,
((;)) = 2((:)) (modn) .
, 2: 2 mod . ,
, , -
,
, ,
. , , -
.
,

77_1 . . . 7 1 ,

- , ; ( -
) .
, -
, 2 + 1 , ,
, (14.2.3).
, ( )
. ,
,
14.4. ( ) 209

. , -
, ?
, .
,
( ) , .
( 14.5.) ,
-
:
-
. ,
-. , -
-
\ = 2k ,
-
.

14.3.
, , -
, .
-,
: rifflelc.m. -
. r i f f l e l c - ,
, -
,
40 52 14.2.1.
. , 52 -
:
. ?

14.4. ( )
1^.^.1.
,
. , -
,
-
(. . 14.2). ,
, n = 2fc,

14-4196
210 14.

. 14.2. 22 () -
( ) ().

2 , , < < + 3
( ).
( ,
1,2,... , ) -
. 2 ~ + 1
, m ,
+ 1 m + l , m + 2 , . . . , 2. -
, 0, 1, 2 3
.

0, 1, 2 3
. pi , i = 1, 2, 3,4.
, , ,

PO+Pl + 2 + = 1-

, , \ + 22 + ,
2 + 1 , -
(2 - + l)(pi + 2 + )- ,

14.4. ( ) 211

, . ,
(2 - m + l)(pi + 2p2 + Zp3) = .
, 2 { .), \

Tfl

Pl
- 22 -, = 1 - P i - 2 - - (14.5)
2 + 1
, >2 , \ -
< 1. (14.5) 1 (
), ,
-2 22 + < 1
pi .
2 ? -
pi = 2 = 52 (
) ?
- ruff l e i ., -
. -
, -
, , , 1,2,... , -
, . -
% - .
- ruff l e i . m , -
26
( ). , -
,
() () -
.
- r u f f l e l c . m ,
, 14.3. -
, .
,
.
, -
52 .

14-4-2-
u

- ruffle2.m , -
.
. ,
2, 3 4

14*
212 14.

.
, - ( -
i- ) j-e , i j
. (: -
, i = 1:
- .) , -
. , ,
; , ,
.
-
. -
(
2 $ ), ,
,
. 1 :
.
(
-1 ). , -
-
.
!

2 = 0.2, 3 = 0.05 . 28
( [ i , j] [1 10]), ,
,
!

ans =

22 39 29 35 45 10 28 17
2 23 40 30 36 46 11 -1 18
3 24 41 31 37 47 12 -1 19
4 25 42 32 38 48 13 -1 20
5 26 43 33 -1 49 14 -1 21
6 27 44 34 -1 50 15 -1 -1
7 -1 -1 -1 -1 51 16 -1 -1
8 -1 -1 -1 -1 52 -1 -1 -1
9 -1 -1 -1 -1 -1 -1 -1 -1
14.5. 213

14.5.
14.2.4. -
;
. , -
. 14.2.4, -
, .
, , , -
2 = 1 mod n,
, , -
, . . . -
:
, , -
, 2 ~ 1 mod .
, (:) = 2 2 1. 7T27ri(x)
4- : 4,2(2 1),2(2#) 1 2(2 1) 1, . .
4,4 1,4 2 3. ,
7 ~ 771>-1 . . .7Ti(x) = 2 + 1,

I 0,1,2,... , 2 1. =
= mod .
, 2 = 1. () = + I -
I, , . . .
, 7 .
, , air -
, .
2 + I = + V

I, V. V I = , 2 = + .
+1
= 1 2 = 1 + , 2 2 = 2 + .

2 = 1.
15

-
.
, . -

, -
( ) -
. ,
(.. ) -
, -
.
; -
. 13.


,
. ,

.


. -
, -
.
(
ID),
(, 2D).

MATLAB'a
. -
- fulljiew.m g a u s s j a . m -
,
-. -
15.1. JO; 1 215

- f_rate.m - -
cont4.m.
,
, -
.

15.1. ID: 1

F(x) = 0.
1 ' :

F1 F(x).
= ') , , -

, . . ^ > * > .
- full_new.m, -
.
.
1

F(x) = 3 - 2 + 27z - 18 = 0 (15.1)
, ^ 7.4 (: -
* = 6). F'(x) =
2 - 20 + 27, f_exln.m,
2 ':
function [F,J] = fun_name ( ) ; , 1
= (1) ; ,
, -
F = [~3-10*"2+27*-18]; %
J = [3*~2 - 20* + 27 ] ; '/,
, ()
1
) -
F() *.
. .
2
*> MATLAB'a V3.5 , =
(1) - f-exln.m =
f_exlg.m.
216 15.

Root - full.newOf.exln', 7.4) .


Root = full_new( J f_exln J , 7.4, tni) ,
Root = full_new(If_exln>, 7.4, t n i , t o l ) X
Root = full_new('f_exln', 7.4, t n i , t o l , hi)'/, D

tni (, 12) -
^ = 7.4, tol
: |-F(a:)| < tol (, 1.04) hi
, -
(hi = 1 , hi = 0 ). -
-
(. . hi = 0); tni tol , -
20 1.03 .

15.2. ID: 2
-
F(x) = 0 = G(x),

- gauss.ja.m .
full_new.m, -
- -.
, 1, ,
( f u l l . )

Root = gauss_ja('f_exlg', 7.4) .


>> Root = gauss_ja('f_exlg', 7.4, t n i , t o l , hi) X D

-- f .exlg.m
function G = fun_name( P ); , 1
x = PCD; '/ -
R = 18 - x~3 + 10*x"2;
G = R / 27; '/, :
. R - 10**2-27*+18; ,
X G = sign(R)*abs(R)~(l/3) ; . SIGN,
,
X
15.3. ID; 217

[ ]*'. ,
G .
. G(x) .
,
G(x) = F(x)/F'(x). 1
F(x) ~ 3 - 2 + Tlx - 1 8 = 0
= G{x) G(x) = (18 + 2 3 )/27;
, G(x) = (2 - 27 + 18)
.

15.3. ID:
1, 2 .
, : (1) ,
; (2) -
,
. -

(1).
.

15.3.1.
, -
. R (,+),
. -
,
, ; , [1,10] -
,
.
, . .
F(x) = 0 F(x)
[, 6], MATLAB'a p l o t .

2

F(x) = (2 - sin z)(rc3 - 2 + 27 - 18) = 0- (15.2)

G(P) . . .
218 15.

15 :

! ! / -

10 :


-5 - \ ; : ' /

-10 - / -

-15 - - :

\ ! /

-
V / . . . .

. 15.1. .


= 0.5 : 0.01 : 6.5;
F = (2-sinCx)) .* (.~3 - 10*."2 + 27* - 18) ;
>> plot(x,F, ,zeros(size(x)) ) ; grid
, . 15.1.
, -
[0,7], [0,7]
= ^.

15.3.2.
-
, -
. ,
. ,
-
, -
. ,
.
, [0,8] 1
^0' = 0, 1/8, 2/8, ... , 8
1/8, 8; = 1/8 = 0.125. -
15.3. ID: 219

0 1 2 3 4 5 6 7

. 15.2. .

6
- -

4 -

3 -

2 -

1 -

- 1 L

1 2 3 4 5 6 7

[0 1.875] 1 [2.215 4.25] 3 [ 4 . 8 7 5 ] 6

. 15.3. 2: = 1, 3, 6.

' = 0 : 0.125 : 8. ,
- ,
. 15.2:

t n i = 30 ; X = [] ; R = [] ;
1
forxO = 0 : 1/8 : 8 '/.. f.exln.m 1 /.'/.
root = full_new('f_exln', xO, t n i ) ;
220 15.

if 0 <= root <= 8, X = [X; ]; R - [R; r o o t ] ; end


0
_ j !////1//1/|//'/ V / V / V'/'/ / V /'/'/*/'/'/'/
} J
Convergence_region = [X R], pT.ot(X, R, o )
a x i s ( [ 0 8 0 7])
He ,
, . . 15.2
. 15.3, -

= [0 0 1.875 1.875]; =[0 1 1 0 ] ;
plot (, ); hold on '/,'/, plot (,, '') ; 7, .
p l o t ( [ 2 . 2 1 5 2.215 4.25 4 . 2 5 ] , [0 3 3 0 ] ) ;
p l o t ( [ 4 . 8 7 5 4.875 8 8 ] , [ 0 6 6 0 ] ) ;
axis [-1 9 -1 8 ] ) ; hold off

15.3.3.

( , , ).
. -
. -
^\^1\ . . . , ^\...
\ | ' ' , . .
= \{)-\

( ), , -
, -
. F(x) = 0, -
1^, | | ().
,
. ,

*' -
. +1.
\^ ^ ^\
() ^^ . .
15.4. 2D: 221


, -
.

-: i_rate.m
-
, - i_rate.m, -
.
-
, - f . r a t e . m
. :
>> k = f_rate (root, hi)
root ,
full_new.m gauss_ga.m, hi = 1
( hi = 0
).
1 f -jrate.m :
root = full_new('f_exln', 7.4, 20, 0.0001, 1) ;
>> k = f_rate(root, 1)
>> mean(k)
mean . -
root 1 '
root = [ 3.46 3.5 3.61 3.735 3.755]'
= f_rate(root, 1)
= 3.8743 3.5091 VL
= mean(K)
= 3.6917 .'/.

15.4. 2D:
-
.
full_new.m gauss_ja.m cont4.m f jrate.m.
*'
fc = 2. ; = 1 -
, \\ < 1; < 1
, .
, Ix'*1"1"1^ \ | ' " + 1 ' ^\
l^fn) _ x^n~1^\. -
. . .
222 15.

m ( -
) F(x) = 0,
F = ( F ! , F 2 , . . . ,Fm)T = ( 2 , . . . ,).
F, . . -
= |^-, 3.
, -
.
F(x) cm 2, .. R 2 , -
F(x) :
17/(0) (0 , , (0)^1 , / (0)\^-^1 , . .
=Fl{x\ \x\t) + {x1 -x\ >)^ + (a:2 -xy)- + hot,
OXi %
0) 0) 0)
= ( ) + (*i - 4 ) | J + (x. - 4 ) g + hot,
..
F(*V) = F(x<>) + J [^> - x<0'] + hot,
hot higher order terms
3 <):
J =

-.

15.4-1. 2D: 1
, .. R m ,
F(x) ^ .
*0'
*, ,
F(x) 1 ',
,

0
3 = ^ '. ,

x
(n+i) =
() _ j - i ( x ( n ) ) F ( x ( " ) ) j = 0,1, 2,... ,

J ~ ^ \
F ( x ( n + 1 ) ) . . .
15.4. 2D: 223

ID, ,

> . J,
F'(x^) ; , J~ 1 (x' n ')
1/F'(x^n').
-
: F(x) = (Fi, F 2 ) T = 0 = (, ).
3

F i ( a r , y ) = s i n x - y 3 - 8 = 0, ( 1 5 3 )


cosx
J - (J-.) = I ~^ "V I = [ ~3*
, , '0^ =
(4.7, -1.9) , ,
= (5.075, 2.075)1".
X * n + I ' = x ' n ' Sn\
d( n ) J(x* n ')cr n ' = F ( x ^ n ' ) .
, -
J
(. . 16). , (-
15.1). , '
(\{) 0 0 ~ j \ .
-.

-: full_new.m
3, ---
f .

function. [ F, J ] = anyname ( P ); '/, 3 - -


x = PCD; = (2); V,
F = [ sin(x)-y"3-8; 7. _1
x+y-3 ] ; / _2
J = [ c o s ( x ) , -3*y"2; , 2 x 2
1, 1]; .
224 15.

(: --
.) -

Root=full_new('f_ex2n\ [4.7 -1.9]') ,
Root=full_new('f_ex2n', [4.7 -1.9]', tni) 7.
Root=full_new( J f_ex2n\ [4.7 -1.9]', tni.tol) 7.
Root=full_new()f_ex2n) , [4.7 - 1 . 9 ] ' , t n i . t o l , hi) '/, D
tni (, 12) -
(> = [4.7 1.9], tol -
: for |Fj < tol (,
1.04) hi , -
(hi 1 , hi = 0 ).
, ID.

15-4-2. 2D: 2 -
-
F(x) 0 = G(x)
( + 1 ) = G(x<n>) = 0,1,2,... .
,
, . ID,

,
G ( x ) = x - J-^xJFCx).
3 F(x) = 0
= G(x)

(15.3) , -
.

- : gauss_ja.m
- gauss-ja.m, ,
, full-new.m,
15.5. 2D: 225

1.5 =

0.5 -

-0.5 -

-1.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

. 15.4. Fi(x,y) .

--. , -
J. , 3,
( fulljnew.m)
) )
Root = gauss_ja( f_ex2g , [4.7 -1.9]') 7.
Root = gauss_ja('f_ex2g\ [4.7 -1.9] ' , t n i , t o l , h i ) 7, D
-- f_ex2g.m
function G = fun_name ( ); 7. 3 - (2 )
= (1); = (2); , -
G = [ 3-; , G 2
-(8-sin(x))~(l/3) ]; 7.

15.5. 2D:

F, F(x) =
F.
,
; - cont4. m.

15-4196
226 15.

-
, -
, , 1' meshgrid. -
, F\ (} ) =
{6 - 3 ~ 0.5)(- 2 - 2) Q = [-2, 2] [-2, 2].
(. . 15.4)
= -2 : 0.4 : 2;
= -2 : 0.25 : 2; % ID
[ = meshgrid (, ) ; '/,
Fl=(x. "6-. "3-0.5) .* (-."2-."2); 7, F1
M=max(Fl) ; m=min(Fl); */, -
V=[m 0 ] ; 7, . F1
Cl = contour(x,y,Fl, V, '-'); 7.
clabel(Cl); 7, .
grid 7. .
V
M=max(max(Fl)) m=min(min(Fl)), m
V 3. V
2' F1.
, -
F2(x, ) = 20*(2 2)-5 = , -
Fi(x, ) ( ),
. ( -
) - cont4.m; . 15.5,
.
, ( )
Fi(x,y) = 0 F2(x,y) = 0,
,
( ). ,
, ,
.
( cont4.m :
Root - [ 0.5 -1.5; 0.25 -1.7; 0.55 -0.25;
-0.45-0.1; 0.1 0.55; -1.0 0.83;
=-2:0.4:2; 0=-2:0.25:2; R=Root;
[ ] = meshgrid (, ) ;
:
2
' MATLAB'a V3.5 meshdom.
> V ,
, . . .
15.5. 2D: 227

1.5 -

0.5 -

-0.5 -

-2 -1.5 0.5 1.5

. 15.5. Fi(x,y)
F2(x,y) ( * - Pi -; - F2 = 0).

1.5 -

-0.5 -

-1.5 -

. 15.6. F\ (x, ) = 0
.

15"
228 15.

Fl=(x."6-."3-0.5) .* (-."2-."2) ; % F1
>> V=[-eps 0 eps] ; /,
Cl = contourCx.y.Fl.V, '-'); 7.
>> clabel(Cl); grid ; hold on;
;
plot(R(:fl),R(:.2),'-g , R(:,1),R(:,2),'ow');
hold off
. 15.6, Root -
:
Root = 0.5 -1.5 7, "(0) -
0.25 -1.7
0.55 -0.25
-0.45 -0.1
0-1 0.55
-1.0 0.80 '/, -
X
(, Root -
fulljiew.m gauss.ja.m.)

15,5.1.

. ID, -
. ^ 0 ', ^ 1 ', . . . , ^\ ...
j|x* n + 1 ^ xjj | j x ^ *. ..

( ), , -
, -
. F(x) = 0, || ||
(, 2- L2; -
help norm . 16 -
).
,
. ID,
, -.

- : f_rate.m
,
- f jrate.m,
229

. root , -
full_new.m gauss_ga.m,
>> k = f_rate (root, hi)
hi 1 (
hi = 0 ).
3 f jrate.m :
Root=full_new( > f_ex2n 3 ,[4.7 - 1 . 9 ] ' , 30,1.0-4, 1) /. D
= f.rateCRoot, 1)
mean()
mean .
root = [ 3.46 2.5;
3.5 2.59;
3.61 2.65;
3.735 2.69;
3.755 2.695]
f jrate.m :
>> = f . r a t e C r o o t , 0) ,'/,
Kl = f _ r a t e ( r o o t , 1)
( = 2.8728)
= 2.8728 3.3453
1 = 2.4003 3.3453

15.1 full_new.m ^ ~ 1.5,




F{x) = + ~ + 2 cos x - 6.
15.2 gauss.ja.m . 15.1, -
G(x), -
[1, 2]; ,
= 1(6 ~ 2cosx).
15.3 , , \^ ~~ \ = \^ \, \^ \ =
\^ \ ,

( ) ~ I n , ,., I I n . ,. ;
230 15.

() =\^-\/\^-\.
15.4
, -
.
, -
( ), t :
H{t) = 12.25 [* + 1.25(-0"8* - 1)] .
, -
6.125 , H(t) ~ 6.125, . .
F(t) = 1.25e"-8t + t - 1.75 = 0.
- gauss _ja.m -
:
(a) , Go {t) = tF(t)/F'(t)
( 15.2);
(b) - Gi[t) = 1.75 - 1.25--8*;
F(<)
(c) G2(t) =tj
V J Z W
' 0-(O.8t+O.6)exp(-O.8t)
^' = 0.5.
(i) -
;
() , (i);
(iii) .
: [5,5]
axis ( [-5 5 -4 4]) plot.
15.5 F(x) = 0.6 - (3 + lnx)x + :
(a) xi, X2, # ^4 -
(1,1.3), (1.4,1.5), (1.5,1.6) (1.7,2) -
F(x) \, 2, ,
F(x) [1,2] -
.
F(x) , -
0 [1, 2].
: -
.
5
(b) (tol = 10~ )

G(x) = 0.6 (2 + In x)x + ,
/?, ;
G(x) /3, -
- .
231

15.6 , -
, = () = H{xi,x2)
( = 2),
() - (<>) + (<4 - <>) + hot,
= grad = (^, ^)- -
,

:
( = 3) ?
15.7 F(x) = 0,

= \\ cos(rci -f x<i) = 0.

(a) full_new.m '* (2,1) ,


.
(b) gauss-ja.m ^ = (0.5,0) ,
40 G = X LJJ\F.
= 0.5 = 1.5.
: = 1, -
.
G(x)?

15.8 , , | | ^ | | / | | ^ x|j ft = ||^2'/^1'


x|j fc = , ,
-2) _ / (1) _
HxW-xl
2 1
/.\ _ 1|v( ) _ vll / I I Y ' ) YII^

\V>) Ly | | A ./ A|| .
15.9 15.7:
(a) 0.2
R = { : - 2 < < 1.6, 0 < 2 < 2},
F\ F%,
R;
(b) , (0.5,0.0) ,
-
-
. , -
(2,1) .
232 15.

15.10 F(x) = 0

{ Fi () = 12! - Zxl - 4z 3 - 7.17 = 0,


i=Mx) = \ + 2 - - 11.54 = 0,
F 3 ( x ) = \ + 7 3 -7.631 = 0.

(a) F -
') = (0, 0, 0 ) , -
.
(b) , 3
-
\ 2 -
. -
(c) . 0.1
R = { : ~5 < < 25, - 1 5 < 2 < 5},
Fi i-2,
(), -
. -
-
.
-
.
(d) . -
, -
MATLAB'a fsolve, -
1 ' .
full-new.m .

1
' MATLAB'a { 4.0) -
.
16


, -
, -
.

(-
) , -
. -
- , -
, -
,
. , -
, ,
.
.

, = b -
\.
( )
, -
. .
,
.
MATLAB'a
- lin_solv.m, chop.m, Iu2.m, Iu3.m, Iu4.m, solv6.m
spar.ex.m . -
- . chop .m, -
, Iu2.m, Iu3.m
Iu4.m.
MATLAB'a , .
234 16.

16.1.
, -
(flops)
. .

. , , -
, -
. ,
16.2 16.3, -
. , 16.5, -
,
.
, -
z = , . , n-,
. D = ABC
z = ; 4 3
(flops). ,
, zi = Cb, z? = Bz\, z =
Az2'. &2 ().
, -
. -

,
MATLAB'a flops. ,
:

flops (0); =2000; 7,


7,
>> A=rand(n) ; B=rand(n); '/.
>> C=rand(n) ;b=rand(n, 1) ;'/,
z=C*b; z=B*z; z=A*z; ,
w=flops, ratio=w/n~2 %
w ~ 24000000 ratio = 6.
, rand f l o p s 1 ' .
1
'
,
MATLAB'a. flops
-
. ( )
- -
. . .
16.2. 235

16.1.

flops tic/toe cputime etime


flops(0) tic >> tO=cputime; tO=clock;
>> '' >> '* '' >> ''
>> t=flops >> t=toc t=cputime; >> t=clock;
t=t-tO t=etime(t,tO)
E t =81 t = 6.09 t = 5.27 t = 3.13

flops, -
, MATLAB'y -
; . 16.1,
,

rand(9)*5, .. r a n d ( 9 ) * 5 1 ' . -
, etime clock
; help etime, -
.

. , , -
-
,
. (
), ; 16.2.3.
, "1 = adj(A)/det(.4) ,
- -
. adj(A) -
.
, , ()
-
.

16.2.
MATLAB'
format compact .
11

: -
0.02 , 0.2-0.3
. . .
236 16.

16.2.1. = MATLAB'e

= \ ,
= inv(A) * b,
.
, . -
8 x 8 , A=rand(8),
- b 8, b=rand(8,1).

flops (0) ; /, .
= \ , 8 8 b 8 x 1 .
>> fI = flops '/,
>> flops (0) ; '/
'/,
>> = inv(A)*b
>> f2 = flops ,

flops -
MATLAB'a, . 16.1.
MATLAB'e -
= b , -
:

(1) L, -
U , ,
LU'. / -
. , -
=
, ,
. -
, = , , 1 =
= .
-
.
(2) = (
).
(3) Ux = (
).

, ( LU--
), -
16.2. 237

1 ', .
. 2 ' -
= \
[L,U,P] = l u ( ) ; % L, U (A1=PA=LU)
>> = * ; '/, = b 1 =
*/, LU =
= L \ ; , L = L (U ) =
>> = U \ , U = ---

16.2.2. L U
, = b = ( ,
,
). \
, MATLAB LU-
.
3 ':

LL,U,P] = In(A); , L.U.P (PA=LU)


= P*b * , = ( 1)
z = L \ '/. =
x =U \ z % =
E = P*e ; , = ( 2)
z = L \ E , =
x =U \ z % =

16.2.3.
MATLAB'e -
-
, . -
.
, . , , -
, -
1
' MATLAB'a rref , -
. rrefmovie. , -
rref.m rrefmovie.. A=round(rand(6)*7);
J]=rrei(A), rrefmovie(A).
2
) , = L\B , \
, MATLAB ,
L. = U\y. flops.
3
' X = \, =
. . .
238 16.

, = inv(A) * b,
, .
MATLAB'e 16
.
-
,
i- 1 < t < 16.
- chop.m 1 ' . -
h e l p chop, c h o p ( 0 . 1 3 6 4 , 2) * 10 c h o p ( l . 2 2 3 3 4 5 ,
6) c h o p ( l .223345, 5 ) , , .

16.2.4. -: l i n _ s o l v . m , Iu2.m Iu3.m



= .
- l i n _ s o l v . m :
>> = l i n _ s o l v ( ' l u . n a m e ' , A, b , t) ;
lu_name -- (-
), Iu2, Iu3 Iu4. t -
,
.
-- Iu2.m
( ) lu.m , -
(- . ,
t = 16 Iu2.m, l i n _ s o l v . m
, \.
-- Iu3.m -
,
, -
, -
. - 4. m , I u 3 . m,

(); . 16.5.
- I u 2 . m I u 3 . m
( lu)
[ , , ] = 1 2 ^ ) ; '/. A (t )
[L,U] = l u 3 ( A , t ) ; '/. A (t )
,
- l i n _ s o l v ( ' I u 2 ' , A, b, t) ;
1
) 5.0 chop . . .
16.3. 239

, -
.
,
= l i n _ s o l v ( ' I u 3 ' , A, b, t) ;
-
.

16.3.
~ ,
= b Ay, ( -
). = , xi = +
.
, xi ,
. -
1', :
0.
t < 16, = ,
L, U, . . (-
. = I,
.)
1. b Ay. = 0
2 ' ,
= .
2. L, U, ,
LUe = .
3. : + - .
4- 1 . .
.
MATLAB'a norm.

> , , -
,
(, , , ).
( -
) .
2
) MATLAB'e, TV1, - ||r|| p = norm(r,p),
, 'inf' (.. -). -
MATLAB'a norm ,
, ||.4|| = (, ), 1, 2, 'inf' 'fro', -
1-, 2-, - F- () .
norm(A) 2-.
240 16.

16.4. = b
, = \
, . -
,
cond(A) = "1!! !|A|j, \\ || -
. 2- MATLAB
1' cond, cond(A).
t -
, 2' ( )
t .
t < 16. = b
, -
. -
-
()
( + ) = + .
( + ) i- -
b + . ()
() . ,
t- ,
\\AA\\ = norm(A - Al) |||| = norm(b - ) ,
\ = chop(A,) = chop(b,t).
,
. -
, |(||/!||| |(||/{|||
|| ||/||||. -
. , ,
. .

16.1 , b, a

( + ) = b + .

^ cond(A) , -
, " 1 , .
1- condest(A).
2
' , , -
, -
t. -
.
16.4. = b 241

|- < 1
V
V P I I I N ; '

c = !()

, , = -
, , ,
.
, > 50.
. 11- b t-
t 2; rand . . 6.
.
solv6.m:
randC'seed',1998); n=ll; , 'seed'
= 10*rand(n,n) ;
= rand(n,l); '/,
t = 2 ; .
= \ ; . ''
= lin_solv( 'Iu3', A, b, t) ; ,
A_rel=norm(A-chop(A,t))/norm(A) ;*/, ,
b_rel=norm(b-chop(b,t))/norm(b) ;, , b
k = cond(A) ; '/,
= / ( 1 - * A_rel ) ;
if >= 50, disp' . . . ' ) ,
else, disp' .'), end
error theory = C*(A_rel+b_rel) ,
7,
error_found = norm(x-y)/norm(x)'/,
'/.
, 97.561, ;
error.theory = 0.7618 , (-
), error_found=0.3381 ( -
).

16-4196
242 16.

16.5. ,

, , -
: -
, (, 50%) .
,
,
.
-
, -
(, ,
, -
).

MATLAB'a spy. , -
( - spar_ex.m)

= diag(0:9); % 10
spy(A); grid . ,
>> = eye(10,l)*ones(l, 10)*2; , 1
>> b = ones(10, l)*eye(l, 10)*3; 7. 1
>>=++; '/,
7. >>
>> spy(A); grid % ,
'/,
, -

1 = ; , ,
flops (0) 7,
7. ( tic/toe)
>> [LI Ul]=lu3(Al); 7.
>> Work_l = flops '/,
>> al = symrcm(Al) 7,
7, 1
2 = Al(al,al) 7. 2=*1*>
flops (0) 7.
, tic/toe)
>> [L2 U2]=lu4(A2) ; ,
Work_2 = flops , )
16.5. , 243

, Work.l = 8434 Work_2 = 1506.


, ( )
1; -
,
>> = (10); '/, 10 10
= (1,:) '/,
A3 = *1*' '/. A3 = 2
, 1 ' , , 2
A3 . ,
A3.
, , -
. ,
, -
( -
) (.. , -
1, 2, . . . , ).
Gen (
) ,
.
,
G(A), -
( ) ( ),
. ,
-
G(A). , ()
. ,
G(A) ,
. . % j ,
Aij 0.
, -
, (),
,
. . 1 2,
1 & - 1,
1. , G(A),
j = ~ 1 j = + 1,

*' , /. :
' speye eye, -
: help sparse, -
.

16*
244 16.

Akj 0 \ j\ < 1.
, .
10 10 -
10
1 : 10, .42 al
[10 9 8 4 6 5 2 7 1 3].
G(A) -
MATLAB'a gplot. -

(- spar-ex.m)
>> = [ 0 0
1.5 1.3
0.35 2.0
-1.0 1.7
-1.9 0.68
-1.9 -0.68
-1.0 -1.7
0.35 -2.0
1.5 -1.3
2.0 0.0 ], figure(2)
gplot (A,xy); hold on '/.
gplot (, ,'') '/, ''
for k=l:10,
tt = sprintf O'/.dW ,k);
text (xy(k,l) ,xy(k,2) ,tt) '/,
end; axis off
>> titleC'MaTpmja ')
hold off; figure(3) */ G(A2)
xy2 = xy(al,:); '/,
'/, al
>> gplot (A2, 2); hold on */,
>> gplot(A2,xy2,'') , ''
for k=l:10,
tt - sprintf (' y.dNn^k);
text(xy2(k,l) ,xy2(k,2) ,tt)'/ (
end; hold off; axis off
t i t l e ' Al a i ' )

.
[4] [15).
245

16.1
= 50 170
. flops, -
, ,
:
A\b 3 ;
= det(A) 3 ;
z = inv(A) 3 ;
t b * b' * b 2 ;
u = b * (' * ) ;
v = b * 9 + 6 ;
w = * 2 .
16.2 : = \,
LU- ( -
?):

1 1 0 3 ' \ \ / 4
2 1 -1 1 2 1
3 -1 -1 2 ^
4
1 2 3 -1 1
16.3 16.2.2 Ay = e
f b 16.2,

^ ( 4 2 - 2 1 ) n f = {34 10 1 3 6 ) .

16.4 [L U P]=lu(A) 16.2


:

u
Hil
L2, U2 L, U chop.m =1,
|| , MATLAB'a norm: -
, ||L|| norm(L).

16.5 lin_solv.m Iu2.m ., -


16.2 t = 1- . -
. ? -
norm 16.4.
246 16.

16.6 = ,
/ 1.1756 4.0231 -2.14170 5.1967
-4.0231 1.0002 4.5005 1.1973
= -10.179 -5.2107 1.1022 0.10034
-6.6932 -4.1561 )
\ 886.19 7.0005
b = ( 15.721 19.392 2.9507 -38.089 ) =
\ .
() = b t = 4-
-
. -

=

|j || 2-.
(b) ()
.
(c) () t = 4, , -
-
, ,
. . |||| < 10~ 9
+ -> . -
, -
.
: while

= l i n _ s o l v ( . . . );
count = 0
while norm(e) > 1.0-9 )
= - *

=+ ;
count - count + 1
norm_e_is = norm(e)
end
16.7 16.6, -
, ,
( = 5-
. .
() ,
247

b , -
[0.001,0.001].
: <- b + 0.002*rand(4,1) -0.001 *ones(4,1).
(b) , -
[0.002,0.002].
16.8 . help h i l b , -
. -
6 = 2 : 1 : 7 .
= b

t = 8- .
- ,
t = 1 : 12, -
.

16.9 9 9-
1 0 1 1 0 0 0 1 1
0 1 1 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0
1 0 0 1 1 0 0 0 0
.4 = 0 0 0 1 1 0 0 0 0
0 0 0 0 0 1 0 0 1
0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 1 1 0
1 0 0 0 0 1 0 0 1

symrcra, -
\ = (, )
. G(A) G(Ai), gplot
, G(A) :

0 0
0 1
0 0.5
0 -0.5
= 0 -1
-1 0
1 0
0.5 0
-0.5 0
248 16.

16.10 11- 13.


14. :
/1 - 2 0 30 0 3 -2
0 fi 4 4 0 3 -2 0 0 3 0
0 4 fi 3 0 0 -2 0 0 0 0
0 0 2 ^ 0 0 6 0 0 0 0
2 6 0 0 -2 4 -2 0 4 0
3 3 6 0 4 -2 0 0 -2 0
0 2 4 4 0 0 /i 0 0 4 0
2 0 0 0 3 3 0 4 2 3
00 0 0 -2 0 6
0 - 23 3 -2 0 0 / 0
0 0 0-2 0 - 2 - 2 0 /z J
\i = 999. 1*
symrcm, \. -
, \ -
Iu4.ni,
. spy -
.
, , symrcm?

*' , , -
symrcm .
17

-
, , -
.
,
,
1' .


.
. -
(ID), (
2D). -
.


. -
. ,

. .
MATLAB'a
. -
MATLAB'a interpl, interp2, polyf it polyval
- polyfit2.m polyval2.m. -
MATLAB'a -
; - intdemol.m
intdemo2.m.
1
' , { )
. , , -
-
. . .
250 17. ,

17.1. ID:
m

{) = {\) + (2)'1 + + {) + { + 1),


= [(1) (2) () (+ 1)] .
MATLAB'e
polyval:
1.
{) = 24 - 53 + 2 + 8; - 1,
. . = 4, = [ 2 5 3 8 1 ]. 4 =
-9.0 : 4.5 : 10

= 2 -5 3 8 -1 ] ; 7.
= -9.0 : 4.5 : 10.0 ; V
% [-9,10]
>> = polyval (, ) ; '/,
plot (,, 'ow') ;hold on; , [0]
plot (x,y,'-w') ; 7, [1]
>> = -9.0 : 0.01 : 10.0 ; V.
7. [-9, 10]
>> = polyval (, ) ; '/,
>> p l o t , , ' : g ' ) ; [2] ()
a x i s ( [ - 9 10 -2000 17500]);%
>> CQ = p o l y f i t ( x , y , 2 ) ; %
7. (,)
2 = polyval (CQ, xp) ; 7.
>> p l o t ( x p , 2, ' ' ) ; 7. [3]
7.
t i t l e ( ' 1 - '); hold off
1
plot ' ,
-
. ,
( ).
, -
; . . 17.1.
*) , . ,
, aetfgca, 'Color', ' k ' ) ,
, 'white' () ('ow' '-w') 'black' () ('ok' '-').
17.1. ID: 251

16OOO
1

-
14000 -

12000
\
' -

10000

8
/ -

60

- -
\ ' \ / f
-

40
/ / -

. 17.1. 1 ( -
,
, ).

. -
, -
. -
, , ( )
, xi, yi ( ) ,
( L) . , L
(, L ),
. , = 5
L = 1901.
-
, : (i) -
, , -
; ()
, , (ii,j/i), (2,3/2), ,)> -
, .
4 polyf it
(ii). , -
, ; . 17.1,
.
-
, -
252 17-

. polyf i t ,
i n t e r p l .

17.2. ID-: - intdemol.m


intdemol. m, = cos(2a:)
[2,4] = 13.
2.
= - 2 : 0.5 : 4
= cos{2 * ).
16 xi =
2 : 0.4 : 4, 151 = -2 : 0.04 : 4.

intdemoi.m, ID-; . . 17.2
17.3.

17.3. ID-
(,\), (2,2/2), ,)->
, . -
. 5.

17.3.1. (
)
, . .
1
() = {1) + (2) ~ + + {) + ( + 1),

( )
Pm{%i) -
-

()> Yi = Pm{^i)- = 1,
Pi(x) = (1) + (2),
.5.
17.3. lD- 253

- 2 - 1 0 1 2 3 4
intdemoi.m 1D { )

. 17.2. ID- (), (*)


6- ( ) .

- 2 - 1 0 1 2 3 4
Intdemoi.m 1D ( )

. 17.3. ID- (), (*)


().
254 17.

MATLAB'a, 2
( = 5),
>> = -2 : 0.5 : 4 ; */.
>> = cos(2*x) ; %
>> = polyfit(x,y,5); % C(i)
, _5()
= -2 : 0.04 : 4; '/,
fp = polyval(C, ) ; */, _
,
>> plot(xp, fp) ,

17.3.2.
1 ( . 17.1),
(, )
.
.
, - -
. , -
.
m , = 1 (..
).
,
,
.
, -
(.. , ), -
-
, -
.
(-) 1 *.
2 ' = 1,
. 5,
.

*) -
.
2
) -
. , -
polyfit.
17.3. ID- 255

17.3.2.1.
- -
(-
). -
1), , .
-
.
MATLAB'a interpl -
, ,
2:
>> = -2 : 0.5 : 4; '/,
>> = cos(2*x); ,
>> = -2 : 0.04 : 4; */,
>> FL = interpl(x,y, x x , ' l i n e a r ' ) ; /'
FC = interpl(,, , ' c u b i c ' ) ; .
plot(xx,FL, ' - r ' , x x . F C ' - g 1 )

,
, , 1 : 0.3 : 1.

17.3.2.2.

-
, -
(, )
.
, -
.
MATLAB'a interpl
2:
>> = -2 : 0.5 : 4; ,
>> = cos(2*x) ; ,
>> = -2 : 0.04 : 4; '/,
FS = interplCx.y, xp,'spline') ; '/,
plot(xp,FS,'-')
J
) :
. 17.3.2.2.
256 17.

17.4. ?
, -
1 ), , .
-
.
.
, \,2,... , ( xi)
-
,2, ) ( yi). , /; (
fi) xi, -

Error = J-\\u-yi |2
\2 ~
\
, , -
. Xi {
i (.. -
= ), ,
Error = 0. ( -
.)
2

>> = -2 : 0.5 : 4; '/,


= cos(2*x) ; '/,
= polyfit(x,y,5) ; '/, C(i)
7, _5()
>> xi = -2 : 0.4 : 4; 7,
fi = polyvalCC, xi) ; 7,
7.
>> yi = cos(2*xi); '/,
7
= length(xi); 7. xi
Error = sqrt( normCfi - yi)"2 / T) '/. -
'/,
*' , , -
-
, .
17.5. 257

, norm MATLAB'a. ,
, f i , -
i n t e r p l (, FL), 1 '
fi yi, , .

17.5.
17.1 ID
() ( ).

; m- -
( R n )
_ ( ~ . . . \ _ V" 4 fi. . . *2 . . . tn

if. = 0 , 1 , . . . ,m = 1,2,... ,n. -


20- = 2
= 1 () 3 ().
= 1

Z(x, ) ~ + + + dxy,
3

2 2 2 3 2 3
Z(x,y) = + + + dxy + d\xy + d2x y + eix + e2x + fay + f2y

, ID, -
, : (i)
z ~ z(x,y), Z Z(x,y)
(~1 3) -
( N ); (ii)
(xi,y1,z1), {x2,y2,Z2), ..., (xiv,yjv>2jv), -
Z = Z(x,y), .
,
.

^ , MATLAB'e 4 FS = interpKx.y, xp,


' spline') -, -.
5.

17-4196
258 17.

-, -
:
polyfit2.m -
2D ( )
polyval2.m - "polyfit2.m"
( )
- intdemo2.m, cont4.m
cont7.m.
. , -
, ,
m ;
;
N .

17.6. 2D - intdemo2.ni
-,
- intdemo2. m, -
(N = 25):
3

{ = 0 : 0.25 : 1
1/ = 0 : 0.25 : 1
z = rln(r),
= /{ 1/2)2 + ( 1/4)2. ,
, - intdemo2. m.

17.7. , -

= 2 ,
, ()
.
MATLAB'e -
- ,
. ,

z = z(x,y) = {& - 3 - 0.5)(~2 - 2)


17.7. , - 259

. 17.4. .

= [2, 2] [2, 2].


meshgrid, ,
( ):
= -2 : 0.4 : 2;
= -2 : 0.25 : 2; '/,% , - ID
[ ] = meshgrid (xO,yO); ,'/,
ZZ=(x."6-."3-0.5) .* (-.~2-.~2) ; % ZZ

SD-. mesh surf ( 1 ))


ZZ; .
. 17.4 17.5.

>> mesh(ZZ); t i t l e ( ' ')


>> dispC'Pause . . . ' ) ; pause
surf (ZZ) ; title('fl4eiicTbni ')
, view, -
, view(20, 7 0 ) 2 ) .

*) help mesh, . -
, surf plot3, MATLAB'e 4.
2
> view , -
,
. help view. . .

17'
260 17.

. 17.5. .

. contour ,
, -
( ), 1^ -
( - cont4.m).

M=max(ZZ) ; mi=min(ZZ); 7, -
V=[mi mi/2 /2 ] ; '/,
, ZZ
Cl = contour(x,,ZZ, V , ' - r J ) ; .
>> c l a b e l ( C l ) ; , ()
>> titleCTpai^HK z ( x , y ) ' )
>> 2 = contourCx,y,ZZ, 7 , ' - g ' ) ; . 7
,
V, . 17.6.
: , , , 2 : 0.4 : 2
2 : 0.25 : 2 -
. , .. -
,
^ , MATLAB'a (, -
4-), , , 1 =
coatour(ZZ,7, ., ' - ' ) , 1 = contour(ZZ,V, ., ' - 1 ) , 1 =
contour(xO.yO.ZZ,7, ' - ' ) .
MATLAB'e 5.
17.7. , - 261

-2 -1.5 -1 -.5

. 17.6. .

, , = 1: 0.01: 2 2 : 0.02 : 2
.
. 1 ' ,
- -
. 3
-
(. . 17.7):
>> = 0; = -2 : 0.25 : 2; VI, ,
>> Zx=(x. "6-. "3-0.5) .* (-.~2-."2); , Zx
>> subplot(211);plot(y, Zx,'-r'); title(' ')
J
>> ylabel' x=0 )
>> = 0; = -2 : 0.25 : 2; '/,
Zy=(x. "6-. "3-0.5) .* (-.~2-."2); /, Zy
s u b p l o t ( 2 1 2 ) ; plotCx, Zy, ' - g ' ) ;
>> ylabel' =0')
{, , ) -
p l o t 3 .

subplot(ill)
1>
MATLAB'e 5 slice
. help slice, .
262 17.

-0.5
-2 -1,5 -1 -0.5 0.5
. 17.7. .

= 0; = -2 : 0.25 : 2;
Zx=(x.~6-y.~3-0.5) .* (-.~2-."2) ;
>> hl=plot3(zeros(size()), , Zx, ' - r ' ) ;
>> hold on ,'/,'/,
= 0; = -2 : 0.25 : 2;
Zy=(x.~6-y.~3-0.5) .* (-.~2-."2) ;
J
>> h2=plot3(x, zeros(size(x)), Zy, - g ' ) ;
zlabeK' =0 =0')
grid on; hold off '/.
view(10,50) '/, view(80,50)
7, view(175,50)
setChl.'Linewidth', 3 ) ; set(h2,'Linewidth', 2)
set(gca,'Ytick', -2:1:2)
17.8. '\'- 263

-
, : get(gca)
help set, ,
. ,
, -
. ,
, ,
+ = 1.

17.8. ; \'-
Z(x,) z(x,y) z^ = z(xi,yj);
, z(x,y) ,
.
-
( 2 Z(x{,yj) i,j)


(, , , , d 17.5).
-, \-
( . . 5). polyf it2.m
polyval2.m 3 (. cont7.m):
= 0:0.25:1; = ; VI, .
[ ] = meshgridfxO, );
R = sqrt ( (-1/2).~2 + (-1/4)."2 );
z = R. *log(R+eps) ; VI*
VI,
Cl = polyfit2( x,y,z, 'linear');
2 = polyfit2C x,y,z, 'cubic' );
V/XIX/X/XIX/X/. '/.
= 0:0.02:1; = ; '/,
[xi yi] = meshgrid(xO, yO);
Zl = polyval2( Cl, xi,yi, 'linear'); %
'/,
Z2 = polyval2( C2, xi,yi, 'cubic' ); '/.
,
yX/XIX/XIX/Xa
c o n t o u r ( Z l , 9 , xO.yO, ' - g ' ) ; hold on; */, 9
contour(Z2,9, xO.yO, ' : r ' ) ; hold off
264 17.

17.9.
-
, -
1). , , -
, -
-
.
-
. MATLAB'a interp2 -
, .
, -
, . -
2)
, -
.
.
, interp2 3 (.
cont7.m)
=0 :0.25: 1; =; [ y]=meshgrid(x, );
R=sqrt ( (-1/2).~2 + (-1/4)."2 ); z = R.*log(R+eps);
>> =0 :0.05: 1 ; = ; , ID-
>> [xi yi] = meshgrid(xa, ya) ; '/, 2-
>> zL = interp2(x,y,z, x i , y i , ' l i n e a r ' ) ;
>> zC = interp2(x,y,z, x i , y i , ' c u b i c ' ) ;
contour(zL,9, xa.ya, '-w'); hold on;
J
contour(zC,9, xa,ya, - b ' ) ; hold off

17.10.
z = z(x,y),
Z ~ Z(x,y). , -
, .
1
*
\ polyfit , -
,
.5. . -
2
' -
( ,
). , -
.
17.10. 265

, ,
. , -
,
.
, Z -
z (,
iV3 x 2). ,
, Z Zl,Z2,zL,zC,
z z(x,y). -
.
. hold on,
Z -
z (, ). -
, -
, .
: -
mesh surf.
-
, , , -
. ,
, ,
,
.
. , -

, 1', = norm(Z ~ z)
2'
, .
, ID,
,

, .
1
' ,
.
2
. .
' . 16.
266 17.

,
(Z z), -
MATLAB'a norm(Z-z, ' f r o ' ) .
:

>> [m n] = s i z e ( Z ) ; 7,
inn = m * ; ,
>> format compact; /,
>> dispC' ');
= s q r t ( normC Z-z, ' f r o ' ) "2 / ran )

,
. -
,
,
, , -
.
, -
(,
, -
--).
-
. -
, ()
,

.

17.1 f(x) 1/(1 + 252) [1,1]


= 1:0.25:1;
3 7 .

17.2 f(x) . 17.1


, -
.
267

17.3 , [0,1]:
(a) f(x) = -(x + a)R + [aR{l-x) + {l+a)Rx] =10~2
R I
(b) f{x) = (l-x){tan-1[b(x-xQ)]+tzn-1[bx0]} = 100
0 = 1/4,
(c) /(z)=tanh[20(a:-l/2)].
(d) . f{x)=10000{fi(x)+f2(x))\{x-l/4){x-Z/4)\3
fi(x) ~~(x + a)R + [aR(l-x) + {l+a)Rx] f2{x) =
-(l-x + a)R + [aRx + {l+a)R(l-x)]. = 0.3 =
-1/4.

(i) () -
: = 1 : 2 0 , -
- , -
, 10 -
( = 0 : 1/9 : 1).
(ii) -
: 1: 20
- , =10 -
(,
[0:0.1:0.4 0.6 : 0.1 : 1] = [0 0.26:0.15:0.44 0.47:
0.035:0.65 1]).
.

. , ,
:
(1) = 10 +
1
(.. 1/10);
(2)
( -
);
(3) .
:
(i) -
= 20 ,
,
(ii) , -
268 17.

, -
:
,
,
-
-
.

(iii) i~^ = 1 - tanh 2 (x)


y
;
~
dx ' dx 1+x2
(iv)
(1) 6 ;
(2) 3 x 4
-
;
(3) 3 x 2
-
.

17.4 , -
(
- ):
gi{x,y) = tanh[20(x + - 1)] [0,1] [0,1];
92(,) = t a n h [ 2 0 ( a : 2 + y 2 - l / 2 ) ] [0,1] [0,1].
17.5 . 17.4
( ) -
; N = 11 -
, .. = = : 0.1: 1.

17.6 . 17.4
( )
; N 9 -
, .. = = 0 : 1/8 : 1 .

17.7 . 17.4
JVj = 2 = 13
(. . 17.5 = = 0 :1/12 :1)
JVi = N2 =
8 (. . 17.6 = = 0 : 1/7 : 1):
() -
-
269

. ,
4 * N\ * N2.
(b) , -
. (
, -
-.)
18


-
, ,
.

,
, -
.
-
.
, -
.

MATLAB'a
. 7. ,
( )
. -
, -, -
(fodesol.m, s p e c i e s , m, vderpol .m,...). -
-
.

18.1.
-
:
() -
. -

.
271

(b) , .
(c) .
(d) , ,
, ..
-
. ? ? -
? ? , -
, . . .
, ,
, . 7.
, , -
MATLAB.
. , .

18.1 1

= 2,

(0) = 1.
18.2 = 1

dx
(0) = 1.
18.3 5

{ - 2 ^ ) ~ ^ - = 0, { > 0,/ > 0),



(1) = 10.
18.4 = 1

+ 3

(0) = 1, '(0) = 0.
18.5 = 4

(0) = 1, /(0) = 0.
272

18.6 = 4

t/(0) = 1, '(0) = 0.
18.7 = 4

(0) = 1, '(0)=0.
(: -
, 0 (
). -
() + + 2, -

, -.)
18.8 t ~ 1

=x(2x + i/-3), -=( + 2-3),


at at
(0) = | , (0) = 1.
(^. -
, . 7.)
18.9 = 1

(0) = 0, '(0) = |.
(. . 18.7,
-
.)
III

19. : 275
19.1. 276
19.2. 280
19.3. 283
284
20. 287
20.1. 288
20.2. 288
20.3. 291
20.4. 293
294
21. 296
21.1. 297
21.2. SIR- 298
21.3. 299
21.4. 301
302
22. 304
22.1. 305
22.2. 306
22.3. 308
309
23. 311
23.1. 312
23.2. 312
23.3. 314
23.4. - 315
315

18-4196
19
:

-
, .. -
(fifo first-in-first-out),
.
, -
, ,
-
, ,
,
. , , , -
, ,
(, , , -
, ),
.


. -,
, , -
. -, ,
,
-
100%, -
, ,
.
-
.


,
, . 6.
,
.

18'
276 19. :

MATLAB'a
- queue. m -
- exprand. m, normrand. m, unirand. m;
MATLAB'a plot, bar, sort, rand.
. 19.1 -
-
- queue.. 19.2
, 19.3 -

.
,
, .

19.1.


. -
. -
,
,
.
. .
,

. , , -
.
1
^,
,
. ,
- , , -
, ,
19.3 , -
.
. -

1 -
;
1
* , . . .
19.1. 277

2 -
().
, cumsum -
. -
,
( ), ,

.
-
-
queue.m. ,
-
.

19.1.1.
It -
. . 6,

, L -
, a It -
().
-
(, : 40% -
, 60% )
MATLAB'a, . 6.

19.1.2. - queue.m
-
- queue .m ,

.
-
[Mean_q Serv_u Wait_t Stop_t] = queue(Arr_t, Ser_t)

Arr_t ,
Ser_t ,
278 19. :


Mean.q , -
;
Serv_u , , -
;
Wait_t
;
Stop_t .
, = [2 8]
Ser = [7 4] ( )
[ S Wait Stop] = queue(Arr, Ser)
M - 0.9231
S = 0.8462
Wait = 0 1 /, 1- , 2-
Stop = 9 13 7,
- queue.m, ,
.
queue.m ^.
-
- exprand. m, normrand. unirand. m.
, . 6, , -
, help, . -
fc-
fi = mu
>> matrix = exprand(,,)
^--
( = mu a ~ sigma, -

matrix = normrand(mu,sigma,n,k)
^-
,
matrix = unirand(a,b, n,k)
1
' , -
100%, , -
, ,
.
19.1. 279

19.1.3.


L ~ 50 . / = 10 ,
5 = 10 .
-
IT = exprand(5, L) , -
N = ceil(unirand(5,0,10)).
. 19.1.
AT cumsum
I T . ,
, ,
, -
, .

- queue.m :
IT = [47 94 58 103 3 ] ;
AT = cumsumC IT )
ST - [90 70 70 30 60] ; .
>> [Mean.q Ser_u Wait_t Stop_t] = queue(AT,ST)
, M A T L A B ' O M ,

AT = 47 141 199 302 305


Mean_q = 0,.9158
Ser_u = 0..8163
Wait_t = 0 0 12 0 27
Stop_t = 137 211 281 332 392

,
Mean_q = 0.9158 1 (..

19.1. -


IT N ST = S *
47 9 90
94 7 70
58 7 70
103 3 30
3 6 60
280 19. :

19.2.


,* N ST QL
EoS
() ^
0 0 47
(1) 47 9 90 1 141 137
(2) 141 7 70 1 199 211
(3) 199 7 70 2 302 281
(4) 302 3 30 1 305 332
() 305 6 60 2 343 392

). , , -
,
,
.

19.1.4-

.
: , -
, .
, ,

.
-
-
(. . 19.2), ,
, .., N
EoS ,
QL , (: -
QL queue. m, EoS
, queue.).

19.2.
(. . 19.1)
-
. ,
-
, .
19.2. 281

. 19.1. ( ).

, ,
, , 20% -
, 30% 50%
(, ).
-
100 150
. -
, 10 100
30 150 -
. , , 30
, 40 60 .
, -
,
( ), -
, . 19.3, -
, -
( s). -
. . 19.4 -
,

19.3.

AT ST
s

2 17 56 46 0.96 +1 60
246 72 52 129 0.96 +1 60
344 98 94 74 0.07 1 30
400 356 33 19 0.22 0 40
405 0.11 30
282 19. :

19.4. -
('ml.p' 'ml' -
( ), 'ml.k' -
'ml' 'sl.p' 'sl.k' ).


()
()
0 0 0 0 2 17
ml.p 2 1 0 0 246 17 58
sl.p 17 1 1 0 246 72 63
ml.k 58 60 0 1 1 246 72 118
sl.k 63 60 0 0 2 246 72 178
s2,p 72 0 1 2 246 98 201
s3.p 98 0 2 2 246 356 275
s2.k 201 30 0 1 1 246 356 231
m2.p 246 1 1 0 344 356 298
s3.k 275 40 1 0 1 344 356 315
m2.k 298 30 0 0 2 344 356 345
m3.p 344 1 0 1 400 405 438
s4.p 356 1 1 0 400 405 375

(: EoS -
1). queue.m,
EoS:
Arr = 58 63 201 275 298] ; .'/,
V/,
Ser = [ 60 60 30 40 30];
[mq su wait_t EoS] = queue(Arr, Ser)
Arr Ser . 19.4 (-
). ( EoS)

. 19.4, :
[mq su] = 0.8464 0.6377 '
wait_t 0 55 0 0 17
EoS = 118 178 231 315 345 7. '/.
: -
[0,1],
0 < < 0.2, 0.2 < <
0.5 0.5 < < 1. <
0.2 > 0.2 kl = ( r < = 0 . 2 ) .
19.3. 283

. 19.2. .

( < = 0.2) , a fcl


1 0.

19.3.
-
,
: ,
. ,
- .
. 19.2, , -
, -
,
() . -
, .
, :
(a)

mi, m<i $ .
, , -
,
,
. -

.
(b) 40% .
284 19. :

50% .
60% .
(c) , -
d, 6.2 ^
, ,
.
(d) , , , -
, 20 40
. 90%
10%
.

19.1 , L
3 .
-
/(:
(a) [0,6];
(b)
=1;
(c) .
100 -
, queue.m 2
,
. -

.
19.2 19.1.4, L = 45, / = 12, S =
8, queue.m -
, .
19.3 19.2:
() 145 -
() 96 -
-
( )
queue. m. :
( -
), -
285


( );
( -
) , -
.
.
.
. , -
.
EoS- ( -
) . -
. MATLAB'e
- b
= [].
(b) -
( ) ,
. 19.4
500 .
. ,
, -
, 500 .
(c)
2 18 -
. . -
, 70
80 130
-
.
, .
- ( > 10)
V ,
(V k/n,
).
. -
seed rand.

>> use_seed = sum(100*clock);
randCseed', use_seed) ;
-.
286 19. :

19.4 19.3, mi = 44, m 2 =


55, 77i3 = 36, m 4 = 100 d\ = 145, d2 = 108, d3 = 69:
(a) 100 -
50 .
, 100 -
.
( ) -
( ).
(b)
(). () -
(). , -
queue.m
() ().
( -
) ''
.
(c) () (),

40 ? -
40 ? , ,
,
1.49 -
30 . 40 .
, -
90?
1 ,
19.2, , s = ( <=
0.9), , s = (0.9 < ),
.
2 MATLAB'a nnz
, sort -

,
= [ 2 0 1 5 0 0 4 0 9 ]
arr_l = - s o r t ( - a r r ) , number = nnz(arr)
arrival.2 = sort( arr_l(l:number) )
1 ' number = 5
arr_l = 9 5 4 2 1 0 0 0 0
arrival_2 = 1 2 4 5 9

1
J sort ,
arrival-2 = sort(arr(arr~ = 0)). . .
20



. -
(
), -
. ,
.

-
(.2) (.7),
.
(.5).
MATLAB'a

-, .
. , help,
-
.
MATLAB'a, , eig ( ), plot bar
{ ). :
fishy.m - ,
leslie.m - (. . 2),
Imfish.m - ,
iodesol.m-
,
mparft.m -
,
mparst4.m-
,
288 20.

resid4.m - ,
f ishdat .m- fishy.m,

20.1.
fishy, -
. help fishy, , . -
plot, , -
.
() -
. ( help bar.)

{. .2). help lmf ish, ,
. 1'.
, ,
, ,
( )
,
.
, -
.
-
.
. -

.

20.2.
, .
[3]. -

. -
, :
m(t)- t,
V{t) - t,
t - ,

type lmf ish. . .


20.2. 289

- / 3
( 1 / 3 ),
h, w,l -, ().
(. .
,
.)

, ,
. h, w
I
. . ,
V = hlw. m = pV.
.

20.2.1.
( ) -
, -
.

=re-xtm, (20.1)

( > 0) -
. , ,
. -
1/ ,
, , -
.
, (20.1) t,
. -
f odesol,
. ,
. t,
(t= 1?).
.
, (20.1)
m(t). -
, ,
f odesol fnxt,
. -

19-4196
290 20.

.
f odesol, .7.

20.2.2.
, ,
,

^=-/, (20.2)

/3 . -
. -
() -
( ), -

.
,
f odesol , -
L V's, L, , . -
,
, dVjdt = 0. , -
. ( .)

20.2.3.
, -

[fish(:,2) f i s h ( : )]. -
,
-
. , ,
.
.5 -
.
2
R
,
. MATLAB ,
- mparst4.m ( -
) mparf t . m. mparst4, -
. mparf t . m,
20.3. 291


m = aebVi + c. (20.3)
, [1 1 1] -
[abc].
R2. -
.
resid4.ni,
( (20.1) (20.2)).
,
, , R2,
.
,
.

20.3.
.2, -
. - leslie.m
. 111.
-
. :
(i) fishy.m
, 5000
. ,
fishy.m .
() ,
. -
(, ),
/ ,
.
(iii) , -
, ,
.
(iv) 10 .
-.
-
,
.
9'
292 20.

20.3.1.
, , -
, V t.
,
, f i s h ( : ,2)
( ),
V(t) -
t.
, , ,
d , V . -
-
.
(l/h) (w/h). V
h. , h> d .
. , -
, , ,
.

20.3.2.
h<d, . -
,
h d. ,

2
Pc = mm{l,{h/d) } (20.4)
, -
, -
2
. (h/d) , - -
, , -
, .
,
() .
, , -
.
/ //, -
1 .
lmf ish.m, -
, . ,
, -.
(
20.4. 293

%) . ,
.
, ,
- -
d feff.

d=input(' d ' ) ;

d (, 10)
lmf ish.ra.
-, -
, .

20.4.
.2,
, -
. 1 (
.), .
1, .
,
( , ) -
. ,
, , -
,

>> pO=fish(:,3)

pl=H*pO
, [ pi 2 . . . ] . ,
, -
, . ,
-
d / //.
.

, -
. , , ,
. -
, \
294 20.

, -
. , ,
.
, -
. -
, -,
( ),
. -
.
,
. , -
lmfish.m,
, -
. (.*)
.
,
. , d= 100 / // = 0,
. , -
, -
. -
, .

20.1 , fishy,

() .
20.2 ( )
,
.
20.3 (/3), -
,
.
20.4 (20.1) (20.2) -
.
20.5 fodesol,
(20.1) (20.2) . -
, ,
.
20.6 (-
) V(t),
295

mparft, *
f odesol.
20.7 [,, ] [,,/3] -
(20.1) (20.2), , , -
.
,
.
20.8 , .
20.9 lmfish.m,
, -
.
20.10 (-
,
,
).
?
20.11 , -
.
- ,
.
21


-
, -
.
, -
. -

. -
,
.

:
(.7); -
; , -
; -
(.5).
MATLAB'a
-
, .7. -

. 20.
-,
, .
-
. help, -
.
:

f ludat.m - ,
plagdat.m- ,
21.1. 297

colddat .m- ,
sirepi.m - SIR-
,
sirfn.m -
,
mparft.m -
,
mparst3.m-
,
resid3.m - ,
lagsum.m - .

21.1.

f ludat, -
, ,
-
. N
(= 763) ,
[1=1] S = N 1 = 762
. -
, I , , -
.

{ R). -
N
N = S(t) + I(t) + R{t) (21.1)
SIR-,
.
- plagdat .m ,
, -
1905 1906 .
R(t) ,
, , -
.
: -
1
'. , ,
(), . . dR/dt.

) , , . . .
298 21.

colddat -
-

.
. 280 -
.

21.2. SIR-
, -
30- ., -
5, / R, -
, .
, , -
[10] [3]. -
(. (21.1)), -
:

ft (21.2)
^=rSI~aI, (21.3)

f= O 7. (2L4)
:

S(t)~ , .. -
N , -
t.
I(t)
(),
.
R(t) , -
, -
, ,
, .

, -
,
. (21.4). , -
, ( )
21.3. 299

/.
= ( > 0). (21.5)
(21.3) -
, ,
I. ,
-
() S,
/ .

= ( > 0). (21.6)
, (21.2) -
,
S.
-
-
. (0) = 0, -
. /(0) = /
, t = 0,
So = N IQ. t = 0 , I = IQ = \,
.

21.3.
, dS/dt < 0 ,
S(t) ,
dl/dt = 0 S = , (21-7)

, , I(t)
*- , ,
I(t) .
= / (21.8)
.
, 5 0 < , (21.7) -
. . /, -
, . -
I(t) > IQ t.
, ( -
-
300 21.

. , (21.2) (21.3)

, ,

=>(). (21.10)
,
t. -
, -
. , -
(21.10)
(21.4) R(t),

~=a(N-R-Soe~f). (21.11)

. ,
f odesol.m . 7. R/p << 1, -
R, ,
, -
, .
, -

A2-(R-R)2 ~ a d t -
(21.12)
(. ). -
#(}, -
(21.11).
dR/dt, -
, , ,
, plagdat.m.

JD
= sech2 (at + 0). (21.13)

(21.10) -
, I -
t J- . (21.10)

/ / \\ \
(21.14)
21.4. 301

, , -
MATLAB'a f zero.
, -
. (21.10) (21.7),
-
/ -

.

21.4.
-

. , , R/p , -
(21.13),
, 0 -
. 5
. . 20 -
, :
-
. - mparft.m
. mparst3,
,

%=~^. (21.15)

mparft, ,
.
- resid3.m. , -
resid3.m,
(21.13).
SIR- -
- sirepi.m. ,
.
, -
t.
, R , 5 -
N I, (21.3)

(21.16)
302 21.


, . t,
, 5 I ,
dl/dt . , -

. ,
s i r e p i .
c o l d d a t . m
, -
.
I(t), , -
. -,
7 . -
I(t), R(t) , , S(t).

MATLAB'a.
- lagsum.m. -
5, / R, SIR-. , -
SIR-,
,
. .

21.1 , -
(21.7), I(tmax).
21.2 (21.10) (21.9), -
, 21.2.
21.3 (21.12), -

1
! I h - ^ ) (21.17)

(21.13), -
, , , N SQ.
21.4 , -
, , 7 = 1 t = 0
N = 763.
21.5 R/p .
21.6 ?
303

21.7 , 0,
, -
(21.13).
21.8 sirepi- -
dRjdt (N, )
. , -
.
21.9 , -
, ,
.
21.10 colddat.m ,
S(t), I(t) R(t)
. R(oo).
21.11 SIR-,
.
.
2 2



-
, -
.
,
.

, -
. -
.
MATLAB'a
, -
MATLAB'a . 7-
-, ,
. -

. help
. :
topog 3-
,
snowsl ,
snowboat ,
snbtfn ,
fsnowO / (
),
fsnowl fx fy,
fsnow2 fxx, fXy fyy,
snowmn ,
snowmx .
22.1. 305

22.1.
topog, -
, ,
.
z = /(x,y), (22.1)

/ , snowsl.ru
fsnowO.m. - topog.m ,
() ().
- fmins, /
/, .

(. f snowl . f snow2.m),
. ,
, -
, fmins
.
-
. (
), , -
, . -
, v
:
= + ~ const, (22.2)

2
- mgz, = -^mv . (22.3)

, , ,
, . , -
:

, -
;
, .

-
, . -
-
.

20-4196
306 22.

, -
,
.
,
.
.

22.2.
.

m : 150
;
: 1.5 0.5 2 ;
9.81 / 2 ;
fi
;
(Fk = kv2);
- ;
F , ;
;
Fp ;
Ffc ;
N
.

mv = F = F g + F p + F f c + N , (22.4)
, . 22.1.
,
(22.4) (22.1). ,
, , -
,
(22.4) F M = N 0.

F, = - j ^ | N | . (22.5)
, , -
. -
= 0, .
22.2. 307

. 22.1. , ( )

. 7 . , -
( = 0).
(. ). -
, , -
,
F f c = -jferjf|. (22.6)
, , -
. -
, ,
70 , ,
54 /.
-
,
, .
, -
, ,
= 0, ( ) -

.
:
,~l) (22.7)
, .

20'
308 22.

, N - f = 0, N ,
; .
, ,
(22.1) g r a d -
z f(x,y). .

, (22.4)
,
(, ) -
(22.1). , , z, z z,
. -
. 7,
, , , /, ,
= , v = .

U
*) = ( ( { ? ) = - 1 ( - ? ?+9 ' * ) , (22.8)

__ | -1 Qxjx Qxjy
~QyJx A ~ QyJy

9 = 9 + fxxU2 + Zfxyuv + fyyv2 + \t\(fxu + fyv),


Qx 5 Px lx
Pz M
(nx,ny,nz), g r a d , N -
.
,
.
- snowboat. m ,
. 7. snbtfn.m -
(22.8).

22.3.
, ,
-
309

f.i ( ), -
snowboat.
, -
, (
/^ + VQ), . , -

, .
-
/ (22.1) -
.
.
, snowsl.m, fsnowsO.m, fsnowsl.mn
fsnows2.m, , ,
z = f(x,y)=y/2. (22.9)
. -
, , , .

v t , -
, ,
dv
y^v. 22.10
dy
-
,
.
- snowboat. ( ,
( ) uo ^ St
. , -
VQ,
. -

(22.8).

.
.

22.1 3- -
, topog.
310 22.

22.2
2 2 . .
22.3 , .
22.4 ,
,
.
22.5 ,
(22.9), -
. snowboat -
(0,2000)
(0, 2) / ,
-
.
22.6 -
z = /10, / (
)
?
22.7 /i -
,
,
( snowsl.m ..). -
, -
, -
.
22.8
. ,
.
22.9 snowboat.m, -


.
22.10 ,
.
.
2 3


, -
, -
,
. ,
( ) , -
( ) .
, ,
, ,

.. 0:00 1 1992 .


,
-
.

'
MATLAB-,
-
. :
f ourier-
;
fitdemo-
;
fft - ;
ifft - ;
spline - ;
mean - ;
- .
312 23.


-.
. ,
help,
. :
tides.m - tm(l:nt)
hm(l:nt);
fourdat.m - ;
fouran.m -- ;
foursig.m - ;
locmax.m - ;
times.mat - ;
heights.mat- ;
noisyt.mat - ;
noisys.mat - .

23.1.

tides,
times.mat heights.mat. -
. (tm) , (1)
.
,
.
, ,

(*) - + Asin(w + 0). (23.1)
ho, , , ,
. ,
,
.
, , .
h0 .

23.2.
,
(23.1),
23.2. 313

. , -
, . ,
, -
.
, , -
. .

.
, , -
.
-
f(t) ( -
) (
) .

f(t)= ] ^-, (23.2)


=~
, -
, .
sin cos,
:

JJ .
2*\
(23.3)
sin(27rni/X) cos(2imt/T) / -
t, -
/. ~1~^~

t:

U ^ (23.4)

f(t) ( -
) , .
MATLAB'a fft (fast fourier transform
) iff t.
MATLAB'a,
, .
fourier ,
314 23.

() -
. -
, -
,
. -
1' -

fftdemo; -
,
(. . ), -
,
, , -
. -
( , ).
( -
), . ,
1 1 " 1 .

, ,
.

23.3.
, -
(fourdat), fftdemo,
- (f ouran). , help
f name .
, -
,
. ,
, -
. ,
f ouran.m, -
.
.
, . -
, , - f oursig.m, -
,
.
1
' -
. . .
315

23.4. -
- fouran.m, -
, .
load,
(times.mat heights.mat). ,
,
. , ,
? -
fouran.m s, t.
, , ,
clear
load times.mat
load heights.mat
>> whos
plotC . .. .) ..

. :
(
, );
-,
;
-
, (23.1);
spline
.

23.1
, .
23.2 , .
23-3 -
, ..
23.4 locmax
.
?
23.5 -
.
316 23.

23.6 , -
/.
23.7 , ,
.
23.8 -
, -
.
23.9 ( )
, .
.
23.10 -
.
.
23.11
.
23.12 3 10 13
6 4 1992 .
23.13 (/),
22 1992 . ,
1 200 (
). -
, , -
? -
(23.1).
1
MATLAB'a


help, -
. ,
help command.


help fname - -
fname
quit MATLAB
exit , quit
type fname - fname
who
whos

clear

what -,

which -
format

demo MATLAB'a


pi 7

inf GO ans
flops clock

318 1


+ (),
(),
*
.*

/ , ()
./

\
"

.""

'
size
length
sum
norm


sin, cos, tan
acos, asin
exp, log
sqrt
rand [0,1)
round
fix ,
abs

angle
r e a l , imag

conj
MATLAB'a 319


det
eig

inv
rref
rank

plot ,
(- ,-)
hold on/off
clg
mesh -

meshdom
-
contour
bar
title
xlabel, ylabel
axis
text
print


fmin
imins
izero
spline

quad
ode23 2-
3-
320 1


mean
std

cov
inin, max

/
save
load
diary fname MATLAB'a fname
cd
dir
2
MATLAB'e

MATLAB 5
MAPLE 1 *. -
,
, -
.


4
= f = + 2ty t 2t3, -
0, :
mapleC f := + 2*t*y - t - 2*t~3 ;' )
mapleC g := d i f f ( f . t ) ')
>> mapleC h := solve(g,y) ')
, MATLAB -
Maple.
f := x+2*t*y-t-2*t"3
g := 2*y-l-6*t~2
h := l/2+3*t"2

7
^ | = | , :
mapleC a := diff (x(t) , t ) = x ( t ) / t - x(t) ')
>> mapleC b := dsolve(a,x(t)) ')
1
' Maple MATLAB'a
Waterloo Maple Software, Inc. Waterloo Maple
: http://www.maplesoft.on.ca/ .

21-4196
322 2

(_1 ):
:= d i f f ( x ( t ) , t ) = x ( t ) / t - x ( t )
b := x(t) - t*expC-t)*_Cl

11
1
, -A^d = 2 (/ - / - /-) = 2,

maple( ' := 2' )


>> mapleC ' :- int(1/sqrt(-), =_0.._1) ')

:= -2*(2-_1)~(1/2) + 2*(2-_0)"(1/2)

16
,
1 1 0 3 \ 4 \
2 1 - 1 1 2 1
3 - 1 - 1 2 -3
-1 2 3- 1 v V4

= [1 2 0 1] ,
>> maple(' := matrixC[[1,1,0,3],[2,1,-1,1],
[3,-1,-1,2],[-1,2,3,-1]])')
>> maple(' print(A) ')
3 ) }
maple(' := " )
maple := array(1..4, [4, 1,-3,4])')
>> maple( J x := linsolve(A,b)' )
, , , -
""
.
:= VECTDR([-1, 2, 0, 1])
Maple,
>> mhelp , mapleC'help')
>> mhelp solve '/, "solve"
3
-

-, , -

http://www.cup.cam.ac.uk/Scripts/webbook.asp?isbn=0521639204

http://www.cup.cam.ac.uk/Scripts/webbook.asp7isbii~0521630789
, .
, , .
,
- MATLAB'a, -
- MATLAB'a.

1:

1 4
tsine.m
tsine2.m
2 polyex.m
goatgr.m
leslie.m goatfn.m
parnorm.m
3 linenv.m
cubics.m
fibno.m hypocyc.m
hail.m
gcdiv.m
pow.m

21*
24 3

5 7
tomato, m fodesol.m
toms.m fnxt.m
diabetic, m odegr.m
marks.m mode23.m
mannheim.m species.m
specfn.m
6 ode23k.m
vderpol.m
. vdplfn.m
exprand.m diffeqn.m
normrand.m dfeqfn.m
randme.m
unirand.m

2:

8 11
zzl.m
slide l.m
slidelfn.m
slide4.m
slide4fn.m

9 12
gcdran.m mobius.m
primes.m mobiusl.m
psp2.m cobm.m
miller .m cobq.m
matit2.m
10 matit3.m
quadn.m
hypocy.m perdoub.m
linenv.ra
paramc.m
- 325

13 16
cnrl.m Iin_solv.m
cnr2.m chop.m
Iu2.ra
14 Iu3.m
Iu4.m
randperm.m solv6.m
cycles.m spar_ex.ra
riffle l.m
riffle 1 a. m
17
remm.m
riffle 1 c m intdemol.m
rufflel.m intdemo2.m
rufflelc.m cont4.m
ruffle2.m cont7.m
polyfit2.m
15 polyval2.m

fulLnew.m
18
gauss_ja.m
Lrate.m . . 7
cont4.m

3:

19 20
queue, m fishy, m
exprand.m lmfish.m
normrand.m mparft.m
unirand.m mparst4.m
resid4.m
fishdat.m
326 3

21 23
fludat.m tides.m
plagdat.m fourdat.m
colddat.ra foursig.m
sirepi.m locmax.m
sirfn.m times.mat
mparst3.m heights.mat
resid3.m noisyt.mat
lagsum.m noisys.mat

22
topog.m
snowsl.ra
snowboat.m
snbtfn.m
fsnowO.m
fsnowl.m
fsnow2.m
snowmn.m
snowmx.m
4
-


- -
.
CUP :
,
http://www.cup.cani.ac.uk/Scripts/webbook.asp?isbn=0521639204
, ,
http://www.cup.cam.ac.uk/Scripts/webbook.asp7isbn~0521630789
5
MATLAB'a

MATLAB : matrix laboratory -


. MATLAB ,
LINPACK EISPACK,
-
. MATLAB -
( -) C++,
().
MATLAB'a .
, web--

http://www.mathworks.com/

-
LAPACK EISPACK,
http://www.netlib.org/Iapack/

, MATLAB,

http://www.ius.cs.cmu.edu/help/Math/vasc-help-matlab.html
http://www.unm.edu/cirt/info/software/apps/matlab.html

, -
MATLAB'y , -

http://www-math.cc.utexas.edu/math/Matlab/Matlab.html
http://www.liv.ac.uk/pollol/karen/document/486.dir/486.html
http://www.indiana.edu/~statmath/smdoc/Matlab.html
http://classes.cec.wustl.edu/~cslOO/lab5/
MATLAB'a 329

MATLAB'a -
:
http://wwwcache.rrz.uni-hamburg.de/RRZ/software/math/
Matlab/
ftp://ftp.math.ufl.edu/pub/matlab/
; ,
- :
ftp://ftp.cc.tut.fi/pub/math/piche/numanal/
ftp://ftp.mathworks.com/pub/mathworks/toolbox/matlab/
sparfun/

' FAQ (frequently asked questions - -
):
http://www.mathworks.com/digest/digest.htrnl
http://www.mathworks.com/newsletter/nn.html
http://www.math.ufl.edu/help/matlab-faq.htrnl
http://ftp.mathworks.com/support/faq/faq.shtml
http://www.uni-karlsruhe.de/~MATLAB/FAQ.html

1. . Abelson and A.diSessa, Turtle Geometry, Cambridge, Mass: MIT


Press, 1981.
2. J. W. Bruce, P. J. Giblin and P.J.Rippon, Microcomputers and
Mathematics, Cambridge: Cambridge University Press, 1990.
3. P. Doucet and P. B. Sloep, Mathematical Modelling in the Life Sciences,
Chichester; Ellis Horwood, 1992.
4. I. S.Duff, A.M.Erisman and J.K.Reid, Direct Methods for Sparse
Matrices, Oxford: Clarendon Press, 1986.
5. G.Fischer, Mathematical Models, Braunschweig: Friedrich Vieweg Sohn,
1986 (Commentary volume, p.53.)
6. M.Gardner, Mathematical Carnival, Washington DC: Mathematical
Association of America, 1989.
7. P. J. Giblin, Primes and Programming, Cambridge: Cambridge University
Press, 1993.
8. L. M. Hall, "Trochoids, roses, and thornsbeyond the spirograph', College
Mathematics Journal 23 (1992), 20-35.
9. L. Haws and T. Riser, 'Exploring the brachistochrone problem', American
Mathematical Monthly 102 (1995), 328-336.
10. F. C. Hoppensteadt, Mathematical Theories of Populations:
Demographics, Genetics and Epidemics, Philadelphia: Society for
Industrial and Applied Mathematics, 1975.
11. J. F. Humphreys and M.Y.Prest, Numbers, Groups and Codes,
Cambridge: Cambridge University Press, 1989.
12. N. Koblitz, A Course in Number Theory and Cryptography, New York:
Springer-Verlag, 1987.
13. J. C. Lagarias, 'The + l problem and its generalizations', American
Mathematical Monthly 92 (1985), 3-23.
14. H.-O.Peitgen and P. H- Richter, The Beauty of Fractals : Images of
Complex Dynamical Systems, Berlin: Springer-Verlag, 1986. (
: .-., .. .
. .: , 1993.)
331

15. Y. Saad, Iterative Solution for Sparse Linear Systems, Boston: PWS Int.
Thompson Pub. (ITP), 1996.
16. A.C.Thompson, 'Odd magic powers', American Mathematical Monthly
101 (1994), 339-342.
17. . . , . .: ,
1986. ( : V- M.Tikhomirov, Stories About Maxima
and Minima, Washington DC: Mathematical Association of America,
1990.)

MATLAB'y

1. . MATLAB 5.2.
Windows..: , 1999, 288 .
2. . ., . . MATLAB 5.
. .: , 1999, 633 .
3. . . MATLAB: . .: , 2001, 560 .
4. .. MATLAB 5.x. . . BHV, 2000, 384 . (-
.)
5. .., . . Matlab 5.x. . .
. .: -, 2000, 332 .
6. . , . . Control System Toolbox. MATLAB 5
. .: -, 1997, 287 .
7. .. MATLAB.-M.: -, 2000,
350 .
8. .. MATLAB 5.x. 2-
. .: -, 1999, 366 . + 304 .
9. .. MATLAB. . .:
-, 1997, 350 .
10. . ., .. .
MATLAB 5. - . : -, 2000, 413 . (
.)

-- (function - goatfn 64
M-file) 25 - goatgr 64
- (M-files) 21 - hail 46, 52
- 96 - hypocy 69
- chop 238 - hypocy 133
- cnrl 188 - intdemol 252
- cnr2 189 - intdemo2 258
- cobm 169 - lagsum 297
- cobq 179, 182 - leslie 39, 287
- colddat 297 - lin_solv 238
- cont4 225, 260 - linenv 66, 137
- cont7 263, 264 - lmfish 287, 291
- cubics 68 - locmax 312
- cycles 196 - Iu2 238
- dfeqfn 113 - Iu3 238
- diffeqn 113 - Iu4 238, 248
- exprand 96, 278 - matit2 174, 176
- Lrate 221, 228 - matit3 174
- fftdemo 311 - miller 130
- fibno 45, 52 - mobius 166, 168, 174
- fishdat 287 - mobiusl 166, 174
- fishy 287 - mparft 287, 290, 297
- fludat 296 - mparst3 297
- fodesol 106, 287 - mparst4 287, 290
- fouran 312 - normrand 94, 278
- fourdat 312 - paramc 138
- fourier 311 - parnorm 65
- foursig 312 - perdoub 180
- fsnowO 304 - plagdat 296
- fsnowl 304 - polyex 63
- fsnow2 304 - polyfit2 263
- fulLnew 215, 223 - polyval2 263
- gaussja 216, 224 - pow 50, 53, 56
- gcdiv 49 - primes 126, 128
- gcdran 124 - psp2 129
334

- quadn 179 - (arithmetic


- queue 284, 286 basic operations) 15
- randrae 101
- remm 206 (database) 77
, (bits
- resid3 297
calculation of) 56
- resid4 288
(notepad) 22
- rifflel 205

- rifflela 205
(brachistochrone) 156
- rifflelc 209
(ruffle) 209
-rufflel 211
-rufflelc211
-ruffle2 211 -
- sirepi 297 (vector representing
- sirfn 297 polynomial) 57
- slidel 159 (vectors) 18, 30, 44
- slidelfn 159 - (vectors column) 19
- snowboat 304 - (vectors row) 19
- snowbtfn 304 (probability) 90,
- snowmn 304 124
- snowmx 304
- snowsl 304 (coprime) 124-126
- solv6 241 (rotation) 149
- spar_ex 244
- species 109 (inter-arrival time) 277
- tides 312 - (arrival
- topog 304 time) 96
- tsine 61 - (waiting time) 277
- tsine2 61 - (arrival time) 277
- unirand 94, 278 (cusp) 70, 145, 155
- vderpol 111
- vdplfn 111 (hypocycloid) 69,
- zzl 149 73
(global
(Euclid's variable) 159
algorithm) 47 (graph) 244
- (edge) 243
(perturbation analysis) - (connectivi-
240 ties) 243
- (data analysis) 74 - (graph node) 243
- (Fourier analysis) 314 (plot) 20
(arithmetic) 15 - - (3D line) 261
335

- (contour) 260 - (linear


- (surface) 259 and cubic) 254
- (subplot) 261 - (interpolation
- (grain plot) spline) 255
107
- (plot sliced) 261 (iterative refinement)
- (graph 239
annotation) 263

(garage door) 139 (tangents parallel) 140
(Wankel
engine) 140 (quadratic functional) 89
(division
element-by-element) 40 (quadratic equation) 188
(kinetic
(digits significant) 237 energy) 157
(commands
(differential equations) repeating) 17
105 MATLAB'a
- (autonomous) 108 - \ 223
- (higher - abs 36
order) - acos 31, 65
- (ordinary) 270 - angle 36
- (first order) - axis 59, 68
107, 108 - axis('equal') 60
- (coupled) 304, 308 - axis ('square') 60
- - axis(axis) 61
(coupled first order) 296 - bar 46, 76, 287
- ceil 92
(goat problem)
64, 69, 72 - clear 26
- comparison ( = = ) 47
(integral) 158 - cond 240
- (improper) 158 - condest 240
- (Fourier) 313 - conj 36
- contour 304
- cumsum 75
(inter-arrival - det 32
time) 96 - diag 33
(iterations) 214, 221 - diary 26
- ID (interpolation ID) 249 - eig 35, 287
- 2D (interpolation 2D) 257 - exp 29
336

- fft 311 - polyval 58, 63, 69, 81, 250


-fix 92 - prod 75
- floor 48, 92 - quad8 158, 159
- flops 235 - rand 55, 90, 91, 94, 95, 101,241
-fauns 161,304 - randn 94, 95, 103
- for 44, 45 - randperm 92, 195, 197
- format 16, 31, 266 - real 36
- fprintf 99 - rem 46, 48, 50, 55, 206
- fsolve 163, 232 - roots 69, 179, 180
- fzero 65, 301 - round 92
- get 261 -rref 34, 119, 236
- gplot 244 - rrefmovie 236
- help 21, 24 - save 27
- hist 76, 196 - set 250, 261
-hold 20, 21,58, 62, 265 - sin 16
-135 - slice 261
- if...else 46 - sort 75, 195, 203, 286
- ifft 311 - sparse 243
- iraag 36 - speye 243
- Inf 168 - spline 311
- input 293 - sprintf 244
- interpl 255 - spy 242
- interp2 264 - sqrt 30, 36, 266
- inv 32 - std 75
- length 59 - sum 30, 75
- load 28 - surf 259
- magic 118 - symrcm 242
- max 46, 75, 311 - tic 235
- mean 75, 311 - title 20
- median 75 - toe 235
- mesh 259, 304 - type 23
- meshdom 226 - view 259, 263
- meshgrid 226, 259 - what 24
- min 75 - while 45, 49, 246
- nnz 286 - who 18
- norm 31, 257, 266 - whos 18
- ones 33 - xlabel 20
-pi 16 - ylabel 20
- plot 20, 58, 59, 76, 217 -
- plot3 261 (arithmetic operations)
- polyfit 63, 69, 80 318
33"

- (graph - (rose) 133


operations) 319 - (normal) 65
- - (parabola) 65, 158
(function operations) 319 - (parametric)
- (matrix 60
operations) 318 - (constant
- (matrix width) 140
functions) 319 - (sine) 61, 64
(shell) 28 - (spirograph) 69,
- 153
/ - (cycloid) 156
(load and save - (ellipse) 154
operations) 320 - (epicycloid)
- (basic 135, 154
operations) 317 (cubic
- equation) 68, 191
(common functions) 318 - (double root)
- 68
(statistics operations)
(ladder) 138
320
(zigzag) 147
- (semicolons) (line broken) 160
47
(complex (magic
numbers) 35, 187 square) 118
- {argument 36 -
- (real (pandiagonal) 120, 123
part) 36 - (product of) 121
- (imaginary
part) 36 (scale with two
- (modulus) 36 curves) 61
- (distance) 188 - axis
- (conjugate) 36 (scale change by axis
(pedal command) 60
construction) 141 - (scale freezing) 61
(curve) 57 (matrix) 31
- (hypocycloid) - (Leslie) 37, 288, 291
69, 73, 133 -
- (plotting) 59 (reduced echelon form)
- (square 119
root) 164 - (rotation) 149

22-4196
338

- (diagonal) 33
- (identity) 32 (greatest common
- (matrix divisor) 47, 124, 131
magic square) 118 - (three numbers) 54,
- (nonsingular) 126
35
- (inverse) 32 (least common multiple)
- (determinant) 32 151, 197
- (permutation) (nonlinear
122 systems) 221
- (sparse) 242, 243 - (equations) 214
- (augmented) 33 (fixed
- (echelon point) 177
form) 34 -
- (multiplication) 32 (CauchySchwarz
inequality) 87
(GaussJacobi) 216 - (proof) 87
- (normal to a
(NewtonRaphson curve) 65
method) 186, 215, 222 (zero vector)
- (divergent) 191 262
- (complex) 187
- (Gauss (basin of
elimination method) 236 attraction) 188, 189, 191
- - (convergence
(least squares method) region) 218
252
- ID (least squares method ID)
252 (disjoint cycle
- 2D (least squares method 2D) notation) 195
263 (envelope) 65, 71,
(Fourier 135, 137, 139, 141
methods) 313
(minimisation) 87 () (floating point
(minimum) 87 operations (flops)) 234
- (function) 161 (determinant) 32
(remainder) 46
(polygon regular) 150 - (when
(data set) 74 numbers are large) 50, 53
- (Mandelbrot (residual
set) 192 correction) 239
339

, (hole, -
square) 140 (NewtonRaphson) 187
(queue) 275 - (quadratic)
, 169, 178, 182, 185
(errors - (basin of
undefined variable) 17 attraction) 188, 189, 191
- (periodic)
(parabola) 158 167, 175, 182
-
(cobweb diagram) 169, (attracting cycle)
175, 180, 182 178,183
(permutation) 92, -
122, 195, 200 (superattracting
- (position) 201, 203 cycle) 182
- - (wildly
(disjoint cycles) 195, 209 divergent) 167
- (order of) 205 - (convergent) 174,
- (transposition) 180,182
195 - (period
- (cyclic) 208 doubling) 180
- (number of - (wildly divergent)
cycles) 198 182
-
(permutation matrix) (exponential) 183
243 (plotting)
20
(perpendicular bisector)
137 (potential energy) 157
(print) 28 (approxima-
(polynomial) 57, 250 tion) 249
- n (in n - (error) 256
dimensions) 257 -
- (roots) 57, 68 (least squares
- (Taylor) 61 fitting) 78, 290, 301
(population) 176 - (least squares
(order) 205 method proof of) 88
- (convergence) - (least squares
217, 228 fitting nonlinear) 82
- (least squares
(sequence Mobius) 166, fitting formulae
169, 174, 185 derivations) 87

22'
340

- (polynomial (random pairs)


function fitting) 80 124
(tides) 311, 312 - (variable) 102
- (distribu-
(derivative partial) 308, tions) 96
309 - (triples) 126
(prime) 126, 128 - (integers) 92
(Poisson - (numbers) 90
process) 103 (eigen-
value) 35, 121, 173, 176,
(pseudoprime) 52, 128 243

(eigenvector) 35, 121,
(difference 173, 176
equations second order) (congruence) 131
113 (querying) 77
- (first order) (resistance) 306
111 (sorting) 76
(sparse (saving
matrix) 242 work) 26
- (graph) 244 (spirograph) 69, 153
(printing) 28
(root mean square error)
(distribution normal) 94 256, 265
- (uniform) 91, 277 (statistics) 75
- (random) 277 (matrix
- powers) 171
(exponential) 95, 277 (power
(edit a algorithm) 50, 53, 55,
file) 22 129
(fish) 288 (Fourier sum) 313
- (catching) 292
- (growth) 288 (event table)
(Taylor 280
polynomial) 222 (shuffle) 201
- (ruffle) 209
(gravity) 157 - (riffle) 201
(sliding - (in) 203, 207, 208, 213
bead) 157 -
- (script) 21, 23 (for odd pack) 207
(trace) 123 - (out) 205, 207, 209, 213
341

- (order of) 205 (files


- (shuffle cut) edit) 22
202, 207, 213 - (save) 22
(Ferraat's
theorem) 50, 128 (fractal set) 193
(Miller's test) 51,
130 (multiple variables) 82
(transposition) - (distribution
195 function) 102
(transpose) (functional) 89
19
(friction) 165, 306 (cycloid) 156, 162
(echelon ,
form) 119, 236 (digits using
power algorithm) 53
(period
doubling) 180
(partial
(multiplication element- pivoting) 236
by-element) 19, 30 (Fibonacci
- numbers) 44, 52
(scalar product) 30 (Carmichael
(equations number) 52
of motion) 306 (width) 140
(phase (epidemics) 296
plane) 108 - SIR- (epidemics SIR
- (fixed model) 297
point) 109 (epicycloid)
- (orbit) 109 154
- (limit cycle)
111 , (boxes,
- {saddle point) unlocking) 200
109

5
9
I. ' 13
1. 15
1.1. MATLAB'e 15
1.2. 18
1.3. - 21
1.4. 28
28
2. 30
2.1. 30
2.2. 35
2.3. : 37
40
3. 44
3.1. 44
3.2. : + 1 46
3.3. -
47
3.4. 49
52
3.5. 55
4. 57
4.1. 57
4.2. 58
4.3. 61
4.4. polyfit 62
4.5. 64
4.6. 65
68
4.7. 72
5. 74
5.1. 74
343

5.2. ... 78
85
5.3. 87
6. 90
6.1. 90
6.2. 92
6.3. 94
6.4. 94
6.5. . 95
98
6.6. 100
7. 105
7.1.
() 105
7.2. 108
7.3. 111
113
. 115
8. 117
8.1. 118
8.2. 3 3 118
8.3. 4 4 121
8.4. 5 x 5 (-
) 123
9. , 124
A. 124
B. 128
10. : 133
A. 133
B. 136
C. 139
11. 147
A. 147
B. 156
12. 166
12.1. 166
12.2. 168
12.3. 171
. 174
344

B. 177
C. -
; 181
13. - 186
13.1. 186
13.2. z2 + 1 = 0 187
13.3. 188
13.4. z3 z = 0 191
14. 194
A. 194
B. 200
14.1. 201
14.2. 203
14.3. 209
14.4. ( ) .. 209
14.5. 212
15. -
214
15.1. I D : 1 215
15.2. I D : 2 216
15.3. I D : 217
15.4. 2D: 221
15.5. 2D: -
225
229
16. 233
16.1. 234
16.2. 235
16.3. 239
16.4. 240
16.5. , -
242
245
17. 249
17.1. I D : 250
17.2. ID-: - intdemol.m 252
17.3. ID- 252
17.4. ? 256
17.5. 257
17.6. 2D - intdemo2.m 258
345

17.7. , - -
258
17.8. '\'- 263
17.9. 264
17.10. 264
266
18. 270
18.1. 270
271
III. 273
19. : 275
19.1. 276
19.2. 280
19.3. 283
284
20. 287
20.1. 288
20.2. 288
20.3. 291
20.4. 293
294
21. 296
21.1. . 297
21.2. SIR- 298
21.3. 299
21.4. 301
302
22. 304
22.1. 305
22.2. 306
22.3. 308
309
23. 311
23.1. 312
23.2. 312
23.3. 314
23.4. - 315
315
346

1. MATLAB'a 317
317
317
318
318
318
319
319
319
/ 320
2. MATLAB'e 321

4 321
7 321
11 322
16 322
3. - 323
1: 323
2: 324
3: 325
4. - 327
5. MATLAB'a . 328
330
MATLAB'y
332
333

, ,
MATLAB

. . .
. . . .
. .
.
. .
. .
. .
- . .
1 2
LH

010174 20.05.97 .
12.04.2001 . 60 90/16.
Computer Modern. .
11,00 . . .-. . 22,00. .-. . 19,23.
. 1/9722. 5 000 . 4196.

,

107996, , 1- ., 2.




.
143200, . , . , 93.

:
., .

MATLAB'A : . . 55 ., .
3 -
. .

MATLAB . -
,
, , , -
. -
.

1/1 -
. -
3
,

:



2 -






:
MATLAB'a


, -
, , -
p a -
&
.
-

2001 .:
. ., .-., . -
C++:
- - -q
: . 2- . .624 , . -D

a
,
- .

, -
, -
,
(REDUCE, MAPLE, AXIOM, -
1, MuPAD). -
- , Java, Eiffel,
in
Smalltalk , C++, -
SymbolicC++. r-J
- (-1 00
( , , , 4

, .).
, -
- '
.

:


-
C++





-
12


Gnuplot PostScript
,
-
, ,
.

:
, ., '. ,
.
-
)
: . . 687 , .

-
-

. -
-
, .
-
-
, -
.

:
,
3
-? g

-


-

1
5

s l i
-, -
| ,
lei .
-

2001 .:
. :
. . 288 , .
-

. -
- -
- .


,
... in
-
:
, - .

, i .
...

-
-
-? S
^


-
- -.
,
. -
-
.
- 1
, l a g
, .
,
.
MATLAB,
?
MATLAB
?


?
- MATLAB?

MATLAB


The MATLAB

MATH
MATLAB.
WORKS
MATLAB .
Inc.
.
MATLAB .

MATLAB.
www.matlab.ru,
MATLAB.

MATLAB
!
www.matlab.ru info@matlab.ru
w w w . s o f t l i n e . r u .: (095) 232-0023