Академический Документы
Профессиональный Документы
Культура Документы
V d
> 2+2;
4
> (3 + 7 + 10)*(1000 - 8)/(900 + 90 + 2) - 17;
3
> 2^1000;
10715086071862673209484250490600018105614048117055336074437503883703 \
5105112493612249319837881569585812759467291755314682518714528569 \
2314043598457757469857480393456777482423098542107460506237114187 \
7954182153046474983581941267398767559165543946077062914571196477 \
686542167660429831652624386837205668069376
> 100!;
93326215443944152681699238856266700490715968264381621468592963895217 \
5999932299156089414639761565182862536979208272237582511852109168 \
64000000000000000000000000
> length(%);
158
Mt s hm thng s dng khi tnh ton trn cc s nguyn:
abs:
tnh gi tr tuyt i ca mt biu thc
factorial (hoc !)
iquo:
irem:
iroot:
isqrt:
tnh xp x cn bc 2 ca mt s nguyn
max, min:
mod:
tnh ng d s hc
ifactor:
isprime:
..........
Mt khc, Maple c th tnh ton xp x cc hng s c bit hoc cc biu thc n sai s
m ngi s dng mong mun.
V d
> Pi;
> evalf(Pi);
3.141592654
> evalf[100](Pi);
3.141592653589793238462643383279502884197169399375105820974944592307 \
816406286208998628034825342117068
> ln(exp(4));
4
Vi s phc, Maple s dng k hiu I biu din cho cn bc hai ca -1. Maple cn c lnh
cho php ta chuyn i cc s t h m ny sang h m khc.
V d
> (2+5*I)+(1-I);
4I
7
25
1
I
25
> (1+I)/(3+4*I);
> convert(247,binary);
11110111
> convert(1023,hex);
3FF
> convert(10,base,8);
[ 2, 1 ]
V d
1. Cho ra 100 s nguyn t u tin
> seq(ithprime(i),i=1..99);
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277,
281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,
389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487,
491, 499, 503, 509, 521, 523
2. Tm c s chung ln nht, bi s chung nh nht ca cc s
> gcd(1923456,1256872);
8
> lcm(24,15,7,154,812);
267960
Cc php tnh c bn
Khai trin biu thc
S dng lnh expand. Xem cc v d sau:
> poly := (x+1)*(x+2)*(x+5)*(x-3/2);
poly := ( x
1) (x
2) (x
5) x
3
2
x4
13 3
x
2
5 x2
31
x
2
15
2 sin( x ) cos( x )
> ln( abs(x^2)/(1+abs(x)) );
ln
x
1
> expand(%);
2 ln( x ) ln( 1
x)
37 x3
10 x2
52 x
24
> % mod 3;
x7
2 x6
2 x5
x3
x2
2x
x7
2 x6
2 x5
x3
x2
2x
y2 x2
(1
y2 ) x2
2xy
3y
3) y
x2
y2 x2
(2 x
y ) sin( x )
( sin( f( x ) )
sin( x ) )
d
f( x )
dx
( sin( x )
sin( f( x ) ) )
d2
f( x )
dx 2
z) x
(x
y ) ( x2
xy
y2 )
y8
x8
(x
1 ) ( x2
2 ) ( x2
1)
2 2
> factor( % );
2 ( x2
1) (x
2 ) (x
2 ) (x
1)
poly := x4
5 x2
( x2
> factor( poly, sqrt(2) );
( x2
2 ) ( x2
3) (x
3)
2 ) (x
2)
3)
Ngoi ra, lnh Factor cho php phn tch biu thc thnh cc tha s trn cc trng c bit
> Factor( x^2+3*x+3 ) mod 7;
(x 6) (x 4)
> Factor( x^3+1 ) mod 5;
( x2
4x
1) (x
1)
>
a biu thc v dng chun
S dng lnh normal thc hin vic ny. Lnh ny thng p dng i vi cc biu thc c
cha phn s, n s quy ng mu s v rt gn cc thnh phn chung a biu thc cho
v dng rt gn nht c th. Xt cc v d sau:
> normal( x + 1/x );
x2 1
x
> expr := x/(x+1) + 1/x + 1/(1+x);
x
1
expr :=
x 1 x
1
x
1
x
x2 y2
( x y )3
x
expr :=
1
x
big_expr := sin
1) x
x 2
cos
x2
x 2
x2
x
cos
x2
x
c bit: lnh normal c th tr v biu thc dng khai trin m dng ny khng n gin hn
dng ban u. Trong nhng trng hp ny ta nn s dng lnh factor.
> expr := (x^25-1) / (x-1);
x 25 1
expr :=
x 1
> normal( expr );
1 x 15 x x 2 x 3 x 4
x9
x 14
x 13
x5
x7
x 16
x 24
x 12
x 19
x 18
x 17
> factor(expr);
( x4 x3 x2 x 1 ) ( x20
x15
x10
x5
x 22
x 23
x 21
x 20
x8
x6
x 11
x 10
1)
cos( x )4 ( cos( x )
1)
Nu mun p dng mt s quy lut c bit trong lng gic, trong cc hm logarit, hoc trong
cc hm m th ta phi ch cho maple bit.
> expr := ln(3*x) + sin(x)^2 + cos(x)^2;
expr := ln( 3 x ) sin( x )2 cos( x )2
> simplify( expr, trig ); #trigonometric: luong giac
ln( 3 x ) 1
> simplify( expr, ln );
ln( 3 )
ln( x )
sin( x )2
cos( x )2
ln( 3 ) ln( x ) 1
Ta cng c th n gin biu thc vi gi thit cho trc
> expr := sqrt( (x*y)^2 );
expr := x2 y2
> simplify( expr );
x2 y2
xy
> simplify( expr, assume=positive );
xy
>
Sp xp biu thc
i khi ta nhp vo mt biu thc, v d nh mt a thc, th Maple c th hin th a thc
nhng khng sp xp theo ng th t bc ca a thc. sp xp li a thc theo th t
gim dn ca bc ta dng lnh sort. Xem cc v d:
> poly := 1 + x^4 - x^2 + x + x^3;
poly := 1 x4 x2 x x3
> sort( poly );
x4
x3
x2
x4
x3
x2
> poly;
> sort( x+x^3 + w^5 + y^2 + z^4, [w,x,y,z] );
w5 z4 x3 y2 x
> sort( x^3*y + y^2*x^2, [x,y] );
x3 y
x2 y2
Mt s lnh khc
Lnh convert: chuyn biu thc v mt dng xc inh
> convert(cos(x),exp);
1 (x I) 1 ( I x)
e
e
2
2
> convert(1/2*exp(x)+1/2*exp(-x),trig);
cosh( x )
> restart;
> A:=Matrix([[a,b],[c,d]]);
A :=
a
c
b
d
> convert(A,'listlist');
[ [ a, b ], [ c, d ] ]
> convert(A,'set');
{ a, b, c, d }
> convert(%,'list');
[ a , b , c, d ]
1
sin( 2 x )
2
> combine( exp(x)^2 * exp(y) );
(2 x
e
y)
(2 a)
> infolevel[combine] := 1;
infolevel combine := 1
x 2 dx
combining
combining
combining
combining
combining
combining
combining
combining
combining
combining
combining
combining
combining
combining
with
with
with
with
with
with
with
with
with
with
with
with
with
with
respect
respect
respect
respect
respect
respect
respect
respect
respect
respect
respect
respect
respect
respect
to
to
to
to
to
to
to
to
to
to
to
to
to
to
linear
linear
linear
cmbpwr
power
power
power
cmbplus
cmbpwr
power
cmbpwr
power
power
power
x 2 dx
>
>
Lnh map: c tc dng p dng mt dng (biu thc, gi tr, hm, ...) ln ton b cu trc d
liu cho trc.
> map(f,[a,b,c]);
[ f( a ), f( b ), f( c ) ]
> ds:=[0,Pi/2,2*Pi/3,2*Pi];
ds := 0,
2
,2
2 3
,
> map(sin,ds);
0, 1 ,
3
,0
2
> ds1:=[sin(x),ln(x),x^2];
ds1 := [ sin( x ), ln( x ), x2 ]
> map(Diff,ds1,x);
d
d
d
sin( x ), ln( x ), ( x2 )
dx
dx
dx
> map(value,%);
cos( x ),
1
,2x
x
> map(x->x^2,[-1,0,1,2,3]);
[ 1, 0, 1, 4, 9 ]
>
Lnh series: to mt chui khai trin (hay khai trin Taylor) ca biu thc
> series(sin(x),x=0,10);
1 3
1 5
1 7
1
x
x
x
x
x9
6
120
5040
362880
O( x10 )
> series(exp(x),x=0,5);
> series(log(x),x=1,5);
1
1
1
x 1
( x 1 )2
( x 1 )3
(x
2
3
4
1 2
x
2
1 3
x
6
1 )4
1 4
x
24
O( x5 )
1 )5 )
O( ( x
> f(x):=(1+x)^n;
f( x ) := ( x
> series(f(x),x=0,5);
n (n 1) 2 n (n 1) (n
1 nx
x
2
6
2)
x3
1 )n
n (n
1) (n 2) (n
24
3)
x4
O( x5 )
y, y
y}
> eqns := {x +
y +
z = 3,
x + 2*y + 3*z = 6,
x + 4*y + 9*z = 14};
eqns := { x y z 3, x 2 y 3 z 6, x 4 y
9 z 14 }
> solve(eqns);
{ x 1, z 1, y 1 }
>
> restart;
- Khi ta gii phng trnh v thu c nghim th nghim c cho dng tp hp. Ta c
th s dng cc lnh bit chuyn dng nghim trn v cc cu trc d liu khc nh danh
sch.
V d
> sol:=solve({x+2*y=3,y+1/x=1},{x,y});
1
sol := { x -1, y 2 }, { x 2, y
}
2
> convert(sol[1],list);
[ x -1, y 2 ]
> eval([x,y],sol[1]);
[ -1, 2 ]
> eval([y,x],sol[1]);
[ 2, -1 ]
> restart;
- i khi phng trnh c nhiu nghim nhng Maple khng hin th ht nghim m ch hin th
mt vi nghim, ta s dng thm lnh sau buc Maple biu din ht nghim.
V d
> eqn:=sin(Pi*x/4)=cos(Pi*x/4);
x
x
eqn := sin
cos
4
4
> solve(%,{x});
{x 1}
> _EnvAllSolutions:=true;
_EnvAllSolutions := true
> solve(eqn,{x});
{ x 1 4 _Z1~ }
Ta c th thy c cc nghim ca phng trnh ny thng qua vic v th sau:
> plot(sin(Pi*x/4)-cos(Pi*x/4),x=-12..12,scaling=constrained);
Lnh unapply
- Lnh ny cho php xc nh hm s t biu thc v cc bin.
V d
> f := unapply(x^2 + y^2 + 4, x, y);
f := ( x, y ) x2 y2 4
> f(a,b);
a2
b2
527
13
s2 := { x
7t
28 u
,z
13
70
13
59 u
,y
13
7t
635
13
12 t
70 u
}
13
> eval( x, s2 );
527
13
28 u
13
7t
> x(1,1);
x( 1, 1 )
> x := unapply(%, u, t);
# % = eval(x,s2)
x := ( u, t ) x( 1, 1 )
> x(1,1);
Error, (in x) too many levels of recursion
Lnh RootOf
i khi, Maple tr v nghim ca cc phng trnh di dng lnh RootOf. iu ny thc s
hu ch nu trng i s ca ta ang lm vic khc vi trng s phc. Cc index i theo trong
lnh RootOf chnh l th t cc nghim. Nu mun ly gi tr tng minh ca cc nghim ta c
th s dng hm evalf.
V d
> solve({x^5 - 2*x + 3 = 0},{x});
{ x RootOf( _Z5 2 _Z 3, index 1 ) }, { x RootOf( _Z5 2 _Z 3, index 2 ) },
{x
RootOf( _Z5
2 _Z
3, index
3 ) }, { x
{x
2 _Z
3, index
5)}
RootOf( _Z
RootOf( _Z5
2 _Z
3, index
4 ) },
> evalf(%);
{ x 0.9585321812 0.4984277790 I }, { x -0.2467292569 1.320816347 I },
{ x -1.423605849 }, { x -0.2467292569 1.320816347 I },
{ x 0.9585321812 0.4984277790 I }
Lnh fsolve
- Lnh ny tng ng vi lnh solve, nhng nghim thu c khi gii phng trnh bng
lnh ny l mt dng nghim xp x di dng s.
V d
> fsolve({cos(x)-x = 0}, {x});
{ x 0.7390851332 }
> poly :=3*x^4 - 16*x^3 - 3*x^2 + 13*x + 16;
poly := 3 x4 16 x3 3 x2 13 x 16
> fsolve({poly},{x});
{x
1.324717957 }, { x 5.333333333 }
{ x 0. }
0.5622795121 I },
Lnh dsolve
Maple c th gii nhiu phng trnh vi phn bnh thng (ODEs: ordinary differential
equations) bng lnh dsolve
V d 1
> ode1 := {diff(y(t),t,t) + 5*diff(y(t),t) + 6*y(t) = 0};
d2
d
ode1 := { 2 y( t )
5
y( t )
6 y( t ) 0 }
dt
dt
> ic := {y(0)=0, D(y)(0)=1};
ic := { y( 0 )
0, D( y )( 0 ) 1 }
3 t)
y1 := t
( 2 t)
( 3 t)
> y1(a);
( 2 a)
( 3 a)
V d 2
> pt := { diff(y(x),x,x)=z(x), diff(z(x),x,x)=y(x) };
d2
d2
pt := { 2 y( x ) z( x ), 2 z( x ) y( x ) }
dx
dx
> nghiem := dsolve(pt, {z(x),y(x)});
( x)
nghiem := { z( x ) _C1 e x _C2 e
_C3 sin( x ) _C4 cos( x ),
y( x )
_C1 e x
_C2 e
( x)
_C3 sin( x )
_C4 cos( x ) }
> y(1);
_C1 e
_C2 e
( -1 )
_C3 sin( 1 )
_C4 cos( 1 )
> y:='y';
y := y
Mt s lnh khc
Lnh isolve: tm nghim nguyn ca cc phng trnh
> isolve({3*x-4*y=7});
{ y 2 3 _Z1, x 5 4 _Z1 }
Lnh msolve: gii phng trnh theo modulo m
> msolve({3*x-4*y=1,7*x+y=2},17);
{ y 6, x
14 }
> msolve({2^n=3},19);
{ n 13 18 _Z2 }
> solve({3*x-4*y=1,7*x+y=2});
{x
9
,y
31
-1
}
31
> about(_Z1);
_Z1:
nothing known about this object
1.4. o hm
V d 1
> y := x^4+x^3+x^2+x+1;
y := x4
x3
d 4
(x
dx
x3
x2
> Diff(y,x);
x2
1)
> diff(y,x);
4 x3
3 x2
2x
> Diff(y,x,x,x);
d3 4
(x
dx 3
x3
x2
1)
> diff(y,x$3);
24 x 6
> unassign('y');
V d 2
> z:=x*exp(x/y)+sin(y/x);
x
y
z := x e
sin
y
x
> diff(z,x,y);
2xe
y2
x
y
x e
y3
x
y
sin
y
y
x
x3
cos
y
x
x2
> diff(z,x$2);
2e
y
x
y
xe
y2
x
y
sin
y 2
y
x
x4
y
y
x
2 cos
x3
> diff(z,y,y);
2
2x e
y3
x
y
x e
y4
x
y
sin
y
x
x2
V d 3
> f := (x) -> sqrt(2*Pi)*x^(x+1/2)*exp(-x);
( x 1/2 ) ( x )
f := x
2 x
e
> simplify(diff(f(x),x));
1
2
2
(x
1/2 )
( x)
( 2 ln( x ) x
> evalf(50!);
0.3041409320 1065
> evalf(f(50));
0.3036344593 1065
> seq(evalf(n!/f(n)),n=2..22);
1)
( x)
> simplify(int(x^4*exp(-x),x));
( 24 24 x 12 x2
dx
4 x3
x4 ) e
( x)
> Int(x/(x^4-1),x);
x
x
dx
> int(x/(x^4-1),x);
1
ln( x
4
1
ln( x
4
1)
1)
1
ln( x2
4
1)
2
( x )
dx
> value(%);
>
>
sin( x y ) dx dy
1
> value(%);
> evalf(%);
0.6075702747
> ?Doubleint
> restart:with(student):
> Tripleint(sin(x*y*z),x=0..1,y=0..1,z=0..1);
1
sin( x y z ) dx dy dz
0
> value(%);
1
ln ( z ) Ci( z )
dz
z
0
> evalf(%);
0.1224340288
sin( x )
cos( x )
y dy dx
0
> evalf(%);
1.417868442
> Int(sin(x)*Int(y^2,y=0..sin(x)-cos(x)),x=Pi/4..3*Pi/4);
3
4
sin( x )
cos( x )
y 2 dy dx
sin( x )
0
4
> value(%);
1
6
thin gii quyt cc vn trong STT, l LinearAlgebra hoc linalg. Trc khi
lm vic vi STT ta nn gi gi cng c with(LinearAlgebra) hoc with(linalg);
1
3
5
5
5
5
2
4
> Matrix(1..2,1..3,5);
5
5
> array([[1,2],[3,4]]);
1
3
2
4
0
0
0
0
B2, 1 := 7
B2, 2 := 4
> B;
2
7
3
4
b := [ 5, 6 ]
Nu mun cho ra mt vect t cc hng hoc cc ct ca mt ma trn c ta dng lnh
Column v Row nh sau
V d
> c:=Column(A,2);
2
c :=
4
> c:=Row(A,1);
c := [ 1, 2 ]
s :=
1
2
3
2
1
> evalf(eval(e,{x=1,y=2}));
2.
0.8414709848
2.
1.
> B+C;
4
9
16
4
11
15
4
10
17
> E:=Add(B,C);
4
E := 9
16
4
11
15
4
10
17
Php nhn
nhn cc ma trn hoc cc vect vi nhau ta dng lnh Multiply, xt cc v d sau:
> G:=Multiply(B,C);
40
35
33
G := 91
80
72
142 125 111
Lnh ny cng c th thc hin vic nhn mt ma trn vi mt vec t
> b:=<5,6,7>;
5
b := 6
7
> Multiply(B,b);
38
92
146
Ngoi ra, ta c th nhn ma trn v vect vi mt v hng bng php nhn * thng thng
> 3*B;
3
12
21
6
15
24
9
18
27
> 5*b;
25
30
35
33
5
6
4
9
7
8
> E:=Matrix([[1,2,3]]);
E := [1
3]
> Transpose(E);
1
2
3
17
Rank: Tm hng ca mt ma trn
> with(LinearAlgebra):
A := ScalarMatrix(n,3);
n
A := 0
0
0
n
0
0
0
n
> Rank(A);
3
Tch v hng v gc gia 2 vect
tnh tch v hng ca 2 vct ta dng lnh DotProduct, tnh gc gia 2 vect ta dng lnh
VectorAngle. Xt cc v d sau:
> restart:with(LinearAlgebra):
> v1:=<1|2|3>;v2:=<4|5|6>;
v1 := [ 1, 2, 3 ]
v2 := [ 4, 5, 6 ]
> DotProduct(v1,v2);
32
> VectorAngle(v1,v2);
arccos
16 14 77
539
> evalf(VectorAngle(v1,v2));
0.2257261290
V d
> restart;with(LinearAlgebra):
> A:=Matrix([[1,1,-3/2],[0,-1,1],[1,-2-1/4,1]]);
-3
1
1
2
A := 0 -1
1
-9
1
1
4
> b:=Vector([0,6,0]);
b :=
0
6
0
> LinearSolve(A,b);
19
20
26
> ?LinearSolve
Trong v d th 2 ny ta s gp lnh RandomMatrix dng to ma trn vi cc phn t ngu
nhin, v gii h phng trnh tuyn tnh theo 2 cch.
V d
> Ab := RandomMatrix(3,4, outputoptions=[datatype=float]);
-70. -94. -53. 40.
Ab := 13. -7. 21. 97.
-58. 12. -25. 43.
> LinearSolve(Ab);
-3.83651127878185338
-1.27278664872979652
6.56976857538359660
6.569768576, x -3.836511279 }
1, 2, 3, 4
> x,y,z,u;
x, y, z, u
Lu rng cu trc ny khng phi l mt danh sch hay mt tp hp. y l mt cu trc da
liu ri rc trong Maple c nhng tnh cht ring:
- Dy cc biu thc l mt cu trc biu din c th t cc thnh phn v cho php cc thnh
phn trong dy trng nhau. Th t khi ta nhp vo cng chnh l th t ca cc thnh phn.
- Ta c th thc hin php ton ghp (||) trn cu trc ny.
V d
> a||b;
0
a || 6
0
> S:=1,2,3,4;
S := 1, 2, 3, 4
> a||S;
- Ngoi ra ta cng c th s dng cu trc ny thc hin php gn chung cho nhiu thnh
phn.
V d
> f,g,h:=2,-1,5;
f, g, h := 2, -1, 5
> g;
-1
1, 2 x
3, 3
x]
> dsten:=[Tom,Jerry,Mickey];
dsten := [ Tom, Jerry, Mickey]
> b:='b';
b := b
> ds_cua_ds:=[[a,b],[1,2,3],[x,y,z]];
ds_cua_ds := [ [ a, b ], [ 1, 2, 3 ], [ x, y, z ] ]
Lu rng Maple bo ton th t ca cc phn t trong danh sch ging vi th t c nhp
vo, do ta c th truy cp trc tip vo cc phn t thng qua th t ca chng.
V d
> chucai:=[a,b,c,d,a];
chucai := [ a, b, c, d, a ]
> chucai[3];
c
Ta c th kim tra mt cu trc c nhp vo c phi l danh sch hay khng bng lnh type.
V d
> type(poly,list);
false
> type(ds_cua_ds,list);
true
> type(ds_cua_ds,listlist);
false
y listlist cng l mt cu trc tm gi l danh sch ca danh sch, nhng ch cc danh sch
thnh phn trong listlist phi c cng s phn t.
> L:=[[1,2],[a,b],[x,y]];
0
L := [ 1, 2 ], a, 6 , [ x, y ]
0
> type(L,listlist);
true
>
Ta c th truy nhp trc tip vo cc thnh phn ca danh sch thng qua th t cc phn t
bng cc cch sau:
V d
> L:=[1,3,5,a,b];
L := [ 1, 3, 5, a, b ]
> L[4];
a
> op(4,L);
a
> nops(L); #Cho ra so phan tu trong danh sach
5
> op(L); #tra ve day cac phan tu cua danh sach
1, 3, 5, a, b
Tp hp (Set)
- Ging nh k hiu ta vn thng din t khi lm ton, tp hp c to thnh khi ta gom cc
i tng (cch nhau bi du phy) vo trong cp du ngoc{}.
- Cc phn t trong tp hp phi phn bit v cu trc ny khng tnh n th t ca cc phn t.
Do , nu ta nhp vo tp{a,b,c} hay{b,c, a} l nh nhau.
- Tuy nhin, Maple phn bit gia s nguyn v s thc (ngha l s 2 v 2.0 l khc nhau) nn
tp hp nh sau vn c chp nhn: {1,2,2.0}
V d
> data_set:={1,-1,2,7};
data_set := { -1, 1, 2, 7 }
> var:={x,y,z};
var := { y, x, z }
> {a,b,c},{b,c,a},{a,a,b,c,a};
{ a, c, b }, { a, c, b }, { a, c, b }
> {1,2,3,1,2.0};
{ 1, 2, 3, 2.0 }
- Trn tp hp ta c th thc hin cc php ton: union, intersect, minus hoc nhiu php ton
khc. Tp rng c k hiu l{}.
V d
> {a,b,c} union {c,d,e};
{ e, a, c, b, d }
> {1,2,3} intersect {0,1,a,2};
{ 1, 2 }
> nops(%);
2
* Mt lnh rt thng c s dng trn tp hp l lnh map lnh ny cho php p dng
mt hm ng thi ln tt c cc thnh phn ca tp hp.
V d
> number:={0,Pi/2,Pi/3,Pi};
number := { 0,
, , }
2 3
> map(g,number);
{ g( 0 ), g
,g
, g( ) }
> map(sin,number);
{ 0, 1,
3
}
2
> tap_rong:={};
tap_rong := { }
> ds_rong:=[];
ds_rong := [ ]
> nops(ten);
4
> op(3,ten);
Donal
Mng (Array)
- L mt kiu cu trc d liu m rng ca cu trc danh sch, trong cc ch s ca mt mng
bt k u l cc s nguyn v phm vi ca cc ch s mng phi c nh r khi khai bo
mng. Cc thnh phn trong mng i lin vi ch s ca n. Hn na, ta c th nh ngha li cc
thnh phn mt cch ring bit m khng cn phi nh ngha li ton b mng.
V d
> A:=array(1..2,1..2,[]);
A := array( 1 .. 2, 1 .. 2, [ ] )
> A[1,1]:=1: A[1,2]:=4: A[2,1]:=2: A[2,2]:=3:
> A;
A
> print(A);
1
2
4
3
> B:=array(1..3,[a,b,c]);
B := [ a, b, c ]
- Ngoi ra, nu ta mun thay th cc thnh phn ca mng bi cc gi tr hoc biu thc khc th
c th dng lnh subs (vit tt t ch substitution) nh sau:
V d
> bt:=z^3+2;
bt := z3 2
> subs({z=x+y},bt);
(x
y )3
> a:=array(1..2,[5,3]);
a := [ 5, 3 ]
> subs({5=9},a);
a
> a1:=subs({5=9},evalm(a));
a1 := [ 9, 3 ]
Bng (Table)
- L mt cu trc d liu m rng ca cu trc mng. S khc nhau gia bng v mng l ch s
ca bng c dng bt k ch khng ch gii hn s nguyn nh mng. Cu trc chung ca mt
bng l: table( F, L);
trong F l danh sch cc ch s, cn L l danh sch cc phn t. Ta c th hnh dung mt
bng nh l mt nh x a tr t tp cc ch s F n tp cc phn t L.
V d
> T:=table([[1,2],[a,b],[c,d,e]]);
T[2];
T := table([1 [ 1, 2 ], 2 [ a, b ], 3
[ c, d, e ]])
[ a, b ]
> bang:=table([one=vang,two=xanh,three=den]);
bang := table([two xanh, one vang, three
den])
> bang[two];
xanh
> guitar[day1]:=mi,fa,sol;
guitarday1 := mi , fa, sol
> guitar[day2]:=si,ddo,re;
guitar day2 := si, ddo, re
> guitar[day3]:=sol,la;
guitarday3 := sol, la
> print(guitar);
table([day1 ( mi, fa, sol ), day3
Chui (String)
- Ging nh cc ngn ng lp trnh khc, chui trong Maple l mt tp hp cc k t nm gia
hai du nhy kp "".
- Trn chui, ta c th truy xut bt c thnh phn no ca n da vo v tr ca thnh phn
trong chui bng cch tng t nh bng hoc danh sch; ta c th ghp hai chui li bng
php ton || hoc cat; v c th xem di ca chui bng lnh length.
V d
> "This is a string";
"This is a string"
> chuoi:="Later than Never";
chuoi := "Later than Never"
> chuoi[7..10];
"than"
> new:=cat("I have to learn. ",chuoi);
new := "I have to learn. Later than Never"
> length(new);
33
with(package)
>
>
Sau y gii thiu mt s gi lnh thng hay s dng trn Maple
1. CodeGeneration: cha cc hm c th dch cc m trong Maple thnh nhng ngn ng
lp trnh khc nh: C, Fortran, Java, Visual Basic.
2. combinat: cc hm t hp, bao gm cc lnh cho vic tnh ton cc hon v v t hp
ca cc danh sch...
3. combstruct: gm cc lnh cho vic to ra v tnh ton cc cu trc t hp, thng s
dng xc nh cc phng trnh hm sinh ra trong tnh ton.
4. DEtools: cc cng c thao tc trn cc phng trnh vi phn
5. Domains: cha cc lnh dng to ra tp xc nh ca cc tnh ton; h tr tnh ton
vi a thc, ma trn, chui trn cc vnh s, vnh a thc, vnh cc ma trn.
6. Maplets: gm cc cu lnh cho vic to ra cc giao din nh ca s tnh ton, hp thoi
hoc cc giao din khc cho cc ng dng.
7. numtheory: gm cc cu lnh lm vi l thuyt s.
8. plots: cc lnh lin quan n v th ca hm s.
Xt mt s v d sau:
V d 1
tm o hm ca hm s ta c th s dng Maplet DiffTutor trong gi Student[Calculus1]
> with(Student[Calculus1]);
DiffTutor();
[ AntiderivativePlot, AntiderivativeTutor, ApproximateInt, ApproximateIntTutor,
ArcLength, ArcLengthTutor, Asymptotes, Clear, CriticalPoints, CurveAnalysisTutor,
DerivativePlot, DerivativeTutor, DiffTutor, ExtremePoints, FunctionAverage,
FunctionAverageTutor, FunctionChart, FunctionPlot, GetMessage,
GetNumProblems, GetProblem, Hint, InflectionPoints, IntTutor, Integrand,
InversePlot, InverseTutor, LimitTutor, MeanValueTheorem,
MeanValueTheoremTutor, NewtonQuotient, NewtonsMethod, NewtonsMethodTutor,
PointInterpolation, RiemannSum, RollesTheorem, Roots, Rule, Show,
ShowIncomplete, ShowSteps, Summand, SurfaceOfRevolution,
SurfaceOfRevolutionTutor, Tangent, TangentSecantTutor, TangentTutor,
TaylorApproximation, TaylorApproximationTutor, Understand, Undo,
VolumeOfRevolution, VolumeOfRevolutionTutor, WhatProblem ]
Initializing Java runtime environment.
d
( x sin( x ) )
dx
sin( x )
x cos( x )
d
( x cos( x ) )
dx
cos( x )
x sin( x )
cos( x )
x sin( x )
> DiffTutor(x*cos(x));
> DiffTutor(x*cos(x),x);
d
( x cos( x ) )
dx
> restart;
tm hiu cch tnh tch phn ta dng lnh Rule
x dx
> Rule[sum](%);
Rulesum
x cos( x )
0
> Rule[power](%);
x dx
Rulepower Rulesum
x cos( x )
x dx
x cos( x )
x dx
> Rule[%](%%);
Rule
Hint Rule
Rulepower Rulesum
power
Rule
sum
x cos( x )
x cos( x )
x dx
x dx
> Rule[sin](%);
Rulesin Rule
Rulepower Rulesum
Hint Rule
power
Rule
sum
x cos( x )
x cos( x )
x dx
x dx
x cos( x )
x dx
>
Tm hiu cch tnh gii hn
1
x
rewrite, 1
x ln 1
1
x
> Rule[%](%%);
lim
1
x
x ln 1
1
x
x ln 1
1
x
lim e
x
> Hint(%);
[ exp ]
> Rule[%](%%);
lim
x
1
x
lim
> Hint(%);
1
x
lhopital, ln 1
> Rule[%](%%);
lim
1
x
lim
> restart;
>
V d 2
* Xc nh c s ca khng gian vect sinh bi cc vect: [1;-1; 0; 1], [5;-2; 3;-1], v [6;-3; 3;
0]. Biu din vect [1,2,3,-5] theo c s
> with(LinearAlgebra):
> v1:=<1|-1|0|1>:
v2:=<5|-2|3|-1>:
v3:=<6|-3|3|0>:
> vector_space:=<v1,v2,v3>;
1 -1 0 1
vector_space := 5 -2 3 -1
6 -3 3 0
> LinearSolve( Transpose(vector_space), <0,0,0,0> );
_t3
_t3
_t3
b1 := [ 1, 0, 1, -1 ]
b2 := [ 0, 1, 1, -2 ]
> basis:=<b1,b2>;
basis :=
1
0
0
1
1
1
-1
-2
>
V d 3
By gi ta s lm mt s tnh ton trn gi stats (gi thng k). Trong gi ny cha cc gi lnh
con:
> with(stats);
[ anova, describe, fit, importdata, random, statevalf, statplots, transform ]
Gi stats lm vic vi d liu dng danh sch thng k (c th to ra bi cu trc danh sch ca
Maple).
> marks :=[64,93,75,81,45,68,72,82,76,73];
marks := [ 64, 93, 75, 81, 45, 68, 72, 82, 76, 73 ]
> readings := [ 0.75, 0.75, .003, 1.01, .9125,
.04, .83, 1.01, .874, .002 ];
readings := [ 0.75, 0.75, 0.003, 1.01, 0.9125, 0.04, 0.83, 1.01, 0.874, 0.002 ]
> describe[mean](marks);
729
10
> describe[range](marks);
45 .. 93
> describe[range](readings);
0.002 .. 1.01
> describe[standarddeviation](readings);
0.4038751074
> random_data:=[random[normald](50)];
random_data := [ 1.275676034, 0.4761860895 , -2.620054215, 0.8547207946 ,
-1.089001803, 0.7165427609 , -0.02996436194, 1.330855643 , -1.296345120,
-0.4703304005, -0.7122630822, -0.08717900722, 1.282253011, -1.683720684,
0.3265473243 , 0.08179818206 , 0.2127564698 , -0.7279468705, 0.6855773713 ,
-0.3760280547, -0.8074455431, 0.5638425492 , 0.7668276240 , -0.9578304704,
0.09625284223 , -0.5899328336, 0.8199273969 , 1.522884873, -0.2965618595,
-0.7531006388, 0.3151206337 , -0.6711662977, -0.3957955372, 0.3570600824 ,
0.004561604546 , -0.2594005341, 0.8186971245 , -0.7093245232, -0.1522233390,
-0.01405914095, -0.6157994795, -0.7439751083, 0.7842556864 , 2.454999901,
0.8338628854 , -0.9492334297, -0.7742757515, 0.1717256675 , -1.535635792,
1.087459487 ]
>
>
>