Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://uneex.mithril.cs.msu.su/static/AltDocs_ScilabBook/main.pdf
Äàòà èçìåíåíèÿ: Mon Sep 26 12:35:54 2011
Äàòà èíäåêñèðîâàíèÿ: Mon Oct 1 23:10:36 2012
Êîäèðîâêà: IBM-866

Ïîèñêîâûå ñëîâà: î íí
:

ALT Linux

Scilab

. . , . . , . .

ALT Linux; . 2008


004.67 22.1 47 . . Scilab: / . . , . . , . . . . : ALT Linux ; . , 2008. 260 . : . ; 8 . . . ( ALT Linux).

47

ISBN 978-5-94774-890-1 Scilab. ( ), . ( , , , , : , , , ). Live CD ALTLinux 4.0 Junior, Scilab 4.1.1. : http://books.altlinux.ru/altlibrary/scilab . 004.67 22.1 : . (499) 157-52-72. E-mail: binom@Lbz.ru http://www.Lbz.ru
, , GNU FDL. , : " ALT Linux" . : Scilab: . . . ALT Linux ALT Linux. Linux . .

c c c

ISBN 978-5-94774-890-1

ALT Linu .

. ., . ., . ., 2008 x, 2008 , 2008




1.1 1.2 1.3 2.1 2.2 2.3 2.4 2.5 2.6 1. Scilab. Scilab . . . . . . . . . . . . . . . . . . . . . . . . Scilab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scilab . . . . . . . . . . . . . . 2. Scilab . . . . . . . . . . Scilab . . . . . . . . . . . . . Scilab . . . . . . . . . . . . . . . . . . . . . . . . Scilab . . . . . . . . . . . . . .

6 8 9 11 12 16 16 16 17 19 20 22

. . . .

. . . . .. ..

...... ...... ...... ...... ...... ......

. . . .

. . . .

. . . .

. . . .

. . . .

..... .....

3. 3.1 3.2 3.3 3.4 3.5 4.1 4.2 4.3 4.4 4.5 4.6

Scilab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

27 28 32 34 52 53 56 56 59 62 65 67 73

4. plot . . . . . . plot2d . . . .

..................... ..................... plot . . . . . . plot2d . . . .

.. . . .. .. ..

. . . . . .


4 4.7 4.8 4.9 4.10 4.11 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 6.1 6.2 6.3 7.1 7.2 7.3 7.4 7.5 . . ...... . . . . . . . . . . . . . . . , .................. . . . . . . . . . . . ..... ..... ..... ..... ..... ..... ..... .. .. .. .. .. .. .. . . . Scilab .... .... .... .... .... .... .... SCI .. .. .. . . . . . . . . . .

... ... ... ... ... .. .. .. .. .. 79 80 81 83 85 109 109 115 118 122 125 129 131 132 138 138 143 147 149 149 151 152 152 154 156 163 164 171 177 182 184 187 187 190

5. plot3d plot3d1 . . . . meshgrid, surf mesh . plot3d2 plot3d3 . . . param3d param3d1 . contour . . . . . . . . . contourf . . . . . . . . hist3d . . . . . . . . . 6. . . . . . . . . . . . .

.. .. .. .. .. .. ..

. . . . . . .

. . . . . . . S

.. .. .. .. .. .. .. cilab

. . . . . . .

. . . . . . . .

...... ...... ......

LA .. .. ..

B ........ ........ ........

7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . , . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

... ... ... ... ...

8. 9.1 9.2 9.3 9.4 9.5



9. Scilab sci- . . . . . Scilab Scilab . . . . . . . Scilab . . . . . . Scilab . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

10. 10.1 . . . . . . . . . 10.2 . . . . . . . . . . . . . . .

Scilab ........... . ...........


11. 11.1 . . . . . . . . . . . . . . . . . . . . 11.2 . . . . . . . . . . . . . . . . . . . . . . . . 12. 12.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.2 . . . . . . . . . . . . . . . . 12.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1 13.2 13.3 14.1 14.2 14.3 14.4 14.5 14.6

5 204 204 209 213 .. .. .. .. 213 215 227 229 234 234 237 238 245 245 248 249 250 252 255 256 258 259

13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14. Scilab Scilab . . . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . .






, . Scilab. Scilab . Scilab Mathcad, MATLAB. Scilab , . Scilab : Linux, Windows ( MS Windows Vista) MacOS. 4.1.1. . www.scilab.org. , Scilab. , . . , Scilab: § http://scilab.land.ru, http://teacher.dn- ua.com, x odt 1 pdf . § . . http://www.csa.ru/~zebra/my_scilab/index.html, , , . Scilab http://www.scilab.org/publications/index_ publications.php?page=books.html. Scilab , .
1 odt Open Document, , OpenOffice.org (http://ru.openoffice.org).




7

Scilab. . Scilab. , , Scilab 4.1.1 . , . Scilab. , . Scilab, Scilab . Scilab. , , . . . Scilab. , . Scilab. Scilab . . . . . , Scilab. , . . , , . CD . ALT Linux , Scilab. . . , . . , . . , , 2007


1 Scilab.

Scilab , , : § ; § ; § ; § ; § ( , ); § . , Scilab . , Scilab , , . , . , , .


1.1. Scilab

9

1.1

Scilab

www.scilab.org. Scilab Windows Linux. , .

1 .1 .1

Scilab Windows

Windows. , Scilab-4.1.1 , , . ( ) OK . . , Scilab 4.1.1 . Next. (I accept the agreement) Next . . C:\Program Files\scilab-4.1.1 . Browse. . . . , , . Next , . 1.1. : § (Installation Default); § (Full installation); § (Compact installation); § (Custom installation). , . Next. , , Scilab. scilab-4.1.1. Browse. . . .


10

1. Scilab.

. 1.1. Scilab

Next , , . Next. . Install . Scilab . . . Next , Launch scilab. , Scilab Finish, ( í í scilab-4.1.1 ) (. 1.2).

. 1.2. Scilab


1.2. Scilab

11

1 .1 .2

Scilab Linux

Scilab , ALT Linux 4.0 Mandrivia 2007. Debian Ubuntu. Linux Scilab http://www.scilab.org, ( /usr/lib ) , Scilab root, make . /usr/lib/Scilab 4/bin/scilab .

1.2

Scilab

Scilab . , . , , -->, () . . Scilab . Enter (. 1.3).

. 1.3. Scilab , . , , , , , Page Up, Page Down. , Scilab .


12

1. Scilab.

, . , , , . . , , . , . , , , , . . : ; ; Home ; End ; Del ; Backspace . , . ; , . , ; , ( 1.1). 1.1. Scilab -->2.7*3+3.14/2 ans = 9.67 -->2.7*3+3.14/2; --> , Scilab, , , . , , , . , , .

1.3

Scilab

, , , . , , , - Scilab, .


1.3. Scilab

13

1 .3 .1



File . 1 : § New Scilab ; Scilab,

§ Exec. . . Scilab- ( sce sci ); § Open , ; § Load , ; ; § Save sav bin ; § Change Directory , ; § Get Change Directory ; § Print Setup. . . § Print § Exit -

;

; Scilab.

1 .3 .2



Edit : § Select All § Copy § Paste § History . ;

; ; ;

§ Empty Clipboard

,

1 Windows, Linux File í File Operations.


14

1. Scilab.

1 .3 .3



Preferences : § Language (, ); § Colors (Text), (Background ) , (Default System Colors ); § Toolbar (F3) § Choose Font ); § Clear History § Consol (F12) ; ;

§ Files Association

(, , ; ;

§ Clear Command Window (F2)

.

1 .3 .4



? Scilab. , , , , . Scilab Demos .

1 .3 .5

-

- Scilab, . , - SciPad, , Editor. -. Untitled1.sce . - , .. , , , . - , Scilab. . 1.4 3x2 + 5x + 4 = 0. , ; , . File í Save . , Save file As. . . . File Name Save


1.3. Scilab

15

. 1.4. - Scilab

, . .sce . File í Open. - : § SciPad Execute í Load into Scilab; § Scilab Exec . - (. 1.4). , SciPad ( Windows ), ( Edit) ( Search). , SciPad ( Options ), ( Help ) , ( Debug ). , SciPad File í Exit.


2 Scilab

2.1



Scilab , //. , -. // , Enter : 2.1. -->//6+8 -->

2.2



Scilab : + , - , * , / , \ , ^ . , Enter. : 2.2. --> 2.35*(1.8-0.25)+1.34^2/3.12 ans = 4.2180


2.3. Scilab

17

, Enter . : 2.3. , --> 1+2+3+4+5+6.... 7+8+9+10+.... +11+12+13+14+15 ans = 120 ; , , : 2.4. ; --> 1+2; --> 1+2 ans = 3

2.3

Scilab

Scilab , . . , = . , . .., _ = _ , , , . , 24 . . .. ABC, abc, Abc, aBc . , , . , . ; , . ;


18

2. Scilab

. : 2.5. -->//------------------------------------------------->// b --> a=2.3 a= 2.3000 --> b=-34.7 b= -34.7000 -->// x y, -->// z --> x=1;y=2; z=(x+y)-a/b z= 3.0663 -->// í --> c+3/2 ??? Undefined function or variable 'c'. -->//------------------------------------------------->// --> c='a' c= a -->// --> h=' ' h = clear _; . : 2.6. clear -->// x y --> x=3; y=-1; -->// x --> clear x -->// x --> x ??? Undefined function or variable 'x'.


2.4. Scilab -->// y --> y y= -1 -->// a b -->a=1;b=2; -->// a b -->clear; -->// a b -->a !--error 4 undefined variable : a -->b !--error 4 undefined variable : b

19

2.4

Scilab

, ans. , , ans : 2.7. ans --> 25.7-3.14 ans = 22.5600 --> // 22.5600 --> 2*ans ans = 45.1200 --> // --> x=ans^0.3 x= 3.1355 --> ans ans = 45.1200 --> // --> // 45.1200 ans. Scilab %:


20 %i %pi %e %inf %NaN %eps ( -1); = 3.141592653589793; e = 2.7182818; ();

2. Scilab

(0/0,/ . .); %eps=2.220-16.

: 2.8. -->a=5.4;b=0.1; -->F=cos(%pi/3)+(a-b)*%e^2 F= 39.661997 : 2.9. %pi -->sin(pi/2) !--error 4 undefined variable : pi

2.5



(, í3.2-6, í6.42+2) (, 4.12, 6.05, í17.5489) . mE‘p, m ( ), p ( ). , , . , -6.42+2 = -6.42 § 102 = -642 3.2E-6 = 3.2 § 10-6 = 0.0000032

. :


2.5. 2.10. -->0.123 ans = 0.123 -->-6.42e+2 ans = - 642. -->3.2e-6 ans = 0.0000032

21

q , : 2.11. -->%pi %pi = 3.1415927 -->q=0123.4567890123456 q= 123.45679 , Scilab . . , , printf , , : 2.12. printf -->printf("%1.12f",%pi) 3.141592653590 -->printf("%1.15f",%pi) 3.141592653589793 -->printf("%1.2f",q) 123.46 -->printf("%1.10f",q) 123.4567890123 -->// 6 -->printf("%f",q) 123.456789


22

2. Scilab

2.6

Scilab

, Scilab, : § ; § . Scilab : _ = _(1 [,2, ...]) _ , ; , , , ans; _ ; .

1, 2, ...

2 .6 .1



Scilab , . , (. 2.1). 2.1. sin(x) x cos(x) x tan(x) x cotg(x) x asin(x) x acos(x) x atan(x) x exp(x) x log(x) x sqrt(x) x abs(x) x log10(x) x log2(x) x


2.6. Scilab x y

23

z =

sin

§ ex :

y

2.13. -->x=1.2;y=0.3; -->z=sqrt(abs(sin(x/y)))*exp(x^y) z= 2.5015073

2 .6 .2

,

- , . , .. , . , , , . Scilab. deff, : deff('[1,...,N] = _(_1,...,_M)', '1=1;...;N=N') 1,...,N , , , _ , .

_1,...,_M

deff. , z= sin x y § ex ( y

2.13): 2.14. deff -->deff('z=fun1(x,y)','z=sqrt(abs(sin(x/y)))*exp(x^y)'); -->x=1.2;y=0.3;z=fun1(x,y) z = 2.5015073


24

2. Scilab

, a, b c S= p § (p - a) § (p - b) § (p - c) , p = a+b+c . 2

2.15. , -->deff('S=G(a,b,c)','p=(a+b+c)/2;S=sqrt((p-a)*(p-b)*(p-c))'); -->G(2,3,3) ans = 1.4142136 , -b ‘ D 2 2 ax + bx + c = 0 D = b - 4ac; x1,2 = a: 2 2.16. -->deff('[x1,x2]=korni(a,b,c)','d=b^2-4*a*c; x1=(-b+sqrt(d))/2/a;x2=(-b-sqrt(d))/2/a'); -->[x1,x2]=korni(-2,-3,5) x2 = 1. x1 = 2.5 : function[1,...,N]=_(_1,...,_M) endfunction 1,...,N , , ; _ , _1, ...,_M . , , .. . , Scilab . . . - sci sce . , , .. . , , , , exec(_) File í Exec. . . , , , .


2.6. Scilab . 2.1. . ax3 + bx2 + cx + d = 0 a : x3 + rx2 + sx + t = 0 , c b , s= , a a (2.2) r= x=y- t= d . a

25

(2.1)

(2.2)

r 3 : y 3 + py + q = 0 , (3s - r2 3 p3 q3 D = + 3 2 p= ) (2.3)

r3 rs - + t. 27 3 (2.3) , q=2 (. 2.2).

2.2. 1 3 2 í

D0 D<0

: y1 = u + v , -q -q v= 3 + (D), - (D) . 2 2 , : u=
3

y2 =

-(u + v ) (u - v ) + i 3, 2 2

y3 =

-(u + v ) (u - v ) - i 3 . (2.4) 2 2


26

2. Scilab 2.17. function [x1,x2,x3]=cub(a,b,c,d) r=b/a; s=c/a; t=d/a; p=(3*s-r^2)/3; q=2*r^3/27-r*s/3+t; D=(p/3)^3+(q/2)^2; u=(-q/2+sqrt(D))^(1/3); v=(-q/2-sqrt(D))^(1/3); y1=u+v; y2=-(u+v)/2+(u-v)/2*%i*sqrt(3); y3=-(u+v)/2-(u-v)/2*%i*sqrt(3); x1=y1-r/3; x2=y2-r/3; x3=y3-r/3; endfunction // : -->exec('C:\Scilab\scilab-4.1.1\cub.sce'); -->disp('exec done'); Warning :redefining function: cub exec done -->[x1,x2,x3]=cub(3,-20,-3,4) x3 = 0.3880206 x2 = - 0.5064407 x1 = 6.7850868


3 Scilab.

. , . , . , , . , . , , , . , , , . , , (). , , : , , . Scilab . .


28

3. Scilab.

3.1



Scilab : name=Xn:dX:Xk name , , Xn , Xk , dX , , .. Xn+dX, Xn+ dX+dX Xk. dX , , , , .. : name=Xn:Xk , , . : 3.1. --> Xn=-3.5;dX=1.5;Xk=4.5; --> X=Xn:dX:Xk X= -3.5000 -2.0000 -0.5000 1.0000 2.5000 4.0000 --> Y=sin(X/2) Y= -0.9840 -0.8415 -0.2474 0.4794 0.9490 0.9093 --> A=0:5 A= 012345 --> 0:5 ans = 0 1 2345 --> ans/2+%pi ans = 3.1416 3.6416 4.1416 4.6416 5.1416 5.6416 . , Scilab

- , , , : name=[x1, x2, ..., xn]

name=[x1 x2 ... xn]


3.1. -: 3.2. - --> V=[1 2 3 4 5] V= 12345 --> W=[1.1,2.3,-0.1,5.88] W= 1.1000 2.3000 -0.1000 5.8800 - : name=[x1; x2; ...; xn] -: 3.3. - --> X=[1;2;3] X= 1 2 3

29

, : name() : 3.4. --> W=[1.1,2.3,-0.1,5.88]; --> W(1)+2*W(3) ans = 0.9000 , , : name=[x11, x12, ..., x1n; x21, x22, ..., x2n; ...; xm1, xm2, ..., xmn;] , , , : name(1, 2)


30

3. Scilab. : 3.5. --> A=[1 2 3;4 5 6;7 8 9] A= 1 2 3 4 5 6 7 8 9 --> A(1,2)^A(2,2)/A(3,3) ans = 3.5556

, , : 3.6. --> v1=[1 2 3]; v2=[4 5 6]; v3=[7 8 9]; --> // -: --> V=[v1 v2 v3] V=123456789 -->// -, -->// : --> V=[v1; v2; v3] V= 123 456 789 -->// : --> M=[V V V] M= 123123123 456456456 789789789 -->// : --> M=[V;V] M= 123 456 789 123 456 789


3.1.

31

: . , . : 3.7. : -->// --> A=[5 7 6 5; 7 10 8 7;6 8 10 9;5 7 9 10] --> // --> A(:,2) ans = 7 10 8 7 --> // --> A(3,:) ans = 6 8 10 9 --> // --> M=A(3:4,2:3) M= 8 10 79 --> // --> A(:,2)=[] A= 5 8 10 779 6 10 9 5 9 10 --> // --> A(3,:)=[] A= 5 8 10 779 5 9 10 --> // - --> v=M(:) v= 8 7 10 9 --> // v


32

3. Scilab. --> b=v(2:4) b= 7 10 9 --> // b --> b(2)=[];

3.2



Scilab : + ' * * ^ \ / .* .^ .\ ./ ; 1 ; 2 ; 3 ; ; 4 ; 5 ; 6 ; ; ; ; .

1 , .. () -, - . 2 , . 3 , -, -. , . , . 4 n- n . , . , , . 5 (A\B) (A-1 B), A § X = B, X . 6 (B/A) (B § A-1 ), X § A = B.


3.2. : 3.8. -->A=[1 2 0;-1 3 1;4 -2 5]; -->B=[-1 0 1;2 1 1;3 -1 -1]; -->// (AT+B)2 - 2A(0.5BT-A) -->(A'+B)^2-2*A*(1/2*B'-A) ans = 10. 8. 24. 11. 20. 35. 63. - 30. 68. --> // §= §A=B. -->A=[3 2;4 3]; -->B=[-1 7;3 5]; -->// AX=B: -->X=A\B X= - 9. 11. 13. - 13. -->// XA=B: -->X=B/A X= - 31. 23. - 11. 9. -->// -->X*A-B ans = 0. 0. 0. 0.

33

, , , : 3.9. --> x=[0.1 -2.2 3.14 0 -1]; --> sin(x) ans = 0.0998 -0.8085 0.0016 0 -0.8415


34

3. Scilab.

3.3



Scilab . . : § matrix(A [,n,m]) A ;

3.10. matrix -->D=[1 2;3 4;5 6]; -->matrix(D,2,3) ans = 1. 5. 4. 3. 2. 6. -->matrix(D,3,2) ans = 1. 2. 3. 4. 5. 6. -->matrix(D,1,6) ans = 1. 3. 5. 2. 4. 6. -->matrix(D,6,1) ans = 1. 3. 5. 2. 4. 6. § ones(m,n) m n 1 ; 3.11. ones -->ones(1,3) // - ans = 1. 1. 1. -->ones(2,2) // ans = 1. 1. 1. 1. -->m=3; n=2;
1

ones(n1,n2...,nn) .


3.3. -->X=ones(m,n) // m n X= 1. 1. 1. 1. 1. 1. -->M=[1 2 3;4 5 6] M= 1. 2. 3. 4. 5. 6. -->// Y, , -->// , M -->Y=ones(M) Y= 1. 1. 1. 1. 1. 1. § zeros(m,n) 1 m n 2 ; 3.12. zeros -->zeros(3,2) ans = 0. 0. 0. 0. 0. 0. -->M=[1 2 3 4 5]; -->Z=zeros(M) Z= 0. 0. 0. 0. 0. § eye(m,n) 3 m n ; 3.13. eye -->eye(3,3) ans = 1. 0. 0. 0. 1. 0. 0. 0. 1. -->eye(5,1) ans =

35

. zeros(n1,n2...,nn) . 3 , .
2

1


36

3. Scilab. 1. 0. 0. 0. 0. -->m=3; n=4; -->E=eye(m,n) E= 1. 0. 0. 0. 0. 1. 0. 0. 0. 0. 1. 0. -->M=[0 1;2 3]; -->// E -->// , M -->E=eye(M) E= 1. 0. 0. 1. -->// eye(). -->// -->//, -->// , , . -->M=[1 2;3 4;5 6]; E=eye(); -->A=E+M A= 2. 2. 3. 5. 5. 6. -->M-E ans = 0. 2. 3. 3. 5. 6.

§ rand(n1,n2,...nn[,fl]) . p , ('uniform' , 'normal' ); rand(m,n) m n ; rand(M) , ; rand() ;


3.3. 3.14. rand -->rand(2,2)// 2 2 ans = 0.2113249 0.0002211 0.7560439 0.3303271 --> R=rand(2,2,2)// R(:,:,1) = 0.9355 0.4103 0.9169 0.8936 R(:,:,2) = 0.0579 0.8132 0.3529 0.0099 -->rand()// ans = 0.6653811

37

§ sparse([i1 j1;i2 j2;...;in jn],[n1,n2,...,nn]) 1 . [i1 j1,i2 j2,...,in jn], [n1,n2,...,nn]. , , , . , ; § full(M) ; 3.15. sparse full -->A=sparse([1 3;3 2;3 5],[4,5,6]) A= ( 3, 5) sparse matrix ( 1, 3) 4. ( 3, 2) 5. ( 3, 5) 6. -->full(A) ans = 0. 0. 4. 0. 0. 0. 0. 0. 0. 0. 0. 5. 0. 0. 6.
1



, .


38

3. Scilab. § hypermat(D[,V]) , D , V ( V ); 3.16. hypermat -->// , -->// , -->// - -->// 0 11. -->M=hypermat([2 2 3],0:11) M= (:,:,1) 0. 2. 1. 3. (:,:,2) 4. 6. 5. 7. (:,:,3) 8. 10. 9. 11. § diag(V[,k]) V k- 1 ; diag(A[,k]), A , -, k- ; 3.17. diag --> V=[1,2,3]; --> diag(V)// , V ans = 1 0 0 0 20 0 03 -->// , -->//V ( ) --> diag(V,1) ans = 0 1 0 0 0 020 0 003 0 000 -->// , -->//V ( )
1

, .


3.3. --> diag(V,-1) ans = 0 0 0 0 1 000 0 200 0 030 --> A=[-1 2 0 ;2 1 -1 ;2 1 3] A= -1 2 0 2 1 -1 21 3 --> diag(A) // ans = -1 1 3

39

§ cat(n, A, B, [C, ...]) , n=1 , n=2 ; [A; B] [A, B]; 3.18. cat --> --> ans 12 34 --> ans 12 34 56 78 A=[1 2;3 4]; B=[5 6 ;7 8]; cat(2,A,B)// = 56 78 cat(1,A,B) // =

§ tril(A[,k]) 1 , k- ; 3.19. tril --> A=[1 2 3;4 5 6;7 8 9] A= 123 456
1 , , , .


40

3. Scilab. 789 -->// , --> tril(A) ans = 100 450 789 --> tril(A,0)// tril(A) ans = 100 450 789 --> tril(A,1)// , --> // ( ) ans = 120 456 789 --> tril(A,-2) )// , --> // ( ) ans = 000 000 700 § triu(A[,k]) 1 , k- ; 3.20. triu --> --> ans 12 05 00 --> --> ans 00 00 00 A=[1 2 3;4 5 6;7 8 9]; triu(A)// = 3 6 9 triu(A,2) )// , // ( ) = 3 0 0

1 , , , .


3.3. --> --> ans 12 45 08 triu(A,-1) )// , // ( ) = 3 6 9

41

§ sort(X) X; X ;

, -

3.21. sort -->b=[2 0 1]; sort(b) // ans = 2. 1. 0. -->-sort(-b) // ans = 0. 1. 2. -->A=[1 2 0;-1 3 1;4 -2 5]; -->sort(A) // ans = 5. 2. 0. 4. 1. - 1. 3. 1. - 2. : § size(V[,fl]) V; V , size(V,1) size(V,'r') V, size(V,2) size(V,'c') ; 3.22. size -->M=[1 2;3 4;5 6;7 8]; -->[n,m]=size(M) m= 2. n= 4. -->size(M,1) ans = 4. -->size(M,2) ans = 2.


42

3. Scilab. § length(X) X; X , ; X , ; 3.23. length --> V=[-1 0 3 -2 1 -1 1];//- --> length(V)// ans = 7 -->[1 2 3;4 5 6];// -->length(ans)// ans = 6. § sum(X[,fl]) X, fl. fl , sum(X) , . fl='r' fl=1, , , X. fl='' fl=2, -, X. sum 1 ; 3.24. sum -->M=[1 2 3;4 5 6;7 8 9]; -->Y=sum(M) // Y = 45. -->S1=sum(M,1) // S1 = 12 15 18 -->S2=sum(M,2) // S2 = 6 15 24 --> V=[-1 0 3 -2 1 -1 1]; --> sum(V) // ans = 1 -->// . --> a=[1 2 3];b=[2 0 1]; --> sum(a.*b) ans = 5
1

a § b = a1 b1 + a2 b2 + § § § + an bn .


3.3.

43

§ prod(X[,fl]) X, sum; 3.25. prod -->prod(M) ans = 362880. -->p1=prod(M,1) p1 = 28 80 162 -->p2=prod(M,2) p2 = 6 120 504 --> V=[1,2,3]; --> prod(V) // ans = 6 § max(M[,fl]) M, fl. fl , max(M) M; fl='r', M; fl='', -, M. [x, nom]=max(M[,fl]) x nom; 3.26. max -->M=[5 0 3;2 7 1;0 4 9]; -->max(M) ans = 9. -->max(M,'r') ans = 5. 7. 9. -->max(M,'c') ans = 5. 7. 9. -->[x,nom]=max(M) nom =


44

3. Scilab. 3. = 3.

x 9.

§ min(M[,fl]) M, max; 3.27. min -->A=[5 10 3 2 7 1 25 4 0]; -->[x,nom]=min(A) nom = 7. x= 25. § mean(M[,fl]) M; M , mean(M,1) mean(M,'r') M, mean(M,2) mean(M,'c') ; 3.28. mean -->mean(M) ans = 3.4444444 -->mean(M,1) ans = 2.3333333 -->mean(M,2) ans = 2.6666667 3.3333333 4.3333333 § median(M[,fl]) mean;

3.6666667

4.3333333



1

M,

3.29. median -->M=[5 0 3;2 7 1;0 4 9]; -->median(M) ans = 3. -->median(M,1) ans =
1

, .


3.3. 2. 4. -->median(M,2) ans = 3. 2. 4. § det(M) 3.

45

; 3.30. det

-->M=[1 0 2;3 2 1;0 3 1]; -->det(M) ans = 17. -->Z=[1 2 2;0 1 3;2 4 4]; -->det(Z) ans = 0. § rank(M[,tol]) M1 tol. 3.31. rank -->M=[1 0 2;3 2 1;0 3 1]; -->rank(M) ans = 3. -->Z=[1 2 2;0 1 3;2 4 4]; -->rank(Z) ans = 2. § norm(M[,fl]) ; fl, fl=2. norm(M) norm(M,2) 2 . 3 norm(M,1). norm(M,'inf') norm(M,'fro') 4 5 . V , norm(V,1) V. norm(V,2) V6 . norm(V,'inf') ;
1 2 3 4 5 6

. . . . . .


46

3. Scilab. 3.32. norm -->M=[1 0 2;3 2 1;0 3 1]; -->norm(M,1) ans = 5. -->norm(M,2) ans = 4.5806705 -->norm(M,'inf') ans = 6. -->norm(M,'fro') ans = 5.3851648 -->X=[5 -3 4 -1 2]; -->norm(X,1) ans = 15. -->sum(abs(X))// , norm(X,1) ans = 15. -->norm(X,2) ans = 7.4161985 -->sqrt(sum(X^2)) // , norm(X,2) ans = 7.4161985 -->norm(X,'inf') ans = 5. -->max(abs(X))// , norm(X,'inf') ans = 5.

§ ond(M)

1 ;

3.33. cond -->A=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10]; -->cond(A) ans = 2984.0927

1

.


3.3.

47

, : § spec(M) 1 M. 3.34. spec -->M=[3 -2;-4 1] M= 3. - 2. - 4. 1. -->spec(M) // ans = - 1. 5. // - , --> Y. -->[X,Y]=spec(M) Y= ! - 1. 0! ! 0 5. ! X= ! 0.4472136 - 0.7071068 ! ! 0.8944272 0.7071068 ! § inv(A) , 2 A3 ; 3.35. inv -->// . -->A=[1 2 3 5;0 1 3 2;4 2 1 1;2 3 0 1]; -->inv(A) ans = ! 0.0285714 - 0.1428571 0.3428571 - 0.2 ! ! - 0.1428571 0.2142857 - 0.2142857 0.5 ! ! - 0.2 0.5 0.1 - 0.1 ! ! 0.3714286 - 0.3571429 - 0.0428571 - 0.1 !
1 x, , Ax = Lx, L , A; L . 2 , , , . .. inv(A) . 3 LU-.


48

3. Scilab. -->// , -->// , . -->inv(A)*A ans = 1. - 1.110D-16 0. 0. 0. 1. - 5.551D-17 5.551D-17 0. 0. 1. 1.388D-17 0. 0. 6.939D-17 1. -->// -->//( ) -->// . -->B=[1 2 3;1 4 5;1 6 7]; -->inv(B) !--error 19 Problem is singular § pinv(A[,tol]) 1 A tol ( ); 3.36. pinv -->pinv(A) ans = 0.0285714 - 0.1428571 0.3428571 - 0.2 - 0.1428571 0.2142857 - 0.2142857 0.5 - 0.2 0.5 0.1 - 0.1 0.3714286 - 0.3571429 - 0.0428571 - 0.1 § linsolve(A,b) A § x - b = 0. 3.37. linsolve -->// -->//{x1+2x2-7=0; x1+x2-6=0}. -->// - -->// . -->A=[1 2;1 1];b=[-7;-6]; -->x=linsolve(A,b) x= 5. 1.

1 pinv(A[,tol])= A**=, **=, * A* , . , , tol, .


3.3. -->// A*x+b , -->// , , . -->A*x+b ans = 1.0D-14 * - 0.6217249 0.0888178 -->// {x1+x2-1=0; x1+x2-3=0} -->A=[1 1;1 1]; b=[-1;-3]; -->// : -->linsolve(A,b) WARNING:Conflicting linear constraints! ans = [] -->// {3x1-x2-1=0; 6x1-2x2-2=0}. -->// , -->// , SCILAB . -->A=[3 -1;6 -2]; -->b=[-1;-2]; -->x=linsolve(A,b) x= 0.3 - 0.1 -->// -->A*x+b ans = 1.0D-15 * - 0.1110223 - 0.2220446

49

§ rref(A) A , ; 3.38. rref --> A=[3 -2 1 5;6 -4 2 7;9 -6 3 12] A= 3 -2 1 5 6 -4 2 7 9 -6 3 12 --> rref(A) ans = 1.0000 -0.6667 0.3333 0 0 0 0 1.0000 0 000


50

3. Scilab. § lu() M1 ; 3.39. lu -->A=[2 -1 5;3 2 -5;1 1 -2] A= 2. - 1. 5. 3. 2. - 5. 1. 1. - 2. -->[L,U]=lu(A) U= 3. 2. - 5. 0. - 2.3333333 8.3333333 ! 0. 0. 0.8571429 ! L= 0.6666667 1. 0. 1. 0. 0. 0.3333333 - 0.1428571 1. -->LU=L*U LU = 2. - 1. 5. 3. 2. - 5. 1. 1. - 2. § qr() 2 ; 3.40. qr -->[Q,R]=qr(A) R= - 3.7416574 - 1.3363062 0. - 2.0528726 0. 0. Q= - 0.5345225 0.8350668 - 0.8017837 - 0.4523279 0.2672612 - 0.3131501 -->Q*R ans =

1.8708287 7.0632734 0.7811335 0.1301889 - 0.3905667 0.9113224

1 M = C § L § U, L U , . LU-. 2 M = Q § R, Q , R . QR-.


3.3. 2. 3. 1. - 1. 2. 1. 5. - 5. - 2.

51

§ svd() 1 n½m; , , ; 3.41. svd -->[U,S,V]=svd(A) V= - 0.1725618 0.9641403 - 0.3059444 0.1421160 0.9362801 0.2241352 S= 7.8003308 0. 0. 3.6207331 0. 0. U= 0.5951314 0.8028320 - 0.7449652 0.5678344 - 0.3014060 0.1817273 -->U*S*V' ans = 2. - 1. 5. 3. 2. - 5. 1. 1. - 2. -->s=svd(A) s= 7.8003308 3.6207331 0.2124427

- 0.2016333 0.9413825 0.2704496 0. 0. 0.2124427 0.0357682 - 0.3501300 0.9360180

§ kernel([,tol[,fl]]) 2 , tol fl . , 'qr' 'svd'.
M = U § S § VT , U V m ½ m n ½ n , S , M 2 X. AX = 0. X=kernel(A) X , AX = 0.
1


52

3. Scilab. 3.42. kernel -->A=[4 1 -3 -1;2 A= 4. 1. - 3. 2. 3. 1. 1. - 2. - 2. -->X=kernel(A) X= 0.3464102 0.5773503 0.4618802 0.5773503 3 1 -5;1 -2 -2 3] 1. 5. 3.

3.4



Scilab , , . , . 3.43. -->M=['a' 'b';'c' 'd'] M= ab cd -->P=['1' '2';'3' '4'] P= 12 34 ( ) : 3.44. -->M+P ans = a1 b2 c3 d4 -->M' ans = ac bd -


3.5.

53

, addf(a,b) mulf(a,b): 3.45. addf mulf -->addf(M(1,1),P(2,2)) ans = a+4 -->mulf(M(1,2),P(2,1)) ans = b*3

3.5


a11 x1 + a12 x2 + § a21 x1 + a22 x2 + § ................ am1 x1 + am2 x2 + § § + a1n xn = § § + a2n xn = ............. § § § + amn xn b1 , b2 , ..... = bm

m n :

(), xj , aij , bi (i = 1 . . . m, j = 1 . . . n). m n : A § x = b, x , A , b . (x1 , x2 , . . . , xn ) . 3.1. : 2x1 + x2 x1 - 3x2 2x2 - x3 x1 + 4x2 - - + - 5x3 6x4 2x4 7x3 + = = + x4 = 8 , 9, -5 , 6x4 = 0 .

. = det A n n A § x = b , x1 , x2 , . . . , xn , : xi = i /, i , A i- b. :


54

3. Scilab. 3.46. - // : A=[2 1 -5 1;1 -3 0 -6;0 2 -1 2;1 4 -7 6]; b=[8;9;-5;0]; // A1=A;A1(:,1)=b; // A2=A;A2(:,2)=b; // A3=A;A3(:,3)=b; // A4=A;A4(:,4)=b; // D=det(A); // // : d(1)=det(A1); d(2)=det(A2); d(3)=det(A3); d(4)=det(A4); x=d/D // P=A*x-b // -: 3.47. - -->exec('C:\scilab-4.1.1\kramer.sce');disp('exec done'); x= 3. - 4. - 1. 1. P = 1.0D-14 * 0.1776357 0. - 0.0888178 0.1554312 exec done

3.2. 3.1 . : n n A § x = b, , A , x = A-1 § b. - : 3.48. inv // : A=[2 1 -5 1;1 -3 0 -6;0 2 -1 2;1 4 -7 6];b=[8;9;-5;0];


3.5. x=inv(A)*b // // -: --> x = 3. - 4. - 1. 1. 3.3. : 2x1 - x2 + 5x3 = 0 , 3x1 + 2x2 - 5x3 = 1 , x1 + x2 - 2x3 = 4 .

55

, , , . . , ( , , , ) . ( ) , n . , n + 1 . - : 3.49. rref // : A=[2 -1 1;3 2 -5;1 3 -2]; b=[0;1;4]; // : C=rref([A b]); // : [n,m]=size(C); //m- // : x=C(:,m) //x - // : --> x = 0.4642857 1.6785714 0.75


4

Scilab . , .

4.1

plot

y = f (x), Scilab plot. Scilab ( Scilab ) plot y = f (x). : plot(x,y,[xcap,ycap,caption]) x ; y ; xcap, ycap, caption X , Y .

4.1. y = sin(cos(x)) plot. x [-2 ; 2 ] 0,1. X . y = sin(cos(x)) X , Y . plot(x,y) 'X', 'Y', 'plot function y=sin(cos(x))' (. 4.1, . 4.1).


4.1. plot 4.1. y = sin(cos(x)) plot x=-2*%pi:0.1:2*%pi; y=sin(cos(x))'; plot(x,y,'X','Y','plot function y=sin(cos(x))');

57

Y 0.9

plot function y=sin(cos(x))

0.7

0.5

0.3

0.1

-0.1

-0.3

-0.5

-0.7

-0.9 -7 -5 -3 -1 1 3 5 7

X

. 4.1. y = sin(cos(x)) plot(y), y. 4.2 . 4.2 y = f (i). 4.2. y = f (i), j y y=[1 2 3 -2 4 5 -1 6 9 11 0 -2 5]; plot(y); plot . 4.2. y = sin(cos(x)), z = cos(sin(x)), v = es t = ecos(x) .

in(x)

,


58

4.

12

10

8

6

4

2

0

-2 1 3 5 7 9 11 13

. 4.2. y = f (i)

, x [-2 ; 2 ] 0,1. X . x , plot . . , (. 4.3 4.3). 4.3. plot Scilab 3 x=-2*%pi:0.1:2*%pi; plot([sin(cos(x));cos(sin(x));exp(sin(x));exp(cos(x))]);

. 4.3, plot Scilab 3 . Scilab 4 , . plot plot(x,y).


4.2.

59

3.0

2.5

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0 0 20 40 60 80 100 120 140

. 4.3. Scilab 3

4.2



plot(x,y) Scilab Graphic (0), y(x) . plot, , . plot : plot(x1,y1,x2,y2,...xn,yn) x1, y1 x2, y2 ... xn, yn n- . ;

;

4.3. y = sin( x ), z = 2 cos(x) v = exp(cos(x)).


60

4.

x [-6,28;6,28], 0,02. Y , Z , V . plot , , , . . plot plot(x,y,x,z,x,v) ( 4.4 . 4.4). 4.4. plot Scilab 4 x=-6.28:0.02:6.28;y=sin(x/2); z=cos(x);v=exp(cos(x)); plot(x,y,x,z,x,v);

3.0

2.5

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.4. plot plot(x3,y3), plot(x,y), plot(x2,y2), ..., plot(xn,yn) mtlb_hold('on'), .

4.4. y = sin( x ), z = 2 cos(x) v = exp(cos(x)) , mtlb_hold('on').


4.2.

61

, x [-6,28;6,28], 0,02 Y , Z , V . plot plot(x,y), , . , plot , mtlb_hold('on') ( 4.5 . 4.5). 4.5. mtlb_hold('on') x=-6.28:0.02:6.28; y=sin(x/2); z=cos(x); v=exp(cos(x)); plot(x,y); mtlb_hold(' on'); plot(x,z); mtlb_hold(' on'); mtlb_hold(' on'); plot(x,v);

3.0

2.5

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.5. mtlb_hold('on') , (. 4.3) Scilab , .


62

4.

4.3



Scilab 4 , . , 4 , 4 , . plotframe: plotframe(rect, tics [,grid, title, x-leg, y-leg, x, y, w, h]) rect [xmin, ymin, xmax, ymax], x y - ; tics [nx, mx, ny, my], X (mx) Y (my), nx ny X Y ; , (%t) (%f). , , [%t,%t];

grid

bound , true tics(2) tics(4). title , ; X Y ;

x-leg, y-leg x, y

, w , h . x, y, w, h [0, 1].

plot. 4.5. y = sin(2x), z = cos(3x), u = cos(sin(2x)), v = sin(cos(3x)) , . , x [-10 : 10] 0,01. Y , Z , U , V . rect , . X x ( ), Y y -1 1.


4.3.

63

tics , , , 11 2 , 5 10 . plotframe : (%t) (%f), , , , . plotframe plot(x,y) ( 4.6 . 4.6). 4.6. , plotframe x=[-10:0.01:10]; y=sin(2*x); z=cos(3*x); u=cos(sin(2*x)); v=sin(cos(3*x)); rect=[min(x),-1,max(x),1]; tics=[2,11,10,5]; plotframe(rect,tics,[%t,%t],["Function y=sin(2x)",... "X","Y"], [0,0,0.5,0.5]); plot(x,y); plotframe(rect,tics,[%f,%f],["Function y=cos(3x)",... "X","Y"], [0.5,0,0.5,0.5]); plot(x,z); plotframe(rect,tics,[%f,%f],["Function y=cos(sin(2x))",... X","Y"], [0,0.5,0.5,0.5]); plot(x,u); plotframe(rect,tics,[%t,%t],["Function y=sin(cos(3x))",... "X","Y"], [0.5,0.5,0.5,0.5]); plot(x,v); subplot. , , , . : subplot(m,n,p) subplot(mnp) , m n , p.


64

4.

. 4.6.

4.6. y = sin(x), z = cos(x), u = cos(sin(x)), v = sin(cos(x)), w = exp(sin(x)) r = exp(cos(x)) , , subplot. x [-10 : 10] 0,01. Y , Z , U , V , W , R. C subplot . , 3, 2 . subplot , ( ) , plot(x,y) ( 4.7 . 4.7). 4.7. , subplot x=[-10:0.01:10]; y=sin(x); z=cos(x); u=cos(sin(x)); v=sin(cos(x)); w=exp(sin(x)); r=exp(cos(x)); subplot(3,2,1);


4.4. plot2d plot(x,y); subplot(3,2,2); plot(x,z); subplot(3,2,3); plot(x,u); subplot(3,2,4); plot(x,v); subplot(3,2,5); plot(x,w); subplot(3,2,6); plot(x,r);
1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10 -8 1.00 0.95 0.90 0.85 0.80 0.75 0.70 0.65 0.60 0.55 0.50 -10 -8 3.0 2.5 2.0 1.5 1.0 0.5 0.0 -10 -8 -6 -4 -2 0 2 4 6 8 10 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10 -8 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10 -8 3.0 2.5 2.0 1.5 1.0 0.5 0.0 -10 -8 -6 -4 -2 0 2 4 6 8 10

65

-6

-4

-2

0

2

4

6

8

10

-6

-4

-2

0

2

4

6

8

10

-6

-4

-2

0

2

4

6

8

10

-6

-4

-2

0

2

4

6

8

10

. 4.7.

4.4

plot2d

, , plot2d. : plot2d([logflag],x,y',[key1=value1,key2=value2,...,keyn=valuen] logflag , (n , l ), nn ;


66 x y ;

4.

, , y1, y2, ..., yn, x. x y . x y , y x;

keyi=valuei key1=value1, key2=value2, ..., keyn=valuen, . . , plot2d . , plot. 4.7. y = sin(x). , x [-2 ; 2 ] 0,1. X . Y , plot2d (. 4.8 . 4.8). 4.8. plot2d x=[-2*%pi:0.1:2*%pi]; plot2d(sin(x)); plot2d, . 4.8. y = sin(x), y1 = sin(2x), y2 = sin(3x) . X , , [0; 2 ] 0,1. plot2d(x,y). Y , (. 4.9 . 4.9).


4.5. plot

67

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 0 20 40 60 80 100 120 140

. 4.8. y = sin(x)

4.9. plot2d x=[0:0.1:2*%pi]'; plot2d(x,[sin(x) sin(2*x) sin(3*x)]);

4.5

plot

, plot: plot(x1, y1, s1, x2, y2, s2, ..., xn, yn, sn) x1, x2, ..., xn y1, y2, ..., yn ;

;

s1, s2, ..., sn , , , (. . 4.1í 4.3), , .


68

4.

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 0 1 2 3 4 5 6 7

. 4.9. y = sin(x), y = sin(2x), y = sin(3x)

4.1. , y m r g b w k


4.5. plot 4.2. , . o + * s d v ^ < > p

69



4.3. , : -. - ( ) , ,

e

(cos(x))

y = sin( x ), z = cos(x) v = 2 . y = sin( x ) , z = cos(x) 2 , , v = exp(cos(x)) , , (. 4.10 . 4.10). 4.10. , , () plot x=-6.28:0.2:6.28; y=sin(x/2); z=cos(x); v=exp(cos(x)); plot(x,y,'--'); mtlb_hold('on'); plot(x,z,'k*'); mtlb_hold('on'); plot(x,v,'r.--');


70

4.

3.0

2.5

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.10. plot

, X Y . Scilab xgrid(color), color id . , . , (. 4.11 . 4.11). 4.11. xgrid x=-10:0.01:10; y=sin(cos(x)); z=cos(sin(x)); plot(x,y,'r',x,z,'b'); xgrid(); , plot, xtitle: xtitle(title, xstr, ystr) title xstr ystr ;

X ; Y .


4.5. plot

71

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10

-8

-6

-4

-2

0

2

4

6

8

10

. 4.11. xgrid

Grafic y=f(x) X Y (. 4.12 . 4.12). 4.12. xtitle x=-10:0.01:10; y=sin(cos(x)); z=cos(sin(x)); plot(x,y,'r',x,z,'b'); xgrid(); xtitle('Grafic y=f(x)','X','Y'); , , , . legend: legend(leg1, leg2, ..., legn, [pos], [boxed]) leg1 , leg2 ; , legn n-


72

4.

Grafic y=f(x) 1.0 0.8 0.6 0.4 0.2 Y 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10

-8

-6

-4

-2

0 X

2

4

6

8

10

. 4.12. xtitle

pos

: 1 ( ), 2 , 3 , 4 , 5 ;

boxed , , ( %t) ( %f) . , (. 4.13 . 4.13). 4.13. legend x=-10:0.01:10; y=sin(cos(x)); z=cos(sin(x)); plot(x,y,'r',x,z,'b'); xgrid(); xtitle('Grafic y=f(x)','X','Y'); legend('sin(cos(x))','cos(sin(x))',3,%f);


4.6. plot2d

73

Grafic y=f(x) 1.0 0.8 0.6 0.4 0.2 Y 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10 sin(cos(x)) cos(sin(x)) -8 -6 -4 -2 0 X 2 4 6 8 10

. 4.13. legend

4.6

plot2d

4.4 , plot2d keyn=valuen. , plot2d : plot2d([logflag],x,y',[key1=value1,key2=value2,...,keyn=valuen] keyn=valuen: § style . . color, (color(" ")) rgb (color(r,g,b)) id () . RGBid Scilab Color_list . , id- 0. . y = sin(x) y = cos(x), style ( red ), id (0,176,0) (. 4.14).


74

4. . 4.14. 4.14. style plot2d x=[-2*%pi:0.1:2*%pi]; y=[sin(x);cos(x)]; plot2d(x,y',style=[color("red"),color(0,176,0)]);

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.14. style plot2d

§ rect keyn=valuen plot2d [xmin, ymin, xmax, ymax], . xmin, ymin xmax ymax . ;

;

rect , [-8,-2,8,2] (. 4.15 . 4.15). , Y [-1:1] [-2:2], X , , Y .


4.6. plot2d 4.15. rect plot2d x=[-2*%pi:0.1:2*%pi]; y=[sin(x);cos(x)]; plot2d(x,y',style=[color("red"),color(0,176,0)], rect=[-8,-2,8,2]);

75

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0

-1.5

-2.0 -8 -6 -4 -2 0 2 4 6 8

. 4.15. rect plot2d § axesflag keyn=valuen plot2d . : 0 1 3 5 ; , y ( ); , y ; , (0,0). 4.9. y = sin(x) y1 = cos(x), 4 axesflag, subplot.


76

4. , subplot , (. 4.3). 4 . axesflag=0 , axesflag=1 , axesflag=3 , axesflag=5 (. 4.16 . 4.16). 4.16. axesflag plot2d x=[-2*%pi:0.1:2*%pi]; y=[sin(x); cos(x)]; subplot(2,2,1) plot2d(x,y',style=[color("red"), subplot(2,2,2) plot2d(x,y',style=[color("red"), subplot(2,2,3) plot2d(x,y',style=[color("red"), subplot(2,2,4) plot2d(x,y',style=[color("red"),

color("blue")], axesflag=0); color("blue")], axesflag=1); color("blue")], axesflag=3); color("blue")], axesflag=5);

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -8 -6 -4 -2 0 2 4 6 8

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -8 -6 -4 -2 0 2 4 6 8 -1.0 -8 -6 -4 -2

1.0 0.8 0.6 0.4 0.2 0.0 0 -0.2 -0.4 -0.6 -0.8 -1.0 2 4 6 8

. 4.16. axesflag plot2d


4.6. plot2d

77

§ , , Scilab nax. axesflag=1 ( ), : [nx, Nx, ny, Ny]. Nx (Ny) nx (ny) c X (Y );

.

4.10. y = sin(x) y1 = cos(x). . X , , x [-8:8] 0,1, : y=[sin(x); cos(x)]. plot2d y = sin(x) y1 = cos(x), nax=[4,9,3,6]. , X 9 (), 4 , Y 6 3 (. 4.17 . 4.17).

1.0

0.6

0.2

-0.2

-0.6

-1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.17. nax plot2d


78

4. 4.17. nax plot2d x=[-8:0.1:8]; y=[sin(x); cos(x)]; plot2d(x,y',style=[color("red"),color("blue")],axesflag=1,... nax=[4,9,3,6]); § leg keyn=valuen plot2d : "leg1@leg2@leg3@...@legn" leg1 ..., legn , n- . , -

. y = sin(x) y1 = cos(x) X Y (0,0) axesflag=5, (. 4.18 . 4.18).

1.0 0.8 0.6 0.4 0.2 0.0 -8 -6 -4 -2 -0.2 -0.4 -0.6 -0.8 -1.0 sin(x) cos(x) 0 2 4 6 8

. 4.18. leg plot2d


4.7. 4.18. leg plot2d x=[-2*%pi:0.1:2*%pi]; y=[sin(x); cos(x)]; plot2d(x,y',axesflag=5, leg="sin(x)@cos(x)");

79

4.7



plot2d . : plot2d(x,y,d) d , (. . 4.4). 4.4. , -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 , ,

4.11. y = sin(x) , . x, X Y . plot2d -8, , (. 4.19 . 4.19).


80

4.

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.19. y = sin(x)

4.19. Scilab x=[-2*%pi:0.25:2*%pi]; y=sin(x); plot2d(x,y,-8);

4.8



Scilab plot2d2(x,y). plot2d. , X Y , , X Y . 4.12. 1947 2006 , . . , 1947, 1958, 1970, 1980, 1999 2006 . X Y plot2d2(x,y) (. 4.20 . 4.20).


4.9.

81

5.5

5.0

4.5

4.0

3.5

3.0

2.5

2.0 1940

1950

1960

1970

1980

1990

2000

2010

. 4.20. plot2d2

4.20. Scilab x=[1947 1958 1970 1980 1999 2006]; y=[2.003 3.1 3.6 4.7 5.2 5.4]; plot2d2(x,y);

4.9



O , , O, OX . M = OM ( ), , X OM ( ). Scilab , polarplot: polarplot(fi,ro,[key1=value1,key2=value2,...,keyn=valuen]), fi ro ;

;


82

4.

keyn=valuen ( . 4.4). 4.13. = 3 cos(5) 1 = 3 cos(3). , fi, ro. polarplot, ro , ro1 (c. 4.21, . 4.21). 4.21. fi=0:0.01:2*%pi; ro=3*cos(5*fi);ro1=3*cos(3*fi); polarplot(fi,ro,style=color("red")); polarplot(fi,ro1,style=color("blue"));

90 120 3 2.4 1.8 150 1.2 0.6 30 60

180

0

210

330

240 270

300

. 4.21. = 3 cos(5), 1 = 3 cos(3)


4.10. ,

83

4.10

,

y (x) x = f (t) y = g (t) , t . , , t, x = f (t), y = g (t) y (x), plot(x,y) plot2d(x,y). 4.14. . , , : x2 (a + x) = y 2 (a - x) t: 2 X (t) = (t - 1) (t2 + 1) 2 Y (t) = t § (t - 1) 2 + 1) (t t=-5:0.01:5; x=(t.^2-1)./(t.^2+1); y=t.*(t.^2-1)./(t.^2+1); plot(x,y); 4.22. plot (4.1)

(4.2)

t, x y plot(x,y) (. 4.22, . 4.22).

4.15. . , : y
m

= A + B x + C x2 + . . . + N x

n

(4.3)

: x(t) = 0.5t2 y (t) = 0.3t3 (4.4)


84

4.

5 4 3 2 1 0 -1 -2 -3 -4 -5 -1.0

-0.8

-0.6

-0.4

-0.2

0.0

0.2

0.4

0.6

0.8

1.0

. 4.22.

10 8 6 4 2 0 -2 -4 -6 -8 -10 0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

. 4.23.


4.11.

85

, t- , x y . plot2d(x,y) (. 4.23, . 4.23). 4.23. plot2d t=-3:0.01:3; x=0.5*t.^2; y=0.3*t.^3; plot2d(x,y);

4.11



Scilab , , . Edit í Figure properties . y1 = sin(2x) y2 = sin(3x) [0; 2 ] 0,1. x plot2d (. 4.24, . 4.24).

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 0 1 2 3 4 5 6 7

. 4.24. y1 = sin(2x) y2 = sin(3x)


86

4. 4.24. y1 = y2 = sin(3x) plot2d x=[0:0.1:2*%pi]'; plot2d(x,[sin(2*x) sin(3*x)]); sin(2x)

Edit í Figure properties Figure Editor (. . 4.25).

. 4.25. Figure Editor

Ob ject Browser , . Figure(1) ( ) , Ob ject Properties , . Ob ject Browser : Figure ( ) Axes (). , .


4.11.

87

. 4.26. Ob ject Browser

Axes ( ), Compound(1) () . Compound(1) y1 = sin(2x) y2 = sin(3x) Polyline(2) Polyline(1) (. . 4.26).

4 .1 1 .1

Figure ( )

, Figure o , . Figure(1) Ob ject Browser . . 4.26 Style Figure Editor Figure(1). : Visibility ( ) , on off . on .


88

4.

Figure name ( ) , . Scilab Graphic (%d), %d (Figure id). Figure id 0, 1, 2 . . . , Scilab Graphic (%d) Grafic y=f(x) Enter. (. . 4.27).

. 4.27.

X p osition, Y p osition . [0;0] . X size, Y size . -

X axis size, Y axis size

X Y .

Back. color ( ) (RGB-id). 35 ( -2 32 ).


4.11.

89

. 4.28. Figure Editor

15. (. . 4.28). Colormap (. . 4.29). (RED ), (GREEN ) (BLUE ) , , . , [0 0 0] , [0.230 0.230 0.250] , [0.85 0.107 0.47] . Colormap (Nx3 double array) RGB-id . RGBid Scilab Color_list . , id- 0. . Mode Ob ject Properties Figure (. . 4.30) : Auto resize , . ( on ), , , , . (. . 4.31).


90

4.

. 4.29. Colormap Figure Editor

. 4.30. Mode Figure Editor


4.11.

91

. 4.31. Auto resize

Pixmap . ( ) . ( on ) show_pixmap(). , Pixmap . Pixel drawing mo de , . copy . . , . : clear , and , andReverse , andInverted , noop , xor , or , nor , equiv , invert , orReverse , copyInverted , orInverted , nand , set . . 4.32. invert Pixel drawing mode


92

4.

. 4.32. invert Pixel drawing mode Mode

Rotation style . unary , multiple .

4 .1 1 .2

Axes ( )

Axes ( ) Ob ject Browser . Ob ject Properties . X, Y Z , , X , Y Z . X (. . 4.33). X : Label Options (C ) Axis Options ( ). Label Options :


4.11.

93

. 4.33. X Axes

Lab el



;

Visibility , on off . ( on ). Fill mo de , on off ( ). , , on . Auto p osition . on , . , Position [x, y ]. Auto position off . Auto Rotation . ( off ).


94

4.

Font angle . : 0, 90, 180 270 , (. . 4.33). Fore/Back colors í , . 35 . . 4.6. Font size , 0 6. 1. Font style . Helvetica (). Axis Options : Lo cation . X : bottom , top , middle ; Y : left , right , middle . Grid color , . -1 , 0 , 32 . , X Y , Grid color X, Y. Data b ounds . , , . Scale . : lin () log (). Ticks () Edit Axes Ticks. . 4.34. : Visibility , on off . ( on ). Auto ticks , ( on ). , , Steb by Enter. Auto ticks off .


4.11.

95

. 4.34. Edit Axes Ticks

Sub ticks . , . , . Edit Axes Ticks ( Sub ticks ). Locations , Labels . Insert, Delete, Apply, Quit. Insert ( ) . . Delete , , . Apply , Quit Edit Axes Ticks.


96

4.

. 4.35. Title Axes Editor

X Reverse. on , Y . Y, X . Title Axes Editor . Label Options, Label Options X, Y Z (. . 4.35). X, Y, Title Axes Editor. y1 = sin(2x) y2 = sin(3x) [0; 2 ] 0,1. X os absciss Y os ordinat , Helvetica Bold 3. Grid Color 1. X middle, Y Reverse. Grafic y=f(x) ,


4.11.

97

. 4.36. X, Y, Title

Helvetica Bold, 4. , ( 7). , . 4.36. Style Axes Editor (. . 4.37) : Visibility , on ( ) off . off . Font style . Helvetica. Font color , . -1 . Font size , 0 6. 1.


98

4.

. 4.37. Style Axes Editor

Fore. color , . -1 . Back. color , . -2 . Thickness , 1 30. 1. Line style . 6 : solid , .

Style. Helvetica Bold, 2, ( Back. color 12) 2.


4.11.

99

. 4.38. Style

, . 4.38. Aspect Axes Editor (. . 4.39) : Auto clear on . ( ), scale. , Auto

Auto scale . on ( ) , , , . Auto scale , , .


100

4.

. 4.39. Aspect Axes Editor

Auto scale. y = sin(x) y1 = cos(x) (-2 ; 2 ), y2 = sin(3x) (0; 2 ). , . Auto scale , , (. 4.25, . 4.40). 4.25. Auto scale x=[-2*%pi:0.1:2*%pi]; y=[sin(x); cos(x)]; plot2d(x,y'); x=[0:0.1:2*%pi]; plot2d(sin(3*x));


4.11.

101

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -10

0

10

20

30

40

50

60

70

. 4.40. Auto scale

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -8 -6 -4 -2 0 2 4 6 8

. 4.41. Auto scale


102

4.

, Auto scale, . (. 4.26, . 4.41). 4.26. Auto scale x=[-2*%pi:0.1:2*%pi]; y=[sin(x); cos(x)]; plot2d(x,y'); // Auto scale x=[0:0.1:2*%pi]; plot2d(sin(3*x)); Boxed Aspect Axes Editor , ( on ) ( off ). Isoview , . off . Tight limits , , Data bounds X, Y Z. off ( ) , . Cub e scaling . on , 1. 3D- , . off . lip state () . : off , ; clipgrf ( ) , ; on , , lip box. lip b ox , . X Y (upper-left point coordinates), W H.


4.11.

103

Margins : Left ( ), Right (), Top (), Bottom (). [0 : 1]. 0.125. Axes b ounds , . Left Up , Width Height . [0 : 1]. [0 0 1 1]. View Point (. . 4.42) (Rotation Axes Editor , . angles) 0 270.

. 4.42. View Point Axes Editor


104

4.

4 .1 1 .3

Polyline ( )

Polyline Ob ject Browser Polyline Editor. Ob ject Properties : Style, Data, Clipping. Style Polyline Editor (. . 4.43) :

. 4.43. Style Polyline Editor

Visibility , on ( ) off . off . Fill mo de , on off ( ). , , , on .


4.11. Closed , .

105

Polyline style . : interpolated íí ; staircase ; barplot ; arrowed , , Arrow size ; filled ; bar , (. . 4.44).

1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 0 10 20 30 40 50 60 70

. 4.44. y = sin(3x). bar Line . 6 : solid , . : 1 30.

Foreground Background , , , Fill mode on . . 4.45 y = sin(3x) Foreground 1, Background 6, Fill mode Closed. Interp color vector . , -

Mark mo de , ( on ). .


106

4.

. 4.45. Foreground, Background Closed

Mark style : dot ; plus ; cross ; star , ; filled diamond ; diamond ; triangle up ; triangle down ; diamond plus , ; circle ; asterisk ; square ; triangle right ; triangle left ; pentagram . Mark size 0 30pt.

Mark foreground , . . 4.46 y = sin(3x) filled diamond, 1, Mark foreground 5. Data Polyline Editor , . Data field , 2 Double, 63 [63x2 double array] (. . 4.47). Edit data .


4.11.

107

. 4.46. y = sin(3x)

. 4.47. Data Polyline Editor


108

4.

. 4.48. Clipping Polyline Editor

Clipping () Polyline Editor Clip box (), (. . 4.48). , X Y x, y , W, H . Clip state : off , ; clipgrf ( ) , ; on , , lip box.


5 Scilab

Scilab . , . Z (x, y ) : 1. . , xi yj , xn - x0 , i = 0, 1, . . . , n , xi = x0 + ih, h = n yk - y0 y j = y 0 + j h, h = , j = 0, 1, . . . , k . k 2. zij = f (xi , yj ) . 3. .

5.1

plot3d plot3d1

Scilab plot3d plot3d1. , plot3d , plot3d1 , , (. . I). : plot3d(x,y,z,[theta,alpha,leg,flag,ebox][keyn=valuen]), plot3d1(x,y,z,[theta,alpha,leg,flag,ebox][keyn=valuen]),


110 x y z

5. Scilab - ;

- ; ;

theta, alpha , . , , ; leg flag , 'X@Y@Z'. , @. -

, : [mode,type,box]. mode 2 (. . 5.1). , . 5.1. mode

>0 0 <0

mode , , ( ) mode ,

type

(. . 5.2), 2; 5.2. type

0 1 2

, ebox

box

(. . 5.3). 4.






5.1. plot3d plot3d1 5.3. box 01 2 3 4 , ,

111

ebox

, , [xmin, xmax, ymin, ymax, zmin, zmax]. type=1.

keyn=valuen key1=value1, key2=value2, ..., keyn=valuen, , , , . (. 4.6). , plot3d (plot3d1) . 5.1. Z = sin(t) § cos(t). t. Z . , plot3d X Y , , t, sin, cos t (. 5.1, . 5.1). 5.1. Z = sin(t) § cos(t) plot3d t=[0:0.3:2*%pi]'; Z=sin(t)*cos(t'); plot3d(t,t,Z); . , . 5.2. Z = 5y 2 - x2 .


112

5. Scilab

. 5.1. Z = sin(t) § cos(t) X Y . Z (xi , yj ), for. i , X , j , X Y . , Z Y ( ) X . X . . , length X (Y ) (. 2). , plot3d1 (. 5.2, . II). 5.2. Z = 5y 2 - x2 length plot3d x=[-2:0.1:2]; y=[-3:0.1:3]; for i=1:length(x) for j=1:length(y) z(i,j)=5*y(j)^2-x(i)^2; end end


5.1. plot3d plot3d1 plot3d1(x',y',z,-125,51); colorbar(-3,3)

113

, plot3d , , . Scilab , genfac3d eval3dp. genfac3d: [xx,yy,zz]=genfac3d(x,y,z) xx, yy, zz (4, n - 1 ½ m - 1), xx(:,i), yy(:,i) zz(:,i) ; x y z x- m; y - n; (m, n) Z (xi , yj ). 5.3. Z = sin(t) § cos(t). t Z = sin(t) § cos(t). genfac3d (. 5.3). 5.3. genfac3d plot3d t=[0:0.3:2*%pi]'; z=sin(t)*cos(t'); [xx,yy,zz]=genfac3d(t,t,z); plot3d(xx,yy,zz); plot3d (. . 5.1). genfac3d , - plot3d, . eval3dp: [Xf,Yf,Zf]=eval3dp(fun,p1,p2) Xf,Yf,Zf í (4, n - 1 ½ m - 1), xx(:,i), yy(:,i) zz(:,i) ; fun , , ;


114 p1 p2 m; n.

5. Scilab

eval3dp . 5.4. , : x = p1 § sin(p1 ) § cos(p2 ), y = p1 § cos(p1 ) § cos(p2 ), z = p1 § sin(p2 ). , p1 p2 . scp, . , Scilab deff: deff([s1,s2,...]=newfunction(e1,e2,...)' s1,s2,... , .. , ; newfunction ; e1,e2,... , -

.

, deff (. 5.4). 5.4. eval3dp plot3d p1=linspace(0,2*%pi,10); p2=linspace(0,2*%pi,10); deff("[x,y,z]=scp(p1,p2)",["x=p1.*sin(p1).*cos(p2)"; "y=p1.*cos(p1).*cos(p2)"; "z=p1.*sin(p2)"]); [Xf,Yf,Zf]=eval3dp(scp,p1,p2); plot3d(Xf,Yf,Zf); eval3dp , plot3d (. . III). Scilab . Matlab, , , plot3d.


5.2. meshgrid, surf mesh

115

5.2

meshgrid, surf mesh

Scilab 4.0 meshgrid. : [X, Y [Z]] = meshgrid(x, y [z]) (x, y [z]) 2 (3) X , Y (Z ), ; [X, Y [Z]] 2 3 .

surf mesh. , plot3d plot3d1, surf , , , mesh . , mesh surf olor mode= olor flag=0. : surf([X,Y],Z,[color,keyn=valuen]) mesh([X,Y],Z,[color,]) X,Y Z , ;

;

color , ; keyn=valuen key1=value1, key2=value2, ..., keyn=valuen, (. 4.6). , , meshgrid, X,Y . surf surf(z). 5.5. Z = 5y 2 - x2 mesh. C meshgrid . -2 : 2 , X , -3 : 3 Y . Z mesh (. 5.5, . 5.2).


116

5. Scilab 5.5. meshgrid mesh [x y]=meshgrid(-2:2,-3:3); z=5*y.^2-x.^2; mesh(x,y,z);

45 40 35 30 25 20 15 10 5 0 -5 3 2 1 0 -1 Y -2 -3 -2.0 -1.5 -1.0 -0.5 0.0 X 0.5 1.0 1.5 2.0

. 5.2. Z = 5y 2 - x2 , mesh 5.2, , 1, , . meshgrid. 5.6. Z = 5y 2 - x2 surf. meshgrid , , 0,1 . , , . Z surf (. 5.6, . IV).

Z


5.2. meshgrid, surf mesh 5.6. meshgrid surf [x y]=meshgrid(-2:0.1:2,-3:0.1:3); z=5*y.^2-x.^2; surf(x,y,z)

117

, Z = 5y 2 - x2 plot3d1 surf (. . II . IV). . surf Cube scaling (. . 5.3). , surf , plot3d (. . V).

. 5.3. Cube scaling Axes Editor Scilab , , , mtlb_hold('on'), surf mesh.


118 5.7.

5. Scilab

z (x, y ) = (3x2 + 4y 2 ) - 1 , z1 (x, y ) = -(3x2 + 4y 2 ) - 1 .

meshgrid. z (x, y ) = (3x2 + 4y 2 ) - 1 z1 (x, y ) = -(3x2 + 4y 2 ) - 1. . Z = +(3x2 + 4y 2 ) - 1 surf, , . mtlb_hold('on'), , mesh Z1 = -(3x2 + 4y 2 ) - 1 Z = +(3x2 + 4y 2 ) - 1, , (. 5.7, . VI). 5.7. mtlb_hold('on') [x y]=meshgrid(-2:0.2:2,-2:0.2:2); z=3*x.^2+4*y.^2-1; z1=-3*x.^2-4*y.^2-1; surf(x,y,z); mtlb_hold('on'); mesh(x,y,z1);

5.3

plot3d2 plot3d3

plot3d2 plot3d3 plot3d, : plot3d2(x,y,z,[theta,alpha,leg,flag,ebox][keyn=valuen]), plot3d3(x,y,z,[theta,alpha,leg,flag,ebox][keyn=valuen]) , . . . plot3d , plot3d2 (plot3d3) . plot3d2 plot3d3 plot3d plot3d1, surf mesh. Plot3d2 , , .


5.3. plot3d2 plot3d3

119

Plot3d , (. . ) 5.8.

plot3d2.

x(u, v ) = cos(u) cos(v ) , y (u, v ) = cos(u) sin(v ) , z (u, v ) = sin(u)

, x(u, v ), y (u, v ) z (u, v ) X , Y Z . u v . x, y z : 1. x, y z f (u) § g (v ), X , Y Z f (u) g (v ). 2. x, y z f (u) g (v ), X , Y Z f (u) § ones(size(v )) g (v ) § ones(size(u)) . , linspace , . , u=linspace(-%pi/2,%pi/2,40) , u [-2 ; 2 ]. 40 , 40 , 100 (. 5.8). 5.8. plot3d2 u = linspace(-%pi/2,%pi/2,40); v = linspace(0,2*%pi,20); X = cos(u)'*cos(v); Y = cos(u)'*sin(v); Z = sin(u)'*ones(v); plot3d2(X,Y,Z); plot3d2 . 5.4. , plot3d.


120

5. Scilab

. 5.4. , plot3d2

5.9.

plot3d.

x(u, v ) = cos(u) cos(v ) , y (u, v ) = cos(u) sin(v ) , z (u, v ) = sin(u)

u v , x, y , z , (. 5.9). plot3d. (. . VII). 5.9. plot3d u = linspace(-%pi/2,%pi/2,40); v = linspace(0,2*%pi,20); X = cos(u)'*cos(v); Y = cos(u)'*sin(v); Z = sin(u)'*ones(v); plot3d(X,Y,Z); plot3d3 .


5.3. plot3d2 plot3d3 5.10.

121

plot3d3.

x(u, v ) = cos(u) cos(v ) , y (u, v ) = cos(u) sin(v ) , z (u, v ) = sin(u)

u v , , u 40 20 . x, y , z plot3d3 (. 5.10). , (. . 5.5). 5.10. plot3d3 u = linspace(-%pi/2,%pi/2,20); v = linspace(0,2*%pi,20); X = cos(u)'*cos(v); Y = cos(u)'*sin(v); Z = sin(u)'*ones(v); plot3d3(X,Y,Z);

Z

Y

X

. 5.5. , plot3d3


122

5. Scilab

5.4

param3d param3d1

Scilab param3d: param3d(x,y,z,[theta,alpha,leg,flag,ebox]). param3d . 5.11. , : y = sin(t) , y1 = cos(t) , y2 = t . 7 , t. param3d, y , y1 y2 , , 45 35 (. 5.11, . 5.6). 5.11. , , param3d t=[0:0.1:10*%pi]; param3d(sin(t),cos(t),t/7,45,35);

5.12. , x= y= z=

: t § sin(t) ; t § cos(t) ; t § |t| . (50 § )

t, X , Y Z . param3d, 45 60 . (. 5.12, . 5.7).


5.4. param3d param3d1

123

4.5 4.0 3.5 3.0 2.5 Z 2.0 1.5 1.0 0.5 0.0 -1.0 -0.6 -0.2 0.2 Y 0.6 1.0 1.0 0.6 0.2 X -0.2 -0.6 -1.0

. 5.6. , param3d

5.12. , , param3d t=-50*%pi:0.1:50*%pi; x=t.*sin(t); y=t.*cos(t); z=t.*abs(t)/(50*%pi); param3d(x,y,z,45,60);

Scilab param3d1. :

param3d1(x,y,list(z,colors),[theta,alpha,leg,flag,ebox])

list(z,colors), Z - , . .


124

5. Scilab

200 150 100 50 Z 0 -50 -100 -150 -200 -200 -100 0 100 Y 200 200 100 X 0 -100 -200

. 5.7. , param3d

5.13. , x = sin(t) ; y = sin(2t) ; z = t/10 .

: x = cos(t) ; y = cos(2t) ; z = sin(t) .

t. param3d1. X Y , . list Z - (9), (5). 35 45 . 'X@Y@Z' (. 5.13, . VIII). 5.13. list param3d t=[0:0.1:5*%pi]'; param3d1([sin(t),sin(2*t)],[cos(t),cos(2*t)],... list([t/10,sin(t)],[9,5]),35,45,"X@Y@Z");


5.5. contour 5.4. mode 0 1 2

125



Z (x, y ) , Z = zlev

5.5

contour

Scilab, , . , X , Y - , Z - . . Scilab contour. : contour(x,y,z,nz[theta,alpha,leg,flag,ebox,zlev]) x, y z nz ;

í , Z (x, y ); , . nz , Z (x, y ) nz . nz , ;

theta, alpha , . , , ; leg flag , 'X@Y@Z'. , @. -

, : [mode,type,box]. mode (. . 5.4).


126 type box

5. Scilab (. . 5.2), 2; (. . 5.3). 4;

ebox

, , [xmin,xmax,ymin,ymax,zmin,zmax]. type=1; , ( ) . , , .

zlev

, contour Z (x, y ) , . , Scilab deff: deff('[s1,s2,...]=newfunction(e1,e2,...) s1,s2,... , .. , ; newfunction ; e1,e2,... , -

.

- : function = <_> endfunction lhs_arguments function_name rhs_arguments ;

; .

5.14. Z = x § sin(x)2 § cos(y ).


5.5. contour

127

t . function my_surface x, y z . , . contour (. 5.14, . IX). 5.14. Z = x § sin(x)2 § cos(y ) contour t=linspace(-%pi,%pi,30); function z=my_surface(x,y) z=x*sin(x)^2*cos(y) endfunction contour(t,t,my_surface,10); , contour . , . . 5.15. Z = sin(x) § cos(y ) . , t . Surf, deff. rect , , . , Z (x, y ) plot3d For, zij = f (xi , yj ). , feval. plot3d Z = sin(x) § cos(y ), , . flag [2,1,4]: 2 , 1 ( rect, ), 4 . , contour, , , 10 flag [1,1,4]: 1 , , (Z = sin(x) § cos(y )), 1


128

5. Scilab

( rect, ), 4 . -5 5 . xtitle (. 5.15, . X). 5.15. Z = sin(x) § cos(y ) ( plot3d) ( contour) rect t=%pi*(-10:10)/10; deff('[z]=Surf(x,y)','z=sin(x)*cos(y)'); rect=[-%pi,%pi,-%pi,%pi,-5,1]; z=feval(t,t,Surf); plot3d(t,t,z,35,45,'X@Y@Z',[2,1,4],rect); contour(t,t,z,10,35,45,'X@Y@Z',[1,1,4],rect, -5); xtitle('plot3d and contour'); . . 5.16. Z = sin(x) § cos(y ) . , t, Surf, rect, Z = sin(x) § cos(y ), feval. , ( 75 45) ( mode flag -19 ). contour location -5 mode flag 0 Z = sin(x) § cos(y ). xtitle (. 5.16, . XI). 5.16. t=%pi*(-10:10)/10; deff('[z]=Surf(x,y)','z=sin(x)*cos(y)'); rect=[-%pi,%pi,-%pi,%pi,-1,1]; z=feval(t,t,Surf);


5.6. contourf plot3d(t,t,z,35,45,'X@Y@Z',[-19,1,4],rect); contour(t,t,z+0.1,10,35,45,'X@Y@Z',[0,1,4],rect); ... xtitle('plot3d and contour');

129

5.6

contourf

Scilab contourf, , , . : contourf (x,y,z,nz,[style,strf,leg,rect,nax]) x, y z nz ; , -

Z (x, y );

, . nz , Z (x, y ) nz . nz , ;

style , nz ; strf

, sa . (Captions) (. . 5.5); s (Scaling) (. . 5.6); a (Axes) (. . 5.7). , . @. , -

leg rect

[xmin, ymin, xmax, ymax], x y ; 5.5. (Captions) strf 0 1 , leg


130

5. Scilab 5.6. s (Scaling) strf

0 1 2 3 4 5 6

rect , rect , , rect ,

5.7. a (Axes) strf 0 1 2 3 4 5 , Y , Y , (0; 0).

nax

[nx, Nx, ny, Ny], . Nx (Ny) c X (Y ); nx (ny) .

5.17. Z = sin(x) § cos(y ) contourf. t , deff surf. Z = sin(x) § cos(y ), plot3d1, , contourf, . -


5.7. hist3d

131

subplot, . feval, Z = sin(x) § cos(y ) plot3d1, 80 15, , xtitle, plot3d1 . contourf. X , Y Z , (10), 10 : 20 , , strf="121" (1 ; 2 ; 1 , Y ). , . . Scilab colorbar (n, m), n ,m . contourf xtitle (. 5.17, . XII). 5.17. Z = sin(x) § cos(y ) ( plot3d) ( contourf) t=-%pi:0.2:%pi; deff('[z]=Surf(x,y)','z=sin(x)*cos(y)'); subplot(121); z=feval(t,t,Surf); plot3d1(t,t,z,80,15); xtitle('plot3d1'); subplot(122); contourf(t,t,z,10,10:20,strf="121"); colorbar(-%pi,%pi); xtitle('contourf','X','Y');

5.7

hist3d

Scilab hist3d: hist3d(f,[theta,alpha,leg,flag,ebox]) f (m : n), f (i, j ) = F (x(i), y (j )). theta,alpha,leg,flag,ebox , plot3d.


132

5. Scilab

5.18. . rand. , (m,n), rand(m,n) (. 5.18). 5.18. hist3d hist3d(9.7*rand(10,10),20,35); . 5.8.

10 8 6 Z 2 4 2 5 0 0 1 7 2 3 4 Y 8 5 6 9 7 8 9 10 10 X 6 4 3 1 0

. 5.8. , hist3d

5.8

Scilab

Scilab. , . 5.19. Z = sin(t) § cos(t), , |Z | > 0.5.


5.8. Scilab

133

t, Z = sin(t) § cos(t) Z . Z1 find Z , 0,5. %inf. , z(z1)=%inf*z1 , %inf*z1 Z , Z1 , . , Z , , , , plot3d1 . , Z = sin(t) § cos(t) (. 5.19, . XIII). 5.19. t=linspace(-%pi,%pi,40); z=sin(t)'*cos(t); z1=find(abs(z)>0.5); z(z1)=%inf*z1; plot3d1(t,t,z); , Z , Z 0.5 -0.5. : , . 5.20. . , deff sph, X , Y , Z . , sph (. 5.20): deff('[x,y,z]=sph(alp,tet)',['x=r*cos(alp).*cos(tet)+... orig(1)*ones(tet)'; 'y=r*cos(alp).*sin(tet)+orig(2)*ones(tet); 'z=r*sin(alp)+orig(3)*ones(tet)']); r, - orig, x y. , %inf, x (5 : 8) (30 : 35).


134

5. Scilab

, , , (. . XIV). , , , . eval3dp plot3d1, 35 15. 5.20. deff('[x,y,z]=sph(alp,tet)',['x=r*cos(alp).*cos(tet)+orig(1)*... ones(tet)'; 'y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)'; 'z=r*sin(alp)+orig(3)*ones(tet)']); r=1;orig=[0 0 0]; x=linspace(-%pi/2,%pi/2,40); y=linspace(0,%pi*2,20); x(5:8)=%inf*ones(5:8); x(30:35)=%inf*ones(30:35); [x1,y1,z1]=eval3dp(sph,x,y); plot3d1(x1,y1,z1,35,15); plot3d2. . 5.21. . : x = cos(u) § u § 1 + cos (v ) ; 2 u y = § sin(v ) ; 2 (v ) . z = (sin(u) § u) § 1 + cos 2

u, v . x, y , z (. 5.21). plot3d2, , . XV. 5.21. u = linspace(0,2*%pi,40); v = linspace(0,2*%pi,20);


5.8. Scilab x= (cos(u).*u)'*(1+cos(v)/2); y= (u/2)'*sin(v); z= (sin(u).*u)'*(1+cos(v)/2); plot3d2(x,y,z); 5.22. plot3d2.

135

u [0; 2 ], v [-1; 1]. 1, 1, xy (0, 0, 0). u , v . 5.22 , . 5.25. 5.22. plot3d2 t=linspace(-1,1,20)'; x=linspace(0,%pi,40); factor=2+t*cos(x); X=factor*diag(cos(2*x)); Y=factor*diag(sin(2*x)); Z=t*sin(x); plot3d2(X,Y,Z); 5.23. plot3d2. , , . : x(u, v ) = (R + r § cos(u) § cos(v )) , y (u, v ) = (R + r § cos(u) § sin(v )) , z (u, v ) = r § sin(u) ,

. , . : x(u, v ) = 1 + v § cos u § cos(u) , 2 2 u v y (u, v ) = 1 + § cos § sin(u) , 2 2 v u z (u, v ) = § sin . 2 2


136

5. Scilab

u, v [0; 2 ], R , r . 5.23 , . 5.26. 5.23. plot3d2 x=linspace(0,2*%pi,40); y=linspace(0,2*%pi,20)'; fact=1.5+cos(y)*(cos(x)/2+0.6); X=fact*diag(cos(x)); Y=fact*diag(sin(x)); Z=sin(y)*(cos(x)/2+0.6); plot3d2(X,Y,Z,);

. 5.9.

5.24. plot3d2. 5.24 plot3d2, . 5.27.


5.8. Scilab 5.24. plot3d2 x=linspace(0,2*%pi,40); y=linspace(0,2*%pi,20)'; factor=1.5+cos(y); X=factor*cos(x); Y=factor*sin(x); Z=sin(y)*ones(x)+ ones(y)*cos(2*x); plot3d2(X,Y,Z);

137

. 5.10.


6 SCILAB

, . , Scilab .

6.1



P (x) = 0, P (x) , , . x a0 xn +a1 xn-1 +§ § §+an-1 x+an = 0, a0 = 0, n 1 ai ní . , , , . Scilab . P (x) poly, , roots. , Scilab poly(a, "x ["fl"]), a , x , fl , . fl roots coeff ( r c ). fl=c, , a. fl=r,


6.1.

139

a , . fl=r. p, , f 3. 6.1. -->p=poly(3,'x','r'); -->f=poly(3,'x','c'); -->p p= -3+x -->f f= 3 . 6.2. poly -->// -->poly([1 0 ans = 2 2x - 3x + -->// -->poly([1 0 ans = 2 1 + 2x 1, 0 2 2],'x') 3 x 1, 0 2 2],'x','c')

: 6.3. -->p1=poly([-1 2],'x','c') p1 = - 1 + 2x -->p2=poly([3 -7 2],'x','c') p2 = 2 3 - 7x + 2x -->p1+p2 // ans = 2 2 - 5x + 2x


140

6. SCILAB -->p1-p2 // ans = 2 4 + 9x - 2x -->p1*p2 // ans = 2 3 - 3 + 13x - 16x + 4x -->p1/p2 // ans = 1 -----3+x -->p1^2 // ans = 2 1 - 4x + 4x -->p2^(-1) // ans = 1 ----------2 3 - 7x + 2x

roots(p) . p , poly P (x) = 0. .

6.1. 2x4 - 8x3 + 8x2 - 1 = 0. p. poly, V . , x , , :


6.1. 6.4. -->V=[-1 0 8 -8 2]; -->p=poly(V,'x','c') p= 2 3 4 1 + 8x - 8x + 2x : 6.5. roots -->X=roots(p) X= ! 0.4588039 ! - 0.3065630 ! 1.5411961 ! 2.306563

141

! ! ! !

1 , . 6.1, , .

18 16 14 12 10 8 6 4 2 0 -1.0 -0.5 0.0 -2 0.5 1.0 1.5 2.0 2.5 3.0

. 6.1. 6.1

6.2. x3 + 0.4x2 + 0.6x - 1 = 0. , :
1 f (x) = 0 f (x) .


142

6. SCILAB 6.6. 6.2 -->roots(poly([-1 0.6 0.4 ans = ! 0.7153636 ! - 0.5576818 + 1.0425361i ! - 0.5576818 - 1.0425361i 1],'x','c')) ! ! !

, (. 6.2) .

1.0

0.5

0.0 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 -0.5 0.2 0.4 0.6 0.8 1.0

-1.0

-1.5

-2.0

-2.5

. 6.2. 6.2

6.3. y (x) = 0, y (x) = x4 - 18x2 + 6. 6.7 . . 6.3. 6.7. 6.3 -->x=poly(0,'x'); -->y=x^4-18*x^2+.6; -->roots(y) ans = ! 0.1827438 ! ! - 0.1827438 ! ! - 4.2387032 ! ! 4.2387032 !


6.2.

143

200

150

100

50

0 -6 -4 -2 0 2 4 6

-50

-100

. 6.3. 6.3

6.2



f (x) = 0, , . , . f (x) = 0 . . . , .. , . , , f (x) 1 . , , , . Scilab fsolve(x0,f) x0 , f , y (x) = 0. . 6.4. 3

3

(x - 1)2 -

x2 = 0.

1 : f (x) [a, b] , .. f (a) § f (b) < 0, .


144

6. SCILAB

. . , , f (x) - g (x) = 0, f (x) g (x) . 3 f (x) = 3 (x - 1)2 , g (x) = x2 . . 6.4 , [0; 1].

1.6

1.4

1.2

1.0

0.8

0.6

0.4

0.2

0.0 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0

. 6.4. 6.4 , , : 6.8. 6.4 -->deff('[y]=f1(x)','y1=((x-1)^2)^(1/3),y2=(x^2)^(1/3),y=y1-y2') -->fsolve(0,f1) ans = 0.5 6.5. f (x) = ex /5 - 2(x - 1)2 . . 6.5 , f (x) , .. . fsolve , : 6.9. 6.5 -->deff('[y]=f(x)','y=exp(x)/5-2*(x-1)^2') -->x(1)=fsolve(0,f);x(2)=fsolve(2,f);x(3)=fsolve(5,f); -->x


6.2.

145

10

8

6

4

2

0 -1 -2 0 1 2 3 4 5 6

-4

-6

-8

. 6.5. 6.5

x

=! ! !

0.5778406 ! 1.7638701 ! 5.1476865 !

, , : 6.10. 6.5 ( ) -->fsolve([0;2;5],f) ans = ! 0.5778406 ! ! 1.7638701 ! ! 5.1476865 ! 6.6. sin(x) - 0.4x = 0 [-5 ; 5 ]. 6.11. 6.11. 6.6 -->deff('[y]=fff(x)','y=-0.4+sin(x)') -->V=[-5*%pi:%pi:5*%pi]; X=fsolve(V,fff); -->X // X = !-16.11948 -12.154854 -9.8362948 -5.8716685 -3.5531095 0.4115168 2.7300758 6.6947022 9.0132611 12.977887 15.296446! 6.7. y (x) = 0, y (x) = x5 - x3 + 1.


146

6. SCILAB

, , (. 6.6) í2 í1.

6 5 4 3 2 1 0 -1.5 -1.0 -0.5 0.0 -1 -2 -3 -4 0.5 1.0 1.5 2.0

. 6.6. 6.7 fsolve: 6.12. 6.7 -->deff('[f]=y(x)','f=x^5-x^3+1') -->X=fsolve(-2,y) X = 1.2365057 roots: 6.13. 6.7 roots -->roots(poly([1 0 0 -1 0 1],'x','c')) ans = ! 0.9590477 + 0.4283660i ! ! 0.9590477 - 0.4283660i ! ! - 0.3407949 + 0.7854231i ! ! - 0.3407949 - 0.7854231i ! ! - 1.2365057 ! , , ( 6.12), ( 6.13). roots.


6.3.

147

6.3


n m . Scilab fsolve(x0,f).

m n , ,

6.8. : {x2 + y 2 = 1 ; x3 - 1 = 0}. (. 6.7) , .

1.0 0.8 0.6 0.4 0.2 0.0 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 0.2 0.4 0.6 0.8 1.0

. 6.7. [0.8; 0.6] [-0.8; -0.6]. . fsolve, í: 6.14. 6.8 function [y]=fun(x) y(1)=x(1)^2+x(2)^2-1; y(2)=x(1)^3-x(2); endfunction -->exec('C:\fun.sce'); disp('exec done'); exec done -->fsolve([0.5 0.5],fun) ans = 0.8260314 0.5636242 -->fsolve([-0.5 -0.5],fun) ans = - 0.8260314 - 0.5636242


148

6. SCILAB

6.9. : 6.15. 6.9 function [y]=fun(x) y(1)=x(1)^2+x(2)^2+x(3)^2-1 y(2)=2*x(1)^2+x(2)^2-4*x(3) y(3)=3*x(1)^2-4*x(2)+x(3)^2 endfunction -->exec('D:\scilab 3\fun');disp('exec done'); exec done -->fsolve([0.5 0.5 0.5],fun)// ans = ! 0.7851969 0.4966114 0.3699228 !


7

Scilab .

7.1



Scilab inttrap([x,]y). y (x), (x, y ). x . inttrap(y) x y . 7.1.
13


5

2x - 1 dx.
13


5

2x - 1 dx =

(2x - 1)3 , 3

í1 :
1

-: Zb
a

f ( x ) = F ( b) - F ( a ) .


150

7. 7.1. 7.1 -->a=5;b=13; -->I=1/3*(2*b-1)^(3/2)-1/3*(2*a-1)^(3/2) I = 32.666667

1 . 0.5 0.1. , :

. , ,

7.2. 7.1 inttrap -->x=a:b;y=sqrt(2*x-1); -->inttrap(x,y) ans = 32.655571 -->h=0.5; x=a:h:b; y=sqrt(2*x-1); -->inttrap(x,y) ans = 32.66389 -->h=0.1; x=a:h:b; y=sqrt(2*x-1); -->inttrap(x,y) ans = 32.666556 7.3 inttrap . , , , , inttrap(x,y) [5; 13] 1. .. h = 1 , y . , , . , , 0.1, x y , inttrap(y) h = 1 , y . , .
1 , .


7.2. 7.3. inttrap -->x=a:b;y=sqrt(2*x-1); -->inttrap(y) ans = 32.655571 -->h=0.1;x=a:h:b;y=sqrt(2*x-1); -->inttrap(y) ans = 326.66556

151

7.2



í, , ,
b n

y dy = (b - a)
a

Hi y
i=0

i

(7.1)

Hi , í. (7.1) n = 1, , n = 2 . . n > 2 í . Scilab : integrate(fun, x, a, b, [,er1 [,er2]]) x fun , ; , ; a, b , ; er1 er2 , ( ).

7.2. 7.1 7.4. 7.4. integrate -->integrate('(2*x-1)^0.5','x',5,13) ans = 32.666667


152

7.

7.3



Scilab : [I,err]=intg(a, b, name [,er1 [,er2]]) name , ( ( ) ); a b ; er1 er2 ( ). 7.3. 7.1 7.5. 7.5. intg -->deff('y=G(x)','y=sqrt(2*x-1)'); intg(5,13,G) ans = 32.666667 7.4.
0 1

t

2

(3 + sin(t))

dt.

7.6. 7.6. 7.4 -->function y=f(t),y=t^2/sqrt(3+sin(t)),endfunction; -->[I,er]=intg(0,1,f) er = 1.933D-15 I= 0.1741192

7.4

,

, y (x), xi (i = 0, 1, . . . , n) [a, b] yi = f (xi ), , x0 , x1 , . . . , xk (k n), y = f (x), y = f (x) . . y (x0 ) = 1 h y0 - 2 y0 3 y0 4 y0 5 y0 + - + - ... 2! 3! 4! 5! , (7.2)


7.4.

153

, . Scilab dy=diff(y[,n]), y y (x) , n . dy, n y , 2 y , . . . , k y . .

7.5. y (50) y = lg(x), .

7.7. 7.7. diff -->h=5;x=50:5:65; -->y=log10(x) y = 1.69897 1.7403627 1.7781513 1.8129134 -->dy=diff(y) dy = 0.0413927 0.0377886 0.0347621 -->dy2=diff(y,2) dy2 = - 0.0036041 - 0.0030265 -->dy3=diff(y,3) dy3 = 0.0005777 -->// y'(50) (7.2) -->Y=(dy(1)-dy2(1)/2+dy3(1)/3)/h Y = 0.0086775 -->// y'(50) lg'(x)=1/ln(10)/x -->1/log(10)/x(1) ans = 0.0086859 -->// y'(x), x=50,55,60 (7.2) -->Y=(dy-dy2(1:$-1)/2+dy3(1:$-2)/3)/h Y= 0.0086389 0.0079181 0.0073128 -->// y'(x), x=50,55,60, lg'(x)=1/ln(10)/x -->(1/log(10))./x(1:$-1) ans = 0.0086859 0.0078963 0.0072382


154

7.

7.5

.

g=numdiff(fun,x) fun , . y=fun(x [, p1, p2,..., pn]), x , . p1, p2, . . . , pn , , , : g=numdiff(list(fun,p1,p2,...pn),x). d gij = dfij . x . 7.6. f (1), f (x) = (x + 2)3 + 5x. 7.8 . 7.8. 7.6 -->function f=my(x), f=(x+2)^3+5*x, endfunction; -->numdiff(my,1) ans = 32. -->x=1;3*(x+2)^2+5 ans = 32. 7.7. f (x) 0, 1, 2, 3 f (x) = (x + 2)3 + 5x. : 7.9. 7.7 -->v=0:3; -->numdiff(my,v) ans = 17. 0. 0. 0. 0. 32. 0. 0. 0. 0. 52.999999 0. 0. 0. 0. 80.000002 -->function f1=my1(x), f1=3*(x+2)^2+5, endfunction; -->my1(v) ans = 17. 32. 53. 80.


7.5.

155

7.8. y (x1 , x2 , x3 ) = x1 xx3 + x2 x3 . 1 2 dy dy dy , , (1, 2, 3). dx1 dx2 dx3 7.10. 7.10. 7.8 -->function [Y]=f(X), Y=X(1)*X(2)^X(3)+X(1)^2*X(3),endfunction -->X=[1 2 3]; -->numdiff(f,X) ans = 14. 12. 6.5451775 -->//--------------------------------->function [Y]=f1(X), Y(1)=X(2)^X(3)+2*X(1)*X(3), Y(2)=X(1)*X(3)*X(2)^(X(3)-1), Y(3)=x(1)*X(2)^X(3)*log(X(2))+X(1)^2, endfunction -->f1(X) ans = 14. 12. 6.5451774


8

n- H (t, x, x , x , ..., x(n) ) = 0 . : x = 1 x = 2 (8.1)

x(t), n-

f1 (t, x1, x2 , . . . , xn ) f2 (t, x1, x2 , . . . , xn ) §§§ x = fn (t, x1, x2 , . . . , xn ) n

(8.2)

:

, (8.2) ) ) xn (t) x1 (t x2 (t . . .

, . . .

x(t) =

(8.3)


8.

157

: ( ) ; . . , , . . , . Scilab [y,w,iw]=ode([type],y0,t0,t [,rtol [,atol]],f [,jac] [,w,iw]) : y0 ; t0 ; t , ; f , (8.2); y (8.3). , dy = f (t, y ), y (t0 ) = y0 , dt y=ode(y0,t0,t,f). ode: type , , : adams - ; stiff ; rk ; rkf ; fix , ;

rtol, atol , , y, rtol=0.00001, atol=0.0000001, rkf fix - rtol=0.001, atol=0.0001; jac , , J=jak(t,y); , , , .

w, iw


158

8.

. 8.1.
dx dt

+ x = sin(xt), x(0) = 1.5.

dx : = -x + sin(xt), x(0) = 1.5. dt , , , . 8.1

1.5

1.0

0.5

0.0 0 5 10 15 20 25 30 35

. 8.1. 8.1 y=ode(x0,t0,t,f), : f t f (t, x); ; x(0) = 1.5;

x0, t0 y

. 8.1. 8.1 -->function yd=f(t,x),yd=-x+sin(t*x),endfunction; -->x0=1.5;t0=0;t=0:1:35; -->y=ode(x0,t0,t,f); -->plot(t,y)


8. 8.2. x = cos(xy ) , y = sin(x + ty ) , x(0) = 0, y (0) = 0. [0; 10].

159

, , Scilab, (. 8.2). 8.2. 8.2 //, function dy=syst(t,y) dy=zeros(2,1); dy(1)=cos(y(1)*y(2)); dy(2)=sin(y(1)+y(2)*t); endfunction // x0=[0;0];t0=0;t=0:*0.1*:10;y=ode(x0,t0,t,syst); // plot(t,y)

6

5

4

3

2

1

0

-1 0 1 2 3 4 5 6 7 8 9 10

. 8.2. 8.2


160

8.

8.3. 119.46 -10.395 dX = -53.302 dt -115.58 :

: 185.38 126.88 121.03 -10.136 -3.636 8.577 X; X (0) = -85.932 -63.182 54.211 -181.75 -112.8 -199



1 1 . 1 1

8.3. 8.3 -->B=[119.46 185.38 126.88 121.03;-10.395 -10.136 -3.636 8.577; -->-53.302 -85.932 -63.182 -54.211;-115.58 -181.75 -112.8 -199]; -->function dx=syst1(t,x), dx=B*x,endfunction -->function J=Jac(t,y),J=B,endfunction -->x0=[1;1;1;1]; t0=0; t=0:0.01:5; -->y=ode("stiff",x0,t0,t,syst1,Jac); -->plot(t,y); xgrid(); . 8.3.

20

15

10

5

0

-5

-10

-15 0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

5.0

. 8.3. 8.3


8. 8.4. dx1 dt = dx2 dt = dx 3 = dt

161

: -7x1 + 7x2 -1 X (0) = 0 . 157x1 - 1.15x2 x3 , 1 0.96x1 x2 - 8.36x3

. 8.4 [0; 2].

300 250 200 150 100 50 0 -50 -100 -150 -200 0.0

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.8

2.0

. 8.4. 8.4 Scilab, : 8.4. 8.4 function dx=syst2(t,x) // dx=zeros(3,1); dx(1)=-7*x(1)+7*x(2); dx(2)=157*x(1)+x(2)-1.15*x(1)*x(3); dx(3)=0.96*x(1)*x(2)-8.36*x(3); endfunction -->>// -->x0=[-1;0;1]; t0=0; t=0:0.01:2;y=ode("stiff",x0,t0,t,syst2); -->plot(t,y); xgrid();


162

8.

8.5. [0.25; 2]: d2 x dx +4 + 13 = es dt2 dt
in(t)

,

x(0.25) = -1,

x (0.25) = 1.

, y = dy = -4y - 13x + es dt
in(t)

dx : dt x(0.25) = -1.

,

dx = y, dt

y (0.25) = 1,

: 8.5. 8.5 function F=FF(t,x) F=[-4*x(1)-13*x(2)+exp(t);x(1)]; endfunction -->// -->X0=[1;-1];t0=0.25;t=0.25:0.05:2; -->y=ode("stiff",X0,t0,t,FF); -->// -->plot(t,y); xgrid(); . 8.5.

2.5

2.0

1.5

1.0

0.5

0.0

-0.5

-1.0 0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.8

2.0

. 8.5. 8.5


9 Scilab

Scilab . , Scilab. , Scilab , . , ( Scilab ) : 1. Editor (. . 9.1). 2. Scipad . 3. File í Save sce , , file.sce . 4. , exec, , exec("file.sce"). File í Exec . . . , Scipad, Execute í Load into Scilab (Ctrl+L ). , . , Scilab ( Scilab sci).


164

9. Scilab

. 9.1. Scipad

9.1

sci-

sci- -.

9 .1 .1

- Scilab

Scilab x=input('title'); x=x_dialog('title', 'stroka'); input Scilab title , , . x_dialog title, OK, stroka x, stroka,


9.1. sci-

165

x. 9.2 , x=x_dialog('Input X', '5').

. 9.2. input , x_dialog . x_dialog evstr. x_dialog : x=evstr(x_dialog('title','stroka')); disp : disp(b) b .

9 .1 .2



a=b a , b . a b.

9 .1 .3



, , if. if Scilab. if


166 if 1 else 2 end

9. Scilab

, 1, 2 Scilab . if : , 1, 2. Scilab : &, and ( ), |, or ( ), ~, not ( ) : < (), > (), == (), ~=, <> ( ), <= ( ), >= ( ). . , , else if, if. if 1 1 elseif 2 2 elseif 3 3 ... elseif n n else end if : 1 1, 2, 2, 3 . . else elseif , else. , ,

9.1. ax4 + bx2 + c = 0. y = x2 . y .


9.1. sci-

167

a, b, c. x1 , x2 , x3 , x4 , . : 1. a, b c; 2. d; 3. d < 0, y1 y2 , . 4. y1 < 0 y2 < 0 , . 5. y1 0 y2 0, ‘ y1 , ‘ y2 . 6. 4) 5) , y1 . 7. y1 , ‘ y1 , ‘ y2 . sci- 9.1, 9.2. 9.1. // . a=input('a='); b=input('b='); c=input('c='); // . d=b*b-4*a*c; // , if d<0 // , disp('Real roots are not present'); else // // . x1=(-b+sqrt(d))/2/a; x2=(-b-sqrt(d))/2/a; // , if (x1<0)&(x2<0) // . disp('Real roots are not present'); //, , elseif (x1>=0)&(x2>=0)


168

9. Scilab // . disp('Four real roots'); y1=sqrt(x1); y2=-y1; y3=sqrt(x2); y4=-y2; disp(y1,y2,y3,y4); //, (x1<0)&(x2<0) (x1>=0)&(x2>=0) // , else // disp('Two real roots'); // x1. if x1>=0 // x1 , // x1, y1=sqrt(x1); y2=-y1; disp(y1); disp(y2); // ( - x2 ), // // x2. else y1=sqrt(x2); y2=-y1; disp(y1); disp(y2); end end end 9.2. -->exec("G:/Lecture Scilab EG/2/l1.sci"); a=-->-6 b=-->9 c=-->-1 Four real roots 0.3476307 1.1743734 - 0.3476307 0.3476307

if, , Scilab (. 9.3).


9.1. sci- 9.3. a=input('a='); b=input('b='); c=input('c='); d=b*b-4*a*c; x1=(-b+sqrt(d))/2/a; x2=(-b-sqrt(d))/2/a; y1=sqrt(x1); y2=-y1; y3=sqrt(x2); y4=-y3; disp(y1,y2,y3,y4);

169

, 9.3 (. 9.4). 9.4. -->a=3 -->b=8 -->c=-1 -1.6692213i 1.6692213i -0.3458800 0.3458800

9 .1 .4



select : select case 1 then 1 case 2 then 2 ... else end select : 1, 1, , 2, 2. , 3, 3 . . case, , else.


170

9. Scilab

, select, if, select . select . 9.2. , D, , 31 1- . , 1- . D , , , . x k x - int(x/k ) x. , . , (. 9.5). 9.6. 9.5. 9.2 D=input('Enter a number from 1 to 31'); // D 7, // 0 6. select D-int(D/7)*7 case 1 then disp('Monday'); case 2 then disp('Tuesday'); case 3 then disp('Wednesday'); case 4 then disp('Thursday'); case 5 then disp('Friday'); case 6 then disp('Saturday'); else disp('Sunday'); end 9.6. 9.2 -->exec('G:\Lecture Scilab EG\2\l2.sci');disp('exec done'); Enter a number from 1 to 31-->19 Friday Scilab. sci- : while for.


9.2. Scilab

171

9 .1 .5

while

while while end ; , . while , , . for .

9 .1 .6

for

for for x=xn:hx:xk end x , xn , xk , hx . 1, hx , for . for x=xn:xk end (x = xn). , (x > xk). x > xk, , . x xk , ( ). hx (x = x + hx). , .

9.2

Scilab

sci- . (, ) sci- ( ), Scilab .


172

9. Scilab

sci-.

9 .2 .1

-

. 9.7 9.8 sci. 9.7. N=input('N='); disp('Vvod massiva x'); for i=1:N x(i)=input('X='); end disp(x); 9.8. N=input('N='); M=input('M='); disp('Vvod matrici'); for i=1:N for j=1:M a(i,j)=input(''); end end disp(a); () disp () 1 .

9 .2 .2

()

, : 0 (s = 0), s s, s s s . .
1 , () , () Scilab.


9.2. Scilab

173

: 1 (p = 1). p , p . . 9.9í9.12 , . 9.9. // s 0. s=0; // for i=1:length(x) // s=s+x(i); end 9.10. p=1; for i=1:length(x) p=p*x(i); end 9.11. s=0; // N M A. [N,M]=size(A); for i=1:N for j=1:M s=s+a(i,j); end end disp(s); 9.12. // (p) 1. p=1; // N M A. [N,M]=size(A); // . for i=1:N // .


174

9. Scilab for j=1:M // p . p=p*a(i,j); end end

9 .2 .3

() ()

. Max , Nmax . , Max, Nmax (1). , , . , Max, Nmax i. 9.13 . 9.13. // Max . Max=a(1); // Nmax //, 1. Nmax=1; // , . for i=2:N // Max, if x(i)>Max // , Max=x(i); // i. Nmax=i; end; end; , if > < . 9.14 : Nmin , Lmin . , () i j 1. ,


9.2. Scilab

175

ai,j min. 9.14. // Min a(1,1), Nmin Lmin 1. Min=a(1,1); Nmin=1; Lmin=1; for i=1:N for j=1:M // Min, if a(i,j)
9 .2 .4


. , X n , §§ X [n] ,

1 X [1] X [2] § , X [1] X [2]

§§§

X [n] .

. , , . , , . . . , i- (i + 1)-, . . . , (n - 1)- n- . (n-) . , (n-) , . (n - 1)- , , .
1

-

.


176

9. Scilab

> < . 9.15 sci-, . 9.15. x=[-3 5 7 49 -8 11 -5 32 -11]; for i=1:length(x)-1 for j=1:length(x)-i // , //, if x(j)>x(j+1) // . b=x(j); x(j)=x(j+1); x(j+1)=b; end; end; end; // . disp(x);

9 .2 .5



x, n , m- . (m + 1)- m, (m + 2)- (m + 1)-, . . . , n- (n - 1)-, n- . 9.16 , . 9.16. m- x(n) x=[3 2 1 5 4 6 8 7]; disp(x); n=length(x); // . m=input('m='); // , m- . for i=m:n-1 x(i)=x(i+1); end; // n- . x(:,n)=[]; // n 1. n=n-1; // . disp(x);


9.3. Scilab

177

9.3

Scilab

Scilab 1 .

9 .3 .1

mop en

, . sci- mopen, : [fd,err]=mopen(file,mode) file mode , , : 'r' 'rb' 'w' 'wb' 'a' 'ab' 'r+' , , , ; , ; , ; , ; , ; , ; , ;

'rb+' , ; 'w+' ;

'wb+' ; 'a+' ; , ;

'ab+' ; , .
1 , sci- .


178

9. Scilab

mopen fd err. (), . err 0 . err = 0, , .

9 .3 .2

mfprintf

mfprintf mfprintf(f, s1, s2) f ( mopen), s1 , s2 . : %[][][.][]1 9.1. , . 9.2.

9 .3 .3

mfscanf

mfscanf : A=mfscanf(f, s1) f , mopen, s1 %[][.] mfscanf : f A s1. , , , . , , meof(f) (f ), , , .
1

.


9.3. Scilab

179

9.1. + # . . . + , : 0 , 0 (0) . . n , . . , n, . e, E, f n char, . int unsigned int unsigned, a-f, A-F. [-]dddd.dddd [-]d.dddde[+|-]ddd [-]d.ddddE[+|-]ddd e f E F () d, i, o, u, x, X d, i, o, u, x, X

n

0n

n d, i i o u x, X f e E g G s h l


180

9. Scilab 9.2. \b \n \r \t \' \" \? , ?

9 .3 .4

mclose

mclose : mclose(f) f . mclose('all') , . 9.17. 9.17. // abc.txt N M // A(N,M) //N - . N=3; //M- . M=4; A=[2 4 6 7; 6 3 2 1; 11 12 34 10]; // abc.txt . f=mopen('abc.txt','w'); // abc.txt N M, //. mfprintf(f,'%d\t%d\n',N,M); for i=1:N for j=1:M // abc.txt A. mfprintf(f,'%g\t',A(i,j)); end //


9.3. Scilab // << >>. mfprintf(f,'\n'); end mclose(f); . 9.3.

181

. 9.3. 9.18. 9.18. f=mopen('abc.txt','r'); N=mfscanf(f,'%d'); M=mfscanf(f,'%d'); for i=1:N for j=1:M A(i,j)=mfscanf(f,'%g'); end end mclose(f); -, 9.17, 9.19.


182

9. Scilab 9.19. - N= 3. M= 4. A= ! 2. 4. 6. 7. ! ! 6. 3. 2. 1. ! ! 11. 12. 34. 10. !

9.4

Scilab

sci- . 9.3. Y X , X , . 9.20. min1 , Scilab min. min min. 9.20. 9.3 // y. N=input('N='); disp('Vvod massiva Y'); // y. for i=1:N y(i)=input('Y='); end disp(y); // k // y, , x. // k=0. k=0; // y. for i=1:N // , if y(i)>0 // k 1, k=k+1;


9.4. Scilab // y x. x(k)=y(i); end; end; // x. disp(x); // s x, // min1 - x, Nmin //- x. s=x(1); min1=x(1); Nmin=1; // x. for i=2:k // . s=s+x(i); // . if x(i)
183


184

9. Scilab

9.5

Scilab

Scilab . Scilab : function [y1,y2,...,yn]=ff(x1,x2,...,xm) endfunction x1, x2, . . . , xm ; y1, y2, . . . , yn , ff . , , exec . exec('file',-1). file , . . 9.4. A(N , N ) , , , . N A primer.txt (. . 9.4). (summa), (maximum) (kolichestvo) , : function [summa, maximum, kolichestvo]=matrica_A(N,N) 9.21. 9.21. matrica_A function [summa, maximum, kolichestvo]=matrica_A(A,N) summa=0; for i=1:N // , A(i,i) // A(i,N+1-i) summa=summa+A(i,i)+A(i,N+1-i); end // , , // //, : //, , // .


9.5. Scilab

185

. 9.4. primer.txt

if (N-int(N/2)*2)==1 summa=summa-A(int(N/2)*2+1,int(N/2)*2+1); end // A(1,1) , // 1. maximum=A(1,1);kolichestvo=1; for i=1:N for j=1:N // A(i,j) , // , 1. if A(i,j)>maximum maximum=A(i,j); kolichestvo=1; // , // 1. elseif A(i,j)==maximum kolichestvo=kolichestvo+1; end end end endfunction


186

9. Scilab

, matrica_A, 9.22, 9.23. 9.22. matrica_A f=mopen('G:\primer.txt','r'); N=mfscanf(f,'%d'); for i=1:N for j=1:N B(i,j)=mfscanf(f,'%g'); end end mclose(f); [s,m,k]=matrica_A(B,N); 9.23. -->exec("matrica_2.sci"); -->s s= 21. -->m m= 67. -->k k= 4. Scilab. .


10 Scilab

Scilab , , Scilab. Scilab .

10.1



figure. F=figure(); ob jfigure1. ob jfigure1, ob jfigure2 . . 1 F. 'position',[x y dx dy], x, y ( ) ; dx dy ( ) ; ( ) .

1 , .


188

10. Scilab

. 1. . figure F=figure('1', '1', '2', '2', ..., 'n', 'n') '1' , 1 , '2' , 21 . . , F=figure('position', [10 100 300 200]); , . 10.1.

. 10.1.

2. set(f,'','') ; f , '' , '' . (. 10.2). f=figure(); set(f,'position',[20,40,600,450])
1 i , , , .


10.1.

189

. 10.2.

'figure_name', 'name', ('name'). 10.1 FIRST WINDOWS (. . 10.3). 10.1. FIRST WINDOW f=figure(); set(f,'position',[20,40,600,450]); set(f,'figure_name','FIRST WINDOW'); f=figure('position',[20,40,600,450],'figure_name','FIRST WINDOW'); close(f), f . delete(f), f .


190

10. Scilab

. 10.3. FIRST WINDOW

10.2

.

Scilab . , ( ) (, , . .) . uicontrol, : C=uicontrol(F, 'Style', '_', '_1', _1, '_2', _2,..., '_k',_k); C F ;

, ( ); uicontrol , , () ;


10.2.

191

'Style' Style, ( ); '_' , Slider, Panel, , PushButton, Radiobutton, dit, StaticText, Button Group, Listbox , ;

'_k', _k , . set: set(C,'_1',_1, '_2', _2, ..., '_k', _k) C , . C , set C(i); '_k', _k .

get : get(C,'') C , ; '' , .

. .

1 0 .2 .1



PushButton uicontrol, 'Style' 'pushbutton'. , , String (. 10.2 . 10.4).


192

10. Scilab 10.2. // d=figure(); // , Style. dbt=uicontrol(d,'Style','pushbutton'); // YES set(dbt,'String','YES');

. 10.4. YES , : § ; § ; § . 10.3, . 10.5 , . 10.3. // . f=figure(); // . set(f,'position',[0,0,250,100]) // () . set(f,'figure_name',' '); // (style - pushbutton), //, position. Button=uicontrol('style','pushbutton','string','',... 'position',[50,50,100,20]);


10.2.

193

. 10.5.

, , . , . , . CallBack, uicontrol. CallBack , . uicontrol Button=uicontrol('style', 'pushbutton', 'string', 'Button', 'CallBack', 'Function'); Function CallBack . , y = sin(x) (. 10.4). , . 10.6, Button gr_sin, , . 10.7. 10.4. CallBack f=figure(); set(f,'position',[0,0,250,100]) set(f,'figure_name','Grafik'); // , // gr_sin. Button=uicontrol('style','pushbutton','string','Button',... 'position',[50,50,100,20],'CallBack','gr_sin'); function y=gr_sin() x=-5:0.2:5; y=sin(x); plot(x,y); xgrid(); endfunction


194

10. Scilab

. 10.6.

. 10.7. y = sin(x)

1 0 .2 .2



. 'Style' uicontrol 'text'. ( ). 'String' . () uicontrol (. 10.5 . 10.8):


10.2. 10.5.

195

f=figure(); uicontrol('Style','text','Position',[10,130,150,20],'String',... 'Metka');

. 10.8. , HorizontalAlignment. : left center right ; ( ); .

, 4 HorizontalAlignment. 10.6, . 10.9. 10.6. hFig=figure(); set(hFig,'Position',[50,50,300,200]); hSt1=uicontrol('Style','text','Position',[30,30,150,20],... 'String', 'Metka 1'); set(hSt1,'BackgroundColor',[1 1 1]); set(hSt1,'HorizontalAlignment','left'); hSt2=uicontrol('Style', 'text', 'Position', [30,60,150,20],... 'HorizontalAlignment', 'center', 'BackgroundColor', [1 1 1],... 'String', 'Metka 2'); hSt3=uicontrol('Style','text','Position',[30,90,150,20],... 'HorizontalAlignment','right','BackgroundColor',[1 1 1],...


196

10. Scilab 'String','Metka 3'); hSt4=uicontrol('Style','text','Position',[30,120,150,20],... 'BackgroundColor',[1 1 1],'String','Metka 4');

. 10.9.

1 0 .2 .3



, . 'Style' 'checkbox', 'Style' 'radiobutton'. (Radiobutton), uicontrol. 10.7 . 10.10. 10.7. hFig=figure(); R=uicontrol('Style','radiobutton','String','name','value',1,..., 'Position', [25,150,70,30]); ( 'value'), ( 'value' 1) ( 'value' 0). 'value' set. : set(Rb,'value',0) 'value' get. 'CallBack', . uicontrol:


10.2.

197

. 10.10.

r1=uicontrol('Style','radiobutton','String','sin(x)','value', 0,'CallBack','F1'); F1 , . , 'CallBack' , , . , , Plot (. 10.8 . 10.11). 10.8. // . hFig=figure('Position',[50,50,200,200]); // hRb1=uicontrol('Style','radiobutton','String','sin(x)',... 'value',1, 'Position',[25,100,60,20]); hRb2=uicontrol('Style','radiobutton','String','cos(x)',... 'value',1, 'Position',[25,140,60,20]); // Plot, //Radio //. Button=uicontrol('style','pushbutton','string','Plot',... 'position',[20,50,80,20],'CallBack','Radio'); // Close, //Final . Button1=uicontrol('style','pushbutton','string','Close',... 'position',[20,25,80,20],'CallBack','Final'); // Radio, function Radio()


198

10. Scilab newaxes; x=-2*%pi:0.1:2*%pi; if get(hRb1,'value')==1 // , y=sin(x); plot(x,y,'-r'); // xgrid(); end; if get(hRb2,'value')==1 // , y=cos(x); plot(x,y,'-b'); // xgrid(); // end; endfunction //, Close . function Final() close(hFig); endfunction

. 10.11. . 10.11 . Plot , (. . 10.12). , Plot . Close . . . 'CallBack' . , 'value' 1. . .


10.2.

199

. 10.12.

1 0 .2 .4



( 'Style' 'edit') . , , . . , Enter, CallBack. 'String', . uicontrol. set, get. , HorizontalAlignment ( ). , , 'String' eval ( evstr) ( ).


200

10. Scilab

. 10.1. . . 10.9. 10.9. f=figure(); // . // . set(f,'position',[0,0,700,300]) // . set(f,'figure_name',''); // //. // A=. lab_a=uicontrol(f,'style','text','string','A=','position',... [50, 250, 100, 20]); // B=. lab_b=uicontrol(f,'style','text','string','B=','position',... [150, 250, 100, 20]); // C=. lab_c=uicontrol(f,'style','text','string','C=','position',... [250, 250, 100, 20]); // a. edit_a=uicontrol(f,'style','edit','string','1','position',... [50, 230, 100, 20]); // b. edit_b=uicontrol(f,'style','edit','string','2','position',... [150, 230, 100, 20]); // c. edit_c=uicontrol(f,'style','edit','string','1','position',... [250, 230, 100, 20]); // , . textresult=uicontrol(f,'style','text','string','','position',... [5, 80, 650, 20]); //, . radio_bikv=uicontrol('style','radiobutton','string',... ' ?', 'value',1,'position',... [100,100,300,20]);


10.2.

201

BtSolve=uicontrol('style','pushbutton','string','',... 'CallBack', 'Solve','position',[50,50,120,20]); BtClose=uicontrol('style','pushbutton','string','',... 'CallBack', '_Close','position',[300,50,120,20]); // . function Solve() // // . a=eval(get(edit_a,'string')); b=eval(get(edit_b,'string')); c=eval(get(edit_c,'string')); d=b*b-4*a*c; // , , if get(radio_bikv,'value')==0 // , if d<0 set(textresult,'string',' '); else x1=(-b+sqrt(d))/2/a; x2=(-b-sqrt(d))/2/a; set(textresult,'string',sprintf ("2 \t x1=%1.2f\tx2=%1.2f",x1,x2)); end; // , else // . if d<0 set(textresult,'string',' '); else y1=(-b+sqrt(d))/2/a; y2=(-b-sqrt(d))/2/a; if(y1<0)&(y2<0) set(textresult,'string',' '); elseif (y1>=0)&(y2>=0) x1=sqrt(y1);x2=-x1;x3=sqrt(y2);x4=-x3; set(textresult,'string',sprintf("4 ... \t x1=%1.2f\tx2=%1.2f\tx3=%1.2f\tx4=%1.2f",... x1,x2,x3,x4)); else if y1>=0 x1=sqrt(y1);x2=-x1; else x1=sqrt(y2);x2=-x1; end;


202

10. Scilab set(textresult,'string',sprintf ("2 \t x1=%1.2f\tx2=%1.2f",x1,x2)); end; end; end endfunction // . function _Close() close(f) endfunction

10.13 .

. 10.13. . , Scilab , .

1 0 .2 .5



. , , . uicontrol 'Style' 'listbox'. (. 10.10 . 10.14).


10.2. 10.10. // . f=figure(); // listbox h=uicontrol(f,'style','listbox','position', [10 10 150 160]); // . set(h, 'string', " 1| 2| 3"); set(h, 'value', [1 3]); // item 1 3 .

203

. 10.14. . , . 'value' 'CallBack'. 1. Ctrl . , 'value'. Shift, . 'value'. Scilab .


11

11.1



, , . , (. 11.1). , . 11.1. xi yi x1 y1 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6 x7 y7 ... ... xn yn

, Y = f (x, a0 , a1 , . . . , ak ) , yi Yi :
n

S=
i=1

(yi - f (xi , a0 , a1 , . . . , ak ))2 min

(11.1)

ai (11.1). Scilab [a,S]=datafit(F,z,)


11.1.

205

F , ; z ; c ; a ; S . datafit . 11.1. (P , ) (U , ) (. 11.2).

11.2. . U , 132 140 150 162 170 180 190 200 211 220 232 240 251 P , 330 350 385 425 450 485 540 600 660 730 920 1020 1350 P = a1 + a2 U + a3 U 2 + a4 U 3 . . 11.1. 11.1 //, // . // //z=[x;y] - - // - , // // . function [zr]=G(c,z) zr=z(2)-c(1)-c(2)*z(1)-c(3)*z(1)^2-c(4)*z(1)^3 endfunction // x=[1.32 1.40 1.50 1.62 1.70 1.80 1.90... 2.00,2.11,2.20,2.32,2.40,2.51]; y=[3.30 3.50 3.85 4.25 4.50 4.85 5.40... 6.00 6.60 7.30 9.20 10.20 13.50]; // z=[x;y]; // c=[0;0;0;0]; //


206 [a,err]=datafit(G,z,c) S= 0.5287901 a= - 51.576664 95.594671 - 55.695312 11.111453

11.

, datafit P = -51.577+95.595U -55.695U 2 +11.111U 3 , 0.529. (. 11.1): 11.2. // plot2d(x,y,-4); // t=1.32:0.01:2.51; Ptc=a(1)+a(2)*t+a(3)*t^2+a(4)*t^3; plot2d(t,Ptc);

14

12

10

8

6

4

2 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6

. 11.1. 11.1

11.2. Y = a1 § xa2 + a3 .


11.1.

207

(. 11.2). 11.3. 11.2 function [zr]=F(c,z) zr=z(2)-c(1)*z(1)^c(2)-c(3); endfunction x=[10.1,10.2,10.3,10.8,10.9,11,11.1,11.4,12.2,13.3,13.8,... 14,14.4,14.5,15,15.6,15.8,17,18.1,19]; y=[24,36,26,45,34,37,55,51,75,84,74,91,85,87,... 94,92,96,97,98,99]; z=[x;y]; c=[0;0;0]; [a,S]=datafit(F,z,c); t=10:0.01:19; Yt=a(1)*t^a(2)+*a*(3); plot2d(x,y,-3); plot2d(t,Yt);

120 110 100 90 80 70 60 50 40 30 20 10 11 12 13 14 15 16 17 18 19

. 11.2. 11.2 , y = a1 + a2 x, y x. a1 a2 . , x y , , :


208

11.

n

n

n

r=

i=1 n

(xi - Mx ) § (yi - My )
n

xi , Mx =
i=1

y , My =
i=1

i

n

n

(11.2)

i=1

(xi - Mx )2

i=1

(yi - My )2

-1 r 1. r , . , , x y , , , . r , :
n

R=

1-

i=1 n

(yi - Yi )2
2

(11.3)

i=1

(yi - My )

y , Y , , My y . 0 1. 1. R = 0. r , R , . . Scilab a=regress(x,y) x y , a a1 a2 . . 11.3. . . Na N O3 . Na N O3 , 100 , . 11.3. 32 .


11.2.

209

11.3. Na N O3 . 0 66.7 4 71.0 10 76.3 15 80.6 21 85.7 29 92.9 36 99.4 51 113.6 68 125.1

: 11.4. 11.3 // x=[0 4 10 15 21 29 36 51 68]; y=[66.7 71 76.3 80.6 85.7 92.9 99.4 113.6 125.1]; // a=regress(x,y) a= 67.507794 0.8706404 // 32 -->t=32;a(1)+a(2)*t ans = 95.368287 // (11.2) r=sum((x-mean(x)).*(y-mean(y)))/... sqrt(sum((x-mean(x))^2)*sum((y-mean(y))^2)) r = 0.9989549 // (11.3) R=sqrt(1-sum((y-(a(1)+a(2)*x))^2)/sum((y-mean(y))^2)) R = 0.9989549 (. 11.3): 11.5. t=0:70; Yt=a(1)+a(2)*t; plot2d(x,y,-5); plot2d(t,Yt); Scilab a=corr(x,y), x y íí .

11.2



. [a; b] x0 , x1 , x2 , . . . , xn ( n + 1 ),


210

11.

130

120

110

100

90

80

70

60 0 10 20 30 40 50 60 70

. 11.3. 11.3

, f (x) : f (x0 ) = y0 , f (x1 ) = y1 , f (x2 ) = y2 , ..., f (xn ) = yn . (11.4)

F (x), , f (x): F (x0 ) = y0 , F (x1 ) = y1 , F (x2 ) = y2 , . . . , F (xn ) = yn . (11.5) - ( spline , ). . , . Scilab y=interpln(z,x) z ; x ; y x. interpln. 11.1. . 11.5. 11.6. interpln x=[132 140 150 162 170 180 190 200 211 220 232 240 251]; y=[330 350 385 425 450 485 540 600 660 730 920 1020 1350]; plot2d(x,y,-4); z=[x;y];


11.2. t=132:5:252; ptd=interpln(z,t); plot2d(t,ptd);

211

1400

1200

1000

800

600

400

200 120

140

160

180

200

220

240

260

. 11.4. 11.1 Scilab : d=splin(x,y), y=interp(t,x,y,d). d=splin(x,y) : x , ; y , x; d , . y=interp(t,x,y,k) x, y d , t , y , x. 11.4. x= 0, 702, x2 = 0, 512, x3 = 0, 608. (. 11.4).

11.4. 11.4 0.43 1.63597 0.48 1.73234 0.55 1.87686 0.62 2.03345 0.7 2.22846 0.75 2.35973

:


212

11. 11.7. 11.4 x=[0.43 0.48 0.55 0.62 0.7 0.75]; y=[1.63597 1.73234 1.87686 2.03345 2.22846 2.35973]; plot2d(x,y,-4);// koeff=splin(x,y); X=[0.702 0.512 0.608]; // Y=interp(X,x,y,koeff) Y = 2.2335678 1.7969698 2.0057073 plot2d(X,Y,-3); // // t=0.43:0.01:0.75; ptd=interp(t,x,y,koeff); plot2d(t,ptd);

. 11.5.

2.4

2.3

2.2

2.1

2.0

1.9

1.8

1.7

1.6 0.40

0.45

0.50

0.55

0.60

0.65

0.70

0.75

. 11.5. 11.4


12

1 . x, y , z t. . Scilab, , . , . , Scilab.

12.1



u(x, y ) ( u(x, t)) [1]: L(u) = A(x, y ) 2u 2u 2u + 2B (x, y ) + C (x, y ) 2 + x2 x y y u u + E (x, y ) + G(x, y )u(x, y ) = F (x, y ) + D(x, y ) x y

(12.1)

1

.


214

12.

u x t, (12.1) : L(u) = A(x, t) 2u 2u 2u + 2B (x, t) + C (x, t) 2 + 2 x x t t

u u + E (x, t) + G(x, t)u(x, t) = F (x, t) + D(x, t) x t

(12.2)

F = 0, (12.1)í(12.2) , [2]. B 2 - 4AC < 0, (12.2) , B 2 - 4AC > 0, (12.2) , B 2 - 4AC = 0 . , B 2 - 4AC , . x, y ( x, t) , B = 0. . A C , (12.2) , , , A C 0, [2]. [1, 2]: § u = 01 , ; § u = f , , . .; § u + cu = f , . [3]: 2u 2u § : 2 = a2 2 + f (x, t), t x ; 2u 2u 2u + 2 + f (x, y , t) 2 = a2 t x2 y 2 . § 2 u RC + LG u RG 1 2u + + u- = 0 t2 LC t LC LC x2 u ; L, C , R, G 2u 2u + , 2 x y2 u =

1 2

u =
2 2

u u u + + . x2 y2 z2 2 f = 0 .


12.2.

215

, , , . u = a2 u + f . t . , t. . , [3]: § u(x,y,z) = (x, y , z ), , , . u(0, t) = 1 (t), u(L, t) = 2 (t), (0, L) , ; § u = (x, y , z ), n (x,y,z) n ; u + u n = (x, y , z ).
(x,y ,z )

§

, , , : u(x, t0 ) = (x). u(x, t0 ) : u(x, t0 ) = 1 (x) = 2 (x). t , ( ), , . .

12.2



1 [1]. ,
1

.


216

12.

, , t = tj x = xi , xn - x0 (. . 12.1), xi = x0 + ih, h = , h tk - t0 , j = 0, 1, . . . k . , i = 0, 1, 2, . . . , n, tj = t0 + j , = k , , . , h h x t . , j w(x, t) wi = w(xi , tj ), h , . , . h , . Scilab. . (12.3): u 2u 0x = a2 2 + f (x, t), t t u(0, t) = ²(t), u(L, t) = (t), u(x, 0) = (x), 0xL L, 0 t 0 T t T (12.3)

(. . 12.1). h 2u [1]: x2 2 u(xi , tj ) u = 2 x (xi , tj ), ui+1,j (xi , tj +1 ) ui,j -1 u t [1]:
i+1,j

- 2ui,j + u h2

i-1,j

.

(12.4)

ui,j (xi+1 , tj ), ui-1,j (xi , tj -1 ).

u (xi-1 , tj ), ui,j +1

u u(xi , tj ) = t u u(xi , tj ) = t
i,j +1

-u

i,j

(12.5) (12.6)

i,j

-u

i,j -1


12.2.

217

. 12.1. h

, : ui,0 = (xi ) = i , i = 0, 1, . . . n (12.7) u
0, j

= ²(tj ) = ²j ,

u

n,j

= (tj ) = j ,

j = 0, 1, . . . , k

(12.8)

(12.3) (12.4) (12.5) (12.7)í(12.8), u : h u u
0, j i,j +1

= u

i,j -1

+ (1 - 2 )u = j ,

i,j

+ u

i,j +1

+ fi, =

j

(12.9) (12.10)

= ²j ,

u

n,j

u

i,0

= i ,

a2 h2

(. . 12.2). , ( i = 0) ui,0 , ( , u0,j , un,j ) , (12.9) ui,1 , ui,2 ui,k . (12.9) t x : h2 2a2 (12.11)


218

12.

. 12.2.

. 12.1. , L, (x). u(0, t) = U1 = const, u(L, t) = U2 = const. u 2u a2 = , = a2 2 + f (x, t), 0 < x < L, 0 < t < , t t c u(0, t) = U1 = const, u(L, t) = U2 = const, 0 < t < , u(x, 0) = (x), 0 < x < L,

(12.12)

a2 , , c , . 12.1 (12.9)í(12.10) Scilab 12.11 . 12.1. 12.1 // . function y=f(x,t) y=sin(x*t) endfunction // function y=fi(x) y=exp(0.15*x) endfunction // function y=myu(t) y=1
1 12.1 , Scilab 1.


12.2. endfunction // function y=nyu(x) y=2.117 endfunction function [u,x,t]=parabol(N,K,L,T,a) // // . N - , // (0,L); K - //, t (0,T); a // , // u x, t // h=L/N; // t delta=T/K; // x U // for i=1:N+1 x(i)=(i-1)*h; u(i,1)=fi(x(i)); end // t, // //U for j=1:K+1 t(j)=(j-1)*delta; u(1,j)=myu(t(j)); u(N+1,j)=nyu(t(j)); end gam=a^2*delta/h^2; // u //(12.9) for j=1:K for i=2:N u(i,j+1)=gam*u(i-1,j)+(1-2*gam)*u(i,j)+gam*u(i+1,j)+delta*... f(x(i),t(j)); end end end

219

parabol 12.1 : N , (0, L); K , (0, T ); L , T


220

12. . u, parabol , . 12.3.

, a : , x t. h 12.2 12.1

12.2. parabol [U,X,T]=parabol(50,200,5,3,0.4); surf(X,T,U'); title('PARABOLIC EQUATION'); xlabel('X'); ylabel('T');

PARABOLIC EQUATION

2.6 2.4 2.2 2.0 Z 1.8 1.6 1.4 1.2 1.0 3.0 2.5 2.0 1.5 1.0 T 0.5 0.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 X 3.5 4.0 4.5 5.0

. 12.3. 12.1 f (x, t) = sin(xt) t, (12.11). [1]. , , (12.9). . (12.3) (12.4), (12.61 ) (12.7)í(12.8)
1

(12.5)


12.2. u . h u
i-1,j

221

- (1 + 2 )ui,j + ui+1,j = -ui,j -1 - fi,j , i = 1, 2, . . . , n - 1, j = 1, 2, . . . k

(12.13)



(12.13) (12.10) (. . 12.4). (12.10), (12.13) , ui,j j , ( [1]) [1]. (12.13) : u = (u 1 + 2 +u )+ ui,j -1 + f (xi , tj ) 1 + 2 1 + 2 (12.14)

i,j

i-1,j

i+1,j

. 12.4.

(12.14) , , , , . (c neyavn 12.3. neyavn : N , x (0, L); K , t (0, T ); a ; eps (12.4) 1 . neyavn u 12.1; x t; r (12.4) ; k.
1 (12.13)í(12.14) . , .


222

12.
1

12.3. 12.1 // . function y=f(x,t) y=sin(x*t) //y=0; endfunction // function y=fi(x) y=exp(0.15*x) endfunction // function y=myu(t) y=1 endfunction // function y=nyu(x) y=2.117 endfunction function [u,x,t,r,k]=neyavn(N,K,L,T,a,eps) // // . // h=L/N; // t delta=T/K; // x U // for i=1:N+1 x(i)=(i-1)*h; u(i,1)=fi(x(i)); end // t, // U for j=1:K+1 t(j)=(j-1)*delta; u(1,j)=myu(t(j)); u(N+1,j)=nyu(t(j)); end // R R(N+1,K+1)=0;

1 , .


12.2.

223

// gamma gam=a^2*delta/h^2; r=1; k=0; // while // (12.14) // eps while r>eps // R // u //(12.14) for i=2:N for j=2:K+1 R(i,j)=abs(u(i,j)-gam/(1+2*gam)*(u(i-1,j)+u(i+1,j))-u(i,j-1)... /(1+2*gam)-delta*f(x(i),t(j))/(1+2*gam)); u(i,j)=gam/(1+2*gam)*(u(i-1,j)+u(i+1,j))+u(i,j-1)... /(1+2*gam)+delta*f(x(i),t(j))/(1+2*gam); end end // r=R(1,1); for i=1:N+1 for j=1:K+1 if R(i,j)>r r=R(i,j); end end end // . k=k+1; end disp(k) endfunction [U,X,T]=neyavn(50,200,5,3,0.4,0.1); surf(X,T,U'); title('PARABOLIC EQUATION'); xlabel('X'); ylabel('T');


224

12. (t), -

. , , 12.1 12.3, (12.3) f (x, t), ²(t), (x). , f (x, t) = 0, .

12.2. L, f (x). u(0, t) = U1 = const, u(L, t) = U2 = const. , u0 . - , , : 2u u = a2 2 - h (u - u0 ) , t t p 2 h= , 0 < x < L, 0 < t < , a= , c c u(0, t) = U1 = const, u(L, t) = U2 = const, 0 < t < , u(x, 0) = (x), 0
(12.15)

, , p . L T (xi = ihx, h = , i = 0, 1, 2, . . . , n), (tj = j , = , j = h h k 2u u 0, 1, . . . k ). x2 t (12.4) (12.6). (12.16)í(12.18): u u u
i,j i,0 0, j

= (xi ), = U1 ,

i = 0, 1, . . . , N , UN ,j = U2 , j = 0, 1, . . . , K

(12.16)

h 1 ui,j -1 + (ui-1,j + ui+1,j ) + u 0, 1 + 2 + h 1 + 2 + h 1 + 2 + h i = 1, 2, . . . , N - 1; j = 1, 2, . . . , k; (12.17) 2 =a (12.18) hx2 12.2 12.4. =


12.2. 12.4. neiav 12.2

225

// function y=fi(x) y=exp(0.15*x) endfunction function [u,x,t,r,k]=neiav(N,K,L,T,a,h,U1,U2,u0,eps) // // . //N - , //(0,L); K - , // t (0,T); //a, h - ; //eps - (7.17) ; //U1 - ; //U2 - ; // neiav : //u - , x, t, //r - (12.17) , // - . // hx=L/N; // t delta=T/K; // x U // for i=1:N+1 x(i)=(i-1)*hx; u(i,1)=fi(x(i)); end // t, // U for j=1:K+1 t(j)=(j-1)*delta; u(1,j)=U1; u(N+1,j)=U2; end // R R(N+1,K+1)=0; // gamma gam=a^2*delta/hx^2; r=1; k=0;


226

12. // while // (12.17) eps while r>eps // R // u //(12.17) for j=2:K+1 for i=2:N V=gam*(u(i-1,j)+u(i+1,j))/(1+2*gam+delta*hx)+u(i,j-1)/... (1+2*gam+delta*hx)+delta*h*u0/(1+2*gam+delta*hx); R(i,j)=abs(V-u(i,j)); u(i,j)=V; end end // r=R(1,1); for i=1:N+1 for j=1:K+1 if R(i,j)>r r=R(i,j); end end end // k=k+1; end endfunction // 12.2. [U,X,T,R,K]=neiav(50,200,5,3,0.4,0.5,1,2.117,30,0.001); // surf(X,T,U'); title('Example 12.2'); xlabel('X'); ylabel('T');

neiav 12.2 12.4. . 12.5 . 1079 . . , , .


12.3.

227

Example 12.2

40 35 30 25 Z 20 15 10 5 0 3.0 2.5 2.0 1.5 1.0 T 0.5 0.0 0.0 0.5 1.0 1.5 2.0 2.5 X 3.0 3.5 4.0 4.5 5.0

. 12.5. 12.2

12.3



. : 2u 2u = a2 2 + f (x, t), 0 < x < L, 2 t t u(0, t) = ²(t), u(L, t) = (t), 0 u(x, 0) = (x), u(x, 0) = (x), t

0 t 0 T x

t

T (12.19) L

(. . 12.1), h 2u (12.19). (12.4), x2 2u (12.20) [1]. t2 u 2 u(xi , tj ) = t2
i,j -1

- 2ui,j + u 2

i,j +1

(12.20)


228

12.

(12.20), (12.4), (12.5) - (12.19), : ui,j +1 = -ui,j -1 + (ui-1,j + ui+1,j ) = (2 - 2 )ui,j + 2 fi, i = 1, 2, . . . , N - 1, j = 1, 2, . . . , K - 1 ui,1 - ui,0 ui,0 = (xi ), = i , i = 0, 1, . . . , N u0,j = ²j , uN ,j = j , j = 0, 1, . . . , K a2 2 = h2
j

(12.21)

< 1 (12.9)í(12.10) Scilab. - . 12.3. - 2 2 = a2 2 + sin(xt), 0 < x < L, t2 t (0, t) = (0), (L, t) = (L) (x, 0) = (x), t (x, 0) = (x) t > 0, (12.22)

12.5 ggg (12.22), . 12.6 . ggg . 12.5. ggg 12.3 function [u,x,t]=ggg(N,K,L,T,a) // // . : //N - , // (0,L); K - , // t (0,T); a - // . : //u - , x, t, // h=L/N; // t delta=T/K; // x, u //


12.4.

229

for i=1:N+1 x(i)=(i-1)*h; u(i,1)=fi(x(i)); u(i,2)=u(i,1)+delta*psi(x(i)); end // t, //U for j=1:K+1 t(j)=(j-1)*delta; end // U // for j=2:K+1 u(1,j)=0; u(N+1,j)=fi(L); end gam=a^2*delta^2/h^2; // u //(12.22) for j=2:K for i=2:N u(i,j+1)=-u(i,j-1)+gam*u(i-1,j)+(2-2*gam)*... u(i,j)+gam*u(i+1,j)+delta^2*f(x(i),t(j)); end end end , , (, , , ).

12.4



(R - b x R + b, -a y a) . 12.4. u = (
x,y )

2 2 5 + - = -2 x2 y2 x x = 0

(12.23)


230

12.

Example 12.3

4 3 2 Z 1 0 -1 -2 3.0 2.5 2.0 1.5 1.0 T 0.5 0.0 0.0 0.5 1.0 1.5 2.0 2.5 X 3.0 3.5 4.0 4.5 5.0

. 12.6. 12.3

hy , , hx 2b y = yj x = xi , xi = R - b + i § hx, hx = , i = 0, 1, 2, . . . , N x, yj = -a + n 2a j § hy , hy = , j = 0, 1, . . . , N y . k : i-1,j - 2i,j + i+1,j 2 (xi , yj ) = x2 h x2 2 i,j -1 - 2i,j + i,j +1 (xi , yj ) = y2 hy 2 i,0 = i,N y = 0, 0,j = N x,j = 0, i = 0, 1, . . . , N x j = 0, 1, . . . , N y

(12.24)

(12.25)

(12.24)í(12.25) . 1 (Bi i+1,j + Ci i-1,j + D(i,j -1 + i,j +1 ) + 2) A 2 2 1 5 1 5 A= + 2, Bi = + , Ci = - , h x2 hy h x2 2hx xi h x2 2hx xi i = 1, 2, . . . , N x - 1; j = 1, 2, . . . , N y - 1 i,0 = i,N y = 0, i = 0, 1, . . . , N x 0,j = N x,j = 0, i = 0, 1, . . . , N y i,j =

D=

1 hy

2

(12.26)


12.4.

231

( ). , , ( ). 12.6 (12.23) , . 12.7 .
Example 12.4

8 7 6 5 Z 4 3 2 1 0 3 2 1 0 -1 Y -2 -3 12 16 14 X 18 22 20 24

. 12.7. (12.23)

12.6. 12.4 function [psi,x,y,k]=ellip(R,a,b,Nx,Ny,eps) // ellip 12.4. // : //R, a, b - , , //Nx - , //(R-b,R+b); //Ny - , //y (-a,a); //eps - (12.26) . // : //psi - , x, y, //k - //(12.26) . // y hy=2*a/Ny; // x


232

12. hx=2*b/Nx; // x, // psi for i=1:Nx+1 x(i)=R-b+(i-1)*hx; psi(i,1)=0; psi(i,Ny+1)=0; end; // y, // psi for j=1:Ny+1 y(j)=-a+(j-1)*hy; psi(1,j)=0; psi(Nx+1,1)=0; end; // (12.26) A=2/hy^2+2/hx^2; D=1/hy^2; for i=2:Nx+1 B(i)=1/hx^2+5/(2*hx*x(i)); C(i)=1/hx^2-5/(2*hx*x(i)); end // (12.26) // eps p=1; k=0; while p>eps for i=2:Nx for j=2:Ny V=1/A*(B(i)*psi(i-1,j)+C(i)*psi(i+1,j)+D*(psi(i,j-1)... +psi(i,j+1))+2); R(i,j)=abs(V-psi(i,j)); psi(i,j)=V; end end p=R(2,2); for i=2:Nx for j=2:Ny if R(i,j)>p p=R(i,j); end end end k=k+1;


12.4. end endfunction // 12.4. [PSI,X,Y,K]=ellip(18,3,6,32,16,0.01); // surf(X,Y,PSI'); title('Example 12.4'); xlabel('X'); ylabel('Y');

233

, , (12.23), . . , , , , freefem [4].


13

Scilab .

13.1



. 13.1. f (x) = x4 + 3x3 - 13x2 - 6x + 26. (. 13.1 . 13.1). 13.1. x=-5:0.1:1; y=x.^4+3*x.^3-13*x.^2-6*x+26; plot(x,y); xtitle(' f(x)=x^4+3*x^3-13*x^2-6*x+26','X','Y'); xgrid(); , -4. Scilab [f,xopt]=optim(costf,x0),


13.1.
Plot function f(x)=x^4+3*x^3-13*x^2-6*x+26 40

235

20

0

-20 Y -40 -60 -80 -100 -5 -4 -3 -2 X -1 0 1 2

. 13.1. f (x) = x4 + 3x3 - 13x2 - 6x + 26 , x0 - n, costf , . (f) , (xopt). optim costf, : function [f,g,ind]=costf(x,ind) // costf f, g. //f - , f=gg(x); //g - f ( f x), g=numdiff(gg,x); endfunction f , , g . costf ind 2, 3 4, costf , . . optim f xopt. ind=1, optim , ind<0 , f (x) , ind=0 . , ind optim costf, optim , ind costf.


236

13.

, optim costf, f (). optim f (x) = x4 + 3x3 - 13x2 - 6x + 26. (. . 13.1) xmin 4. optim f (x) = x4 + 3x3 - 13x2 - 6x + 26. 13.2.

// fi, f // g. function [f,g,ind]=fi(x,ind) // f, . f=x^4+3*x^3-13*x^2-6*x+26 // g - f. g=4*x^3+9*x^2-26*x-6 endfunction // . y0=-2; // (xmin) (fmin) // - optim. [fmin,xmin]=optim(fi,y0);

:

-->fmin fmin = - 95.089413 -->xmin xmin = 3.8407084

, . Scilab, .


13.2.

237

13.2



costf , x ind. costf , () . ostf : function [f,g,ind]=costf(x,ind) //f - , f=gg(x); //g - f ( ) g=numdiff(gg,x); endfunction f (x, y ) = 100(y - x2 )2 + (1 - x2 )2 . . 13.2.

450 400 350 300 250 Z 200 150 100 50 0 1.0 0.6 0.2 -0.2 Y -0.6 -1.0 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 0.2 X 0.4 0.6 0.8 1.0

. 13.2. , (1, 1), 0. . optim ( 13.3).


238

13. 13.3. // x0 x0=[-2;2] // function y=gg(x) // , x - . y=100*(x(2)-x(1)^2)^2+(1-x(1))^2; endfunction // cst, // . function [f,g,ind]=cst(x,ind) f=gg(x); g=numdiff(gg,x); endfunction // optim [f,xopt]=optim(cst,x0)

optim. x0 = -2. 2. xopt = 0.9999955 0.9999910 f= 2.010D-11

13.3



. . . : 1 , 2 , 3 , 4 . c1 , c2 , c3 , c4 . , b1 , b2 , b3 . , 1 a11 , a12 a13 . . (. 13.1). , .


13.3. 13.1. , 1 2 3 4 a11 a21 a31 a41 a12 a22 a32 a42 a13 a23 a33 a43

239

x1 , x2 , x3 , x4

1 , 2 , 3 , 4 .
4

L = c1 x1 + c2 x2 + c3 x3 + c4 x4 =
i=1

ci xi

(13.1)

, . 1 a11 , x1 a11 x1 , x2 2 a21 x2 . . , 4 j =1 aj1 xj b1 . : a11 x1 + a21 x2 + a31 x3 + a41 x4 b
1

(13.2)

: a12 x1 + a22 x2 + a32 x3 + a42 x4 a13 x1 + a23 x2 + a33 x3 + a43 x4 , x1 , x2 , x3 , x4 : x1 0, x2 0, x3 b b
2 3

(13.3) (13.4)

, 0, x4 0 (13.5)

, : x1 , x2 , x3 , x4 , (13.2)í(13.5), (13.1) . , (13.1) , (13.2)í(13.5) . L . . x1 , x2 , . . . , xn , (13.6), L (13.7) () :


240

13.

n

aij xj
j =1

bi ,

i = 1, . . . , m,

xi

0

(13.6)

n

L = c1 x1 + c2 x2 + . . . + cn xn =
i=1

ci xi

(13.7)

Scilab linpro : [x,kl,f]=linpro(,A,b[,ci,cs][,k][,x0]) c (-) , n x. A , m, n. (-), , m. (-) n (cij xj ); , []. (-) n, (csj xj ); , []. , , , k , l , .. m = k + l. - n.

b

ci

cs

k

x0

linpro x, f k l. linpro .


13.3.

241

13.2. x1 , x2 , x3 , x4 , L L = -x2 - 2x3 + x4 : 3x1 - x2 x2 - 2x3 4x3 - x4 5x1 + x4 x1 0, x2 2 -1 3 6 0,

x3

0,

x4

0

, . (13.1) -1. 13.2 13.4. 13.4. 13.2 c=[0;-1;-2;1]; A=[3 -1 0 0;0 1 -2 0; 0 0 4 -1; -5 0 0 -1]; b=[2;-1;3;-6]; ci=[0;0;0;0]; [x,kl,f]=linpro(p,A,b,ai,[]) 13.5. 13.5. 13.2 f= 2. kl= 0. 0. 0. 0. 0.0909091 1.0909091 0.5454545 0.4545455 x= 1. 1. 1. 1


242

13.

. 13.3. , 200 150 . , . , , 70 , - 180, 110 . 13.2.

13.2. 1 2 5 10 6 12 20 5

: x1 x2 x3 x4 x5 x6 , ; , ; , ; , ; , ; , .

, : Z = 5x1 + 6x2 + 20x3 + 10x4 + 12x5 + 5x6 . , : x1 x2 x3 x1 x4 + + + + + x4 70 ; x5 180 ; x6 110 ; x2 + x3 = 200 ; x5 + x6 = 150 .

, , , : x1 0, x2 0, x3 0, x4 0, x5 0, x6 0.


13.3.

243

13.6. x x1 , x2 , x3 , x4 , x5 , x6 . A , k=2. ci , .. , . , x, kl, f. 13.6. 13.3 Z=[5;6;20;10;12;5]; A=[1 1 1 0 0 0; 0 0 0 1 1 1;1 0 0 1 0 0;0 1 0 0 1 0;0 0 1 0 0 1]; b=[200;150;70;180;110]; ci=[0;0;0;0;0;0]; k=2; [x,kl,f]=linpro(Z,A,b,ci,[],k); Scilab 13.7 13.7. 13.3 f= 2120. kl= 0. 0. -20. 0. -1. 0. -6. -11. 1. 0. 6. x= 30. 170. 0. 40. 0. 110.


244

13.

, , Scilab . , Scilab , .


14 Scilab

14.1

Scilab.
, 10x2 + 30x3 + 40x4 = -50 10x1 + 20x3 + 30x4 = -40 30x1 + 20x2 - 50x4 = 120 40x1 + 30x2 + 50x3 = 50 0.3x1 + x2 + 1.67x3 - 2.3x4 = 4 3x1 + 5x2 + 7x3 - x4 = 0 5x1 + 7x2 + x3 - 3x4 = 4 7x1 + x2 + 3x3 - 5x4 = 16 2x1 + x2 + 5x3 + x4 = 8 0.333x1 - x2 - 2x4 = 3 2x2 + x3 + 2x4 = -5 x1 + 4x2 + 7x3 + 6x4 = 0 -x1 + x2 + x3 + x4 = 12 2x1 + x2 + 2x3 + 3x4 = 13 1.5x1 + x2 + 0.5x3 + x4 = 7 4x1 + 3x2 + 2x3 + x4 = -15

1.1. -x1 - x2 - 2x3 - 3x4 = 2 3x1 - x2 - x3 - 2x4 = -8 1. 2x1 + 3x2 - x3 - x4 = -12 x1 + 2x2 + 3x3 - x4 = 8 x1 - 2x2 + 3x3 - 2x4 = -6 x1 + x2 - 2x3 - 3x4 = -8 2. 3x1 - 2x2 - x3 + 2x4 = 4 2x1 + 3x2 + 2x3 + x4 = 8 x1 + 2x2 + 3x3 + 4x4 = 5 2x1 + x2 + 2x3 + 3x4 = 1 3. 3x1 + 2x2 + x3 + 2x4 = 1 4x1 + 3x2 + 2x3 + x4 = -5 0.1x1 + 0.5x2 + 0.3x3 - 0.4x4 = 2 0.3x1 + 0.1x2 - 0.2x3 = 0.9 4. 0.5x1 - 0.7x2 + 1x4 = -0.9 0.3x2 - 0.5x3 = 0.1

5.

6.

7.

8.


246

14. Scilab -2x1 - x2 + 3x3 + 2x4 = 40 -x1 + x2 + x3 + 0.6667x4 = 20 -3x1 - x2 - x3 + 2x4 = 60 -3x1 - x2 + 3x3 - x4 = 60 3x1 - 6x2 - 3x3 + 3x4 = 8 2x1 - x2 + x3 + x4 = 5 x1 + x2 + 2x3 + x4 = -1 x1 - x2 - x3 + 3x4 = 10 20x1 + 5x2 + 5x4 = -9 x1 - 3x2 + 4x3 = -7 3x2 - 2x3 - 4x4 = 12 x1 + 2x2 - x3 + 3x4 = 10 x1 - 3x2 + x3 + x4 = 11 x1 + 3x2 + 5x3 + 7x4 = 12 3x1 + 5x2 + 7x3 + x4 = 0 -5x1 - 7x2 - x3 - 3x4 = -4 3 -1 5 2 , 07 -1 0 1 B= 0 2 -2 5 3 4 2x1 + x2 + x3 - x4 = 11 2x1 + x2 - 3x4 = 2 13. 3x1 + x3 + x4 = -3 4x1 - 4x2 - 4x3 + 10x4 = 7 2x1 + x3 + 4x4 = 19 x1 + 2x2 - x3 + x4 = 18 14. 2x1 + x2 + x3 + x4 = 15 2x1 - 2x2 + 4x3 + 2x4 = -11 5x1 - 3x2 - 7x3 + 3x4 = 1 -x2 - 3x3 + 4x4 = -5 15. x1 - 2x3 - 3x4 = -4 1.3333x1 - x2 - 1.6667x3 = 13

9.

10.

11.

12.

1.2. , , D. 1. D = 2(A2 + B )(2B - A), 2 A= 4 -1

2. D = 3A - (A + 2B )B 2 , 4 5 -2 A = 3 -1 0 , 42 7 3. D = 3A2 - (A + 2B )B , 4 5 -2 A = 3 -1 0 , 42 7 4. D = (A - B 2 2)(2A + B 3 5 A = 10 7 ), 2 4 3 0 1 , 2

2 1 -1 B= 0 1 3 57 3



2 1 -1 B= 0 1 3 57 3

3 B = -1 2



6 -1 -2 0 1 3


14.1.

Scilab

247

5. D = 2(A - B )(A2 + B ), 5 17 A = -10 -2 1 , 0 12 6. D = (A - B )2 A + 2B , 5 -1 2 A= 0 -2 -1 3 -1 , 0

24 B= 3 1 72 3 B= 1 0



1 0 1

7. D = (A2 - B 2 )(A + B 2 ), 7 20 A = -7 -2 1 , 1 11

7 -2 1 -2 13 3 -2 1 1 0 1 -2 1 -5 16 0 2 4 2 4 2 -2 -1

8. D = 2(A - B )(A2 + B ), 5 17 A = -10 -2 1 , 0 12 9. D = 2A - (A2 + B )B , 1 A= 2 0 42 1 -2 , 1 -1 3 -1 0 4 , 5 -1 2 -5 2 0 , 12

02 B= 1 0 31 24 B= 3 1 72 46 B = 4 10 24 1 4 B = -3 -2 5 7 -1 2 3 B= 0 -1 -3 20 B = 5 -7 10

10. D = 2(A - 0, 5B ) + A3 5 A= 2 3

B ,

11. D = (A - B )A2 + 3B , 3 A= 4 1

12. D = 3(A2 + B 2 ) - 2AB , 421 A = 3 -2 0 , 0 -1 2


248

14. Scilab

13. D = 2A3 + 3B (AB - 2A), 1 -1 0 A = 2 0 -1 , 11 1 14. D = A(A2 - B ) - 2(B + A)B , 2 31 A = -1 2 4 , 5 30 15. D = (2A - B )(3A + B ) - 1 A = -2 -1 2A2 B , 03 0 1 , 31

5 31 B = -1 2 0 -3 0 0 13 5 21 2 2 -1



2 7 B = -1 0 5 13

7 5 1 B= 0 -3 -1

14.2





2.1. f (x). 1. f (x) = 1.2x3 + x2 - 2.8x - 1 . x2 - 1
3 2

7. f (x) = 8. f (x) = 9. f (x) = 10. f (x) = 11. f (x) = 12. f (x) = 13. f (x) = 14. f (x) = 15. f (x) =

3

(x - 4.5)2 (x + 2). x2 (x - 4.7). (x + 5)2 -
3

3

1.9x - 2.8x - 1.9x + 1 2. f (x) = . 3x2 - 1 2x2 - 5 . 3. f (x) = x2 - 2 4.1x - 3.25x 4. f (x) = . 4x4 - 1 5. f (x) = x2 - 11.5 . 4x - 3
2 3

3

(x - 7)2 .

3

(x2 - x - 2)2 . x2 (x + 3.5)2 . (x + 5)2 - 3 x - 1. (3.5 + x)(x2 + 6x + 6). (4 + x)(x2 + 2x + 1). (x2 - x - 6)2 .

3

3

3

3

2.3x - 7 . 6. f (x) = 3x2 - 4

3


14.3.



249

2.2. 1. () = -2ctg . 2. () = 2cos 6. 3. () = 2 + 1. 4. () = 2 cos 2. 5. () = 3 + 2. 6. () = 32 + . 7. () = 2sin 6. 8. () = 3 . 9. () = 2tg 3. 15. () = 13. () = 11. () = 1 cos

10. () =

3

.

2 + 3. sin
2

12. () = 5 sin

. 3

2 + 1. sin . 3

14. () = 5 sin

3 + 1. 2

14.3





3.1. , x = cos(u) § u § 1 + cos (v ) ; 2 u y = § sin(v ); 2 z = (sin(u) § u) § 1 + cos (v ) . 2

plot3d2. 1. 0 2. 0 3. 0 4. 0 5. 0 6. 0 7. 0 8. 0 u u u u u u u u 2 , 2 , 2 , 8 , 4 , 8 , 2 , 8 , 0 0 0 0 0 0 0 0 v v v v v v v v 2 8 4 2 42 4 36 8

9. 0 10. 0 11. 0 12. 0 13. 0 14. 0 15. 0

u u u u u u u

4 , 72 , 2 , 4 , 3 , 2 , 2 ,

0 0 0 0 0 0 0

v v v v v v v

6 72 5 78 8 32 96


250

14. Scilab

param3d. 1 2 3 4 5 t [0; 7 ]

3.2. , : x(t) = sin(t) x(t) = cos(t) y (t) = sin(2t) y (t) = cos(2t) z (t) = t/5 z (t) = sin(t) 6 7 8 9 10 t ; 7 2 [0; 5 ] [2 ; 9 ] [0; 2 ] [ ; 7 ] 11 12 13 14 15 t [0; 4 ] 3 ; 7 2 [ ; 8 ] ; 6 2 [0; 9 ]

[ ; 4 ] ; 5 2 [2 ; 8 ] 3 ; 9 2

14.4


1, 1x4 - x - 0, 9 = 0 x3 + x - 4 = 0 2x4 - x - 1, 5 = 0 3x3 - 5x2 + 9x - 10 = 0 2x4 - 9, 25x2 - 63x + 5 = 0 3x3 - 21x + 2 = 0



4.1. . 1. 2. 3. 4. 5. 6. 7. 8.

0, 9x4 + 4, 2x3 - 8, 5x2 - 13 = 0 5x3 + 13x - 11 = 0 3x4 + 4x3 - 12x2 - 5 = 0 x3 + 2x2 + 2 = 0 3, 2x4 + 7, 75x3 + 6, 3x2 - 10, 5 = 0 2x3 + 0, 48x2 + 1, 6x - 2, 6 = 0 2x4 - 3x2 - 5 = 0 2x3 - 0, 52x2 + 5, 4x - 7, 4 = 0 1, 05x4 - 17x2 + 6 = 0 2x3 - 0, 35x2 + 0, 85x + 1 = 0


14.4.



251

9.

3, 25x4 + 7, 67x3 + 5x2 - 11 = 0 2x3 + 5x2 + 11x + 7 = 0 2, 2x4 - 1, 2x2 - 11 = 0 3x3 - 0, 42x2 + 0, 95x - 2 = 0 -x4 - 18x2 + 6 = 0 2x3 - 0, 08x2 + 0, 94x + 1, 3 = 0 -1, 21x4 + x3 + 2x2 - 3x - 5 = 0 3x3 - 13x2 + 16x - 15 = 0 0, 89x4 + 3, 67x3 - 7, 92x2 - 13 = 0 2x3 - 0, 35x2 + 0, 47x - 1, 43 = 0 6x4 + 8x3 - 23x2 + 2, 1 = 0 5x3 + 20x2 + 5x + 8 = 0 2x4 - 2x3 - 4x2 + 6x - 7 = 0 1, 9x3 + 7x - 11 = 0

10.

11.

12.

13.

14.

15.

4.2. . 1. 2. 3. 4. 5. 6. 7. 8. sin(x + 1) - y = 1, 2; 2x + cos y = 2; cos(x - 1) + y = 0, 5; x - cos y = 3; cos(x - 1) + y = 0, 5; x - cos y = 3; sin x + 2y = 2; cos(y - 1) + x = 0, 7; sin x + 2y = 2; cos(y - 1) + x = 0, 7; sin(x + y ) - 1, 2x = 0, 2; x2 + y 2 = 1; tg(xy + 0, 3) = x2 ; 0, 9x2 + 2y 2 = 1; sin(y + 1) - x = 1, 2; 2y + cos x = 2; 9. sin(x + y ) - 1, 2x = 0, 1; x2 + y 2 = 1; 2y - cos(x + 1) = 0; x + sin y = -0, 4; cos(x + 0, 5) - y = 2; sin y - 2x = 1; tg xy = x2 ; 0, 7x2 + 2y 2 = 1; sin(x - 1) = 1, 3 - y ; x - sin(y + 1) = 0; sin(y - 1) + x = 1, 3; y - sin(x + 1) = 0, 8; sin(y + 1) = x + 1; 2y + cos x = 2;

10.

11.

12.

13.

14.

15.


252

14. Scilab

14.5





5.1. . , , , . . 1. P (s) = As3 + B s2 + D s 0 1 1.5 P 12 10.1 11.58 2. G(s) = Asb s 0.5 1.5 G 3.99 5.65 2 6.41 2 17.4 2.5 6.71 1.2 3.5999 2.5 30.68 3 7.215 1.7 4.4357 3 53.6 3.5 7.611 2.2 5.5781 3.5 87.78 4 7.83 4 136.9 4.5 8.19 4.5 202.5 5 8.3 3.2 8.6621 5 287

3. V (s) = Asb eC s s 0.2 0.7 V 2.3198 2.8569 4. W (s) = s W A Bs + C 1 2 0.529 0.298

2.7 6.9459

3 0.267

4 0.171 1.75 3.672

5 0.156 2 4.592

6 0.124 2.25 4.621

7 0.1 2.5 5.758

8 0.078 2.75 7.173

9 0.075 3 9.269

5. Q(s) = As2 + B s + C s 1 1.25 1.5 Q 5.21 4.196 3.759 6. Y = x Y 7. V = x Ax - B 3 3.1 0.61 0.6

3.2 0.592

3.3 0.58

3.4 0.585

3.5 0.583

3.6 0.582

3.7 0.57

3.8 0.572

3.9 0.571

1 A + B e-U U 0 1 V 12 10.1

1.5 11.58

2 17.4

2.5 30.68

3 53.6 1.74 59.36 12 0.28

3.5 87.78 2.08 82.6 14 0.31

4 136.9 2.63 90.63 16 0.34

4.5 202.5 3.12 113.5

5 287

8. Z = At4 + B t3 + C t2 + Dt + K t 0.66 0.9 1.17 1.47 1.7 Z 38.9 68.8 64.4 66.5 64.95 9. R = C h2 + Dh + K h 2 4 6 R 0.035 0.09 0.147 8 0.2 10 0.24


14.5.



253

10. Y = Ax3 + B x2 + C x + D x 1.2 1.4 1.6 1.8 Y 1.5 2.7 3.9 5.5 11. Y = Ax3 + C x + D x 0 0.4 0.8 Y 1.2 2.2 3.0 12. R = C h2 + K h 0.29 0.57 R 3.33 6.67 1.2 6.0

2 7.1 1.6 7.7 0.14 13.33

2.2 9.1 2 13.6 1.43 16.67 1.57 17.1

2.4 11.1

2.6 12.9

2.8 15.5

3 17.9

0.86 7.5

1.71 23.33 1.86 28.3 2.63 31.86 0.96 0.57

1.82 27.8 1.92 35.3 2.75 37.0

2 33.35 2 36.5 2.88 43.43 1 0.97 3 49.86

13. Z = At4 + C t2 + K t 1 1.14 1.29 Z 6.2 7.2 9.6

1.43 12.5

1.71 22.2 2.5 26.71

14. Z = At4 + B t3 + Dt + K t 2 2.13 2.25 Z 12.57 16.43 19 15. Z = At4 + Dt + K t 0.88 0.9 Z 0.029 0.086 0.91 0.17

2.38 22.86 0.93 0.31

0.94 0.43

0.97 0.71

0.99 0.86

5.2. 1-7 . . 1. x1 = 0.702, x 0.43 y 1.63597 2. x1 = 0.102, x 0.02 y 1.02316 3. x1 = 0.526, x 0.35 y 2.73951 4. x1 = 0.616, x 0.41 y 2.57418 5. x1 = 0.896, x 0.68 y 0.80866 x2 = 0.512, x3 = 608 0.48 0.55 0.62 1.73234 1.87686 2.03345 x2 = 0.203, x3 = 0.154 0.08 0.12 0.17 1.09509 1.14725 1.21423 x2 = 0.453, x3 = 0.436 0.41 0.47 0.51 2.30080 1.96864 1.78776 x2 = 0.478, x3 = 0.537 0.46 0.52 0.6 2.32513 2.09336 1.86203 x2 = 0.774, x3 = 0.955 0.73 0.80 0.88 0.89492 1.02964 1.20966

0.7 2.22846 0.23 1.30120 0.56 1.59502 0.65 1.74926 0.93 1.34087

0.75 2.35973 0.30 1.40907 0.64 1.34310 0.72 1.62098 0.99 1.52368


254 6. x1 = 0.314, x 0.11 y 9.05421 7. x1 = 1.3832, x 1.375 y 5.04192

14. Scilab x2 = 0.235, x3 = 0.186 0.15 0.21 0.29 6.61659 4.69170 3.35106

0.35 2.73951

0.40 2.36522

x2 = 1.3926, x3 = 1.3866 1.380 1.385 1.390 1.395 5.17744 5.32016 5.47069 5.62968

1.400 5.79788

8-15 -. . 8. x1 = 0.308, x 0.298 y 3.25578 9. x1 = 0.608, x 0.593 y 0.53205 10. x1 = 0.115, x 0.100 y 1.12128 x2 = 0.325, x3 = 0.312 0.303 0.310 0.317 3.17639 3.12180 3.04819 x2 = 0.594, x3 = 0.631 0.598 0.605 0.613 0.53562 0.54059 0.54623 x2 = 0.130, x3 = 0.164 0.108 0.119 0.127 1.13160 1.14594 1.15648 x3 = 0.700 2.5 3 30.68 53.6

0.323 2.98755

0.330 2.91950

0.619 0.55043

0.627 0.55598

0.135 1.16712

0.146 1.18191

11. x1 = 0.720, x2 = 0.777, x0 1 1.5 2 y 12 10.1 11.58 17.4 12. x1 = 0.238, x 0.235 y 1.20800 13. x1 = 0.105, x 0.095 y 1.09131 14. x1 = 0.1817, x 0.180 y 5.61543 15. x1 = 3.522, x 3.50 y 33.1154

3.5 87.78

4 136.9

4.5 202.5

5 287

x2 = 0.261, x3 = 0.275 0.240 0.250 0.255 1.21256 1.22169 1.22628 x2 = 0.109 , x3 = 0.111 0.102 0.104 0.107 1.23490 1.27994 1.35142

0.265 1.23547

0.280 1.24933

0.110 1.42815

0.112 1.48256

x2 = 0.2275, x3 = 0.175 0.185 0.190 0.195 0.200 5.46693 5.32634 5.19304 5.06642 x2 = 4.176, x3 = 3.475 3.55 3.60 3.65 34.8133 36.5982 38.4747

0.205 4.94619

3.70 40.4473

3.75 42.5211


14.6.



255

14.6





6. . 1. W = 2x1 - x2 + x4 min x1 + x2 + x3 - x4 1 x1 - x2 + x3 - x4 0 2x1 + x2 + x3 - x4 3 9. W = x1 x1 - x1 - x1 + x2 + + x2 + 3x3 5x2 + 4x3 2x2 - 3x3 6x2 + 5x3 x3 1 - x4 max 5 4 4

3. W = 3 + 2x2 + x3 max x1 - x2 + 2x3 + x4 1 2x1 - x2 + x3 - x4 1 x1 - 2x2 + x3 - x4 -1 x1 + x2 + x3 + 2x4 5

2. W = x1 + x3 max 2x1 - 7x2 + 22x3 22 2x1 - x2 + 6x3 6 2x1 - 5x2 + 2x3 2 -4x1 + x2 + x3 1

4. W = x3 + 3x4 min x1 + x2 - x3 - x4 2 x1 - x2 - x3 + x4 0 -x1 - x2 + 2x3 - x4 -3 x1 1 5. W = -x1 + x2 max x1 - 2x2 2 2x1 - x2 2 x1 + x2 5

11. W = x1 x1 + x1 + x2 - x1 +

10. W = -4 - 2x1 - x2 - x3 min x1 - 2x2 + 3x3 - 4x4 -10 x1 + x2 - x3 - x4 -4 x1 - x2 + x3 - x4 -6 x1 + x2 + x3 + x4 10 + x2 + x3 + 1 min x2 0 x3 1 x3 1 2x2 + 3x3 0

6. W = x1 - x2 - 2x4 max 2x1 - x2 + 2x3 - x4 4 x1 - 2x2 + x3 - 2x4 2 x1 - x4 1 x2 + x3 1

7. W = x1 - x2 + 3x3 + x4 max x1 - x2 + x4 1 x2 - x3 + x4 1 x1 + x3 + 2x4 2 -2x2 + x4 0 8. W = -x2 - 2x3 + x4 min 3x1 - x2 2 x2 - 2x3 -1 4x3 - x4 3 5x1 + x4 6

15. W = -3 + x1 + 3x2 x1 - x2 + x3 1 2x1 + x2 + x3 x1 + 2x2 + x3 x1 + x2 + 2x3

14. W = x1 - 10x2 + 100x3 max x1 + x2 + x3 1 x1 - x2 - x3 2 -x1 + 2x3 0 x1 + 2x3 5 1 1 1

13. W = x1 + x2 x1 - x2 x1 - 2x2 -x1 + x2 2x1 + x2

12. W = 2 + 2x2 - x3 -x1 + x2 - 2x4 x1 + x3 + x4 x2 + x3 - x4 x3 4; x2

+ 3x4 max -1 1 1 10

+ 3 max 1 -2 -1 -2

+ 5x3 max




16 11, 12 27 12 186 213 213 214 213 213 153 151 12 12 151 148 150 11 190 193 198

195 201 195 27 27 32 32 32 32 32 32 32 32 52 32 32 32 32 220 11 for 170 if 164 select 168 while 170 164


257 17 17 138, 139 53 54 55 53 SciPad 14 53 12 53 19 138, 140 146 143 - 14 22, 183 cat 39 close 188 cond 46 costf 234 delete 188 det 45 diag 38 evstr 164 eye 35 figure 186 fsolve 143, 146 full 37 hypermat 38 input 163 integrate 150 intg 151 inttrap 148 inv 47 kernel 51 length 42 linpro 239 linsolve 48 lu 50 matrix 34 max 43 mclose 179 mean 44 median 44 meof(f ) 177 mfprintf 177 mfscanf 177 min 44 mopen 176 norm 45 numdiff 153 ode 156 ones 34 optim 233í237 pinv 48 poly 138 prod 43 qr 50 rand 36 rank 45 roots 140 rref 49 size 41 sort 41 sparse 37 spec 47 sum 42 svd 51 tril 39 triu 40 uicontrol 189 x_dialog 163 zeros 35 216




[1] . . . 840 .

.: , 2002.

[2] . . . Maple. .: , 2004. 539 . [3] . ., . . . , 1966. 724 . [4] www.freefem.org .:




, , , 8 40 . , , 6 20 . , .


Scilab:

: . . : . . : . : . .

16.05.08. 70x100/16. Computer Modern. . . . . . 22,1. 2000 .

: 119334, , 5- , . 21, . 21 : (495) 662-38-83. E-mail: sales@altlinux.ru http://altlinux.ru . : 125167, , , 3 (499) 157-52-72. E-mail: binom@Lbz.ru http://www.Lbz.ru