You are on page 1of 396

bé gi¸o dôc vµ ®µo t¹o

®¹i häc huÕ


trêng ®¹i häc s ph¹m
--------------------------o0o--------------------------
tiÓu luËn maple
§Ò tµi:c¸ch t¹o malet vµ c¸c kiÓu giao
diÖn t¬ng t¸c trong maplet
gi¸o viªn híng dÉn: ts. nguyÔn ch¸nh tó
häc viªn thùc hiÖn: §ç Träng hoµng
líp: cao häc to¸n khãa xv
chuyªn ngµnh: §¹i sè - lý thuyÕt sè
huÕ, th¸ng 12 n¨m 2006
1. lêi nãi ®Çu:
c¸ch d¹y häc - to¸n hiÖn nay ë nhµ trêng phæ th«ng, thËm chÝ ë c¶ ®¹i häc n÷a
gièng nh viÖc thÇy gi¸o dÉn häc sinh ®i tham quan mét l©u ®µi ®· ®îc x©y
dùng xong tõ l©u(l©u ®µi to¸n häc). ta gäi c¸ch d¹y häc ®ã lµ c¸ch d¹y häc
"tÜnh". cã thÓ ch¨ng h×nh dung ra mét c¸ch d¹y häc mµ ta gäi lµ "®éng" trong
®ã thÇy gi¸o híng dÉn häc sinh tham gia thiÕt kÕ råi thi c«ng l©u ®µi ®îc
kh«ng? maple lµ phÇn mÒm cã thÓ gióp gi¸o viªn chÒ ®éng h¬n khi d¹y
häc to¸n. maple lµ mét c«ng cô cã thÓ gióp häc sinh, sinh viªn tù t×m tßi
s¸ng t¹o to¸n häc vµ chÒ ®éng khi tham gia häc tËp. maple cung cÊp c¸c
gãi lÖnh tù häc (gãi student...) g¾n liÒn víi to¸n phæ th«ng vµ ®¹i häc. víi
môc ®Ých t×m hiÓu c¸ch t¹o c¸c gãi lÖnh tù häc, t«i chän ®Ò tµi "c¸ch t¹o
maplet vµ c¸c kiÓu giao diÖn maplet" lµm ®Ò tµi tiÓu luËn cÒa m×nh.
do thêi gian cã h¹n nªn tiÓu luËn khã tr¸nh khái nh÷ng thiÕu sãt, v× vËy
rÊt mong ®îc sù gãp ý cÒa thÇy c« vµ b¹n bÌ. cuèi cïng t«i xin ch©n thµnh
c¶m ¬n thÇy gi¸o ts. nguyÔn ch¸nh tó ®· híng dÉn t«i hoµn thµnh tiÓu
luËn nµy.
2. c¸ch t¹o maplet, c¸c kiÓu giao diÖn vµ t¬ng t¸c:
[xem. creating a maplet application]
ë ®©y t«i chØ nªu ra c¸ch t¹o vµ c¸c kiÓu giao diÖn c¬ b¶n nhÊt ®Ó nh÷ng ngêi
míi ®äc cã thÓ sö dông vµ lµm ®îc maplet cßn có ph¸p c©u lÖnh cã thÓ xem
b»ng c¸ch :
?<c©u lÖnh>. vÝ dô
> ? button
window body elements
2.1. t¹o button
> restart;with(maplets[elements]):
maplets[display]( maplet( [
button("ok", background=red,shutdown())
] ) );
initializing java runtime environment.
2.2.t¹o checkbox
> maplets[display]( maplet( [
[checkbox['chb1']( 'value' = 'true' )],
[button("ok", shutdown(['chb1']))]
] ) );
[ "true" ]
2.3.t¹o combobox
> maplets[display]( maplet( [
combobox['cob1']( 'value' = "blue", ["red", "orange", "yellow",
"green", "blue", "violet"] ),
button("ok", shutdown(['cob1']))
] ) );
[ "yellow" ]
2.4.t¹o dropdownbox
> maplets[display]( maplet( [
dropdownbox['ddb1']( 'value' = "victoria", [
"victoria", "edmonton", "regina", "winnipeg", "toronto",
"quebec city",
"fredericton", "halifax", "charlottetown", "st. john's",
"whitehorse",
"yellowknife", "iqaluit"] ),
button("ok", shutdown(['ddb1']))
] ) );
[ "Victoria" ]
2.5.t¹o listbox
> result := maplets[display]( maplet( [
listbox['lb1']( 'value' = "victoria", [
"victoria", "edmonton", "regina", "winnipeg", "toronto",
"quebec city",
"fredericton", "halifax", "charlottetown", "st. john's",
"whitehorse",
"yellowknife", "iqaluit"] ),
button("ok", shutdown(['lb1']))
] ) ):
if result <> null then
maplets[tools][listboxsplit]( result[1] );
end if;
[ "Iqaluit" ]
2.6. t¹o label
> maplets[display]( maplet( [
label( "c¸ch t¹o maplet vµ c¸c kiÓu t¬ng t¸c", 'font' = font(
'family'=".vntime", italic, 20 ) ),
button("ok", shutdown())
] ) );
2.7. hiÓn thÞ c«ng thøc to¸n
> maplets[display]( maplet( [
label("nhËp vµo mét c«ng thøc to¸n:",
'font' = font( 'family'=".vntime", italic, 20 ) ),
textfield['tf1']('value' = (x^2 - 4*x + 3)/ln(1/x)),
mathmlviewer['mmlv1']( ),
[button("display", evaluate( 'mmlv1' = 'mathml[export](tf1)' ) ),
button("ok", shutdown())]
] ) );
2.8. t¹o plotter
> maplets[display]( maplet( [
label("vÏ ®å thÞ hµm sè f(x):",
'font' = font( 'family'=".vntime", italic, 18 ) ),
textfield['tf1']( 'value' = x^2 - 4*x + 3),
plotter['pl1']( ),
[button("display", evaluate( 'pl1' = 'plot(tf1, x=0..10)' ) ),
button("ok", shutdown())]
] ) );
2.9. t¹o nót Radiobutton
> maplets[display]( maplet( [
[radiobutton['rb1']( "1st", true, 'group' = bg1 ),
radiobutton['rb2']( "2nd", 'group' = 'bg1' )],
[button("ok", shutdown(['rb1', 'rb2']))]], buttongroup['bg1']() )
);
[ "false" , "true" ]
2.10. t¹o thanh slider
> with(maplets[elements]):maplets[display]( maplet( [
label("chän mét sè tù nhiªn:",
'font' = font( 'family'=".vntime", italic, 20 )), slider['sl1'](
1, 0..20, 'majorticks'=5, 'minorticks'=1, 'showticks' ),
button("ok", shutdown(['sl1']))
] ) );
[ "1" ]
§Ó hiÓu râ h¬n vÒ c¸ch t¹o thanh slider ta cã vÝ dô sau: kh¶o s¸t hµm
sè d¹ng y = A sin( B x ) + C
> restart:with(maplets[elements]):
thutuc:=proc(a,b,c)
local p,f;
p:=a*sin(b*x)+c;
f := unapply(p,x); evalf(f(x));
end:
slider1 := maplet( window( 'title'= "khao sat ham so dang
a*sin(b*x)+c",[ [plotter['hv'](),
# tieu de: khao sat ham so
[[label("hµm sè ",'font' = font( 'family'=".vntime", italic, 18 )),
textfield['hs']('value'=2*sin(x)+2)],
# tao cac thanh cuon gia tri a, b, c
[label ("a=",'font' = font( 'family'=".vntime",18 )),slider['re1'](
-10..10, 2, 'majorticks'=2, 'minorticks'=1, 'showticks',
'onchange'='a1' )],
[label ("b=",'font' = font( 'family'=".vntime",18 )),slider['re2'](
-10..10, 2, 'majorticks'=2, 'minorticks'=1, 'showticks',
'onchange'='a1' )],
[label ("c=",'font' = font( 'family'=".vntime",18 )),slider['re3'](
-10..10, 2, 'majorticks'=2, 'minorticks'=1, 'showticks',
'onchange'='a1')]],
# tao cac nut lenh
[button('hienthi',evaluate('hv' = 'plot(re1*sin(re2*x)+re3,x=-
10..10)')),button('ok',shutdown())]
]]), action['a1'](evaluate('hv' = 'plot(re1*sin(re2*x)+re3,x=-
10..10)'),evaluate('hs' = thutuc(re1,re2,re3)))):
maplets[display](slider1);
2.11. t¹o textbox
> with(maplets[elements]):maplet := maplet([
[label("nhËp 1 dßng v¨n b¶n:",'font' = font( 'family'=".vntime",
italic, 14 ) ), boxcell(textbox['ib1'](3..30), 'as_needed')],
[button("ok", shutdown(['ib1'])), button("cancel", shutdown())]
]):
maplets[display](maplet);
[ "lkjk
"]
2.12. t¹o textfield
> maplets[display]( maplet( [
label("tÝnh nguyªn hµm cña hµm sè sau",'font' = font(
'family'=".vntime", italic, 14 ) ),
textfield['tf1']( 'value' = (x^2 - 4*x + 3)/x),
mathmlviewer['mmlv1']( ), [button("nguyenham", evaluate( 'mmlv1'
= 'mathml[export](int(tf1,x))' ) ), button("ok", shutdown(['tf1']))]
] ) );
[ "(x^2-4*x+3)/x" ]
2.13. t¹o menu
> maplets[display]( maplet(
window('title'="tinh dao ham va nguyen ham cua ham so",
'menubar'='mb1', [label("nhËp vµo mét hµm sè ",'font' = font(
'family'=".vntime", italic, 18 ) ),
[textfield['tf1']('value'=x^2+5/x)], mathmlviewer['mmlv1']( ),
mathmlviewer['mmlv2']( ), button("exit", shutdown())]),
menubar['mb1'](
menu("file", menuitem("close", shutdown(['tf1']))),
menu("thuc hien",menuitem("nguyenham", evaluate( 'mmlv1' =
'mathml[export](int(tf1,x))' ) ),
menuseparator(),
menuitem("daoham", evaluate( 'mmlv2' =
'mathml[export](diff(tf1,x))' ) )
)
)
) );
2.14. link ®Õn cöa sæ kh¸c
> with(maplets[elements]):
maplet := maplet('onstartup' = 'a1',
font['font1']('family'=".vntime", 'bold'=false, 'italic'=false,
size=15),
window['w1']('title' = "chon phuong an thuc hien", 'layout' = 'bl0'),
boxlayout['bl0'](
boxcolumn(
boxrow(label("c©n thùc hiÖn ph¬ng ¸n nµo", 'font'=
'font1')),
boxrow(
button("daoham", runwindow('w2')),
button("nguyenham", runwindow('w3')),button("exit",
shutdown())
)
)
),
window['w2']('title'="daoham", [
[
label("nhËp vµo 1 hµm sè",'font'='font1'),
textfield['tf1']('value'=ln(x^2+x))
], mathmlviewer['mmlv1']( ) ,
[
button("daoham", evaluate( 'mmlv1' =
'mathml[export](diff(tf1,x))' )),
button("trove", closewindow('w2')), button("exit",
shutdown())
]
]),
window['w3']('title'="nguyenham", [
[
label("nhËp vµo 1 hµm sè",'font'='font1'),
textfield['tf2']('value'=(ln(x)/(2*x)))
],
mathmlviewer['mmlv2']( ) , [
button("nguyenham", evaluate( 'mmlv2' =
'mathml[export](int(tf2,x))' )),button("trove", closewindow('w3')),
button("exit", shutdown())
]
]),
action['a1'](runwindow('w1'))
):
maplets[display](maplet);
2.15. t¹o table
> il := [1,x,exp(x),a^x, sin(x), cos(x), tan(x), cot(x)]:
maplets[display]( maplet( [
boxcell(table( ["ham so co ban", "nguyen ham"], [seq( [i, int(
i, x )], i = il )], 'width'=200 ), 'as_needed'),
button("ok", shutdown())
] ) );
2.16.t¹o toggle button
> maplets[display]( maplet( [
[togglebutton['rb1']( "1st", true ), togglebutton['rb2'](
"2nd" )],
button("ok", shutdown(['rb1', 'rb2']))]) );
[ "true" , "true" ]
dialog elements
2.17.chän mµu
> restart;with(maplets[elements]):maplets[display]( maplet(
colordialog['cd1'](
'onapprove' = shutdown(['cd1']),
'oncancel' = shutdown()
) ) );
[ "#CC0066" ]
2.18.open
> maplets[display]( maplet( filedialog['fd1'](
'onapprove' = shutdown(['fd1']),
'oncancel' = shutdown()
) ) );
2.19. hép tho¹i question
> maplets[display]( maplet( questiondialog("cau hoi ?",
'onapprove'=shutdown('true'),
'ondecline'=shutdown('false')
) ) );
"true"
2.20. hép tho¹i c¶nh gi¸c
> maplets[display]( maplet( alertdialog(
"canh giac",
'onapprove' = shutdown('true'),
'oncancel' = shutdown("fail")
) ) );
"true"
command elements
2.21. close window
> with(maplets[elements]):
maplet := maplet('onstartup' = 'a1',
window['w1']("1",
[button("mo cua so moi", runwindow('w2')),
button("exit", shutdown("1"))]
),
window['w2']("2",
[button("dong cua so", closewindow('w2')),
button("exit", shutdown("2"))]
),
action['a1'](runwindow('w1'))
):
maplets[display](maplet);
"1"
2.22. evaluate
> maplets[display]( maplet( [
[label("nhËp mét hµm sè theo biÕn x",'font' = font(
'family'=".vntime", italic, 20 )), textfield['tf1']()],[label("§¹o
hµm ",'font' = font(
'family'=".vntime", italic, 20 )),textfield['tf2']()],
[
button("dao ham", evaluate('tf2' = 'diff(tf1, x)')),
button("ok", shutdown(['tf1']))
]
] ) );
[ "x^2" ]
2.23. setoption
> maplets[display]( maplet( [
textfield['b1'](20),
textfield['b2'](20, 'editable'='false'),
[
button("xoa", setoption('target' = 'b1', 'value' = "")),
button("copy", setoption('target' = 'b2', argument('b1'))),
button("exit", shutdown(['b2']))
]
] ) );
[ "354545" ]
3. c¸c vÝ dô:
3.1. sù t¬ng giao trong kh«ng gian 3 chiÒu:
> restart: with(maplets[elements]):with(plots):
b := 'border'=true:
s := 'inset'=0, 'spacing'=0:
c := 'background'="#ddffff":
hinhdong3d:= proc(hs1,hs2,x1,x2,y1,y2,t1,t2)
local b;
b:=plot3d(hs1,x=x1..x2,y=y1..y2,axes=boxed,color=red):
animate( plot3d, [hs2, x=x1..x2,
y=y1..y2],t=t1..t2,color=blue,background=b);
end:
warning, the name changecoords has been redefined
> ve3d:= maplet(
'onstartup'=runwindow('mainwin'),
font['font1']('family'=".vntime", 'bold'=false, 'italic'=false,
size=13),
font['font2']('family'=".vntime", 'bold'=true, 'italic'=false,
size=15),
window['mainwin']('title'= "su tuong giao trong 3d",'menubar'='menu',
'layout'='body', 'width'=900, 'height'=800),
boxlayout['body'](
boxrow(s,c,b,
boxcolumn(s,c,b, 'caption'="sù t¬ng giao",'font'='font2',
plotter['hinhnen']()
),
boxcolumn(s,c,b,
boxrow(s,c,b, 'caption'= "h×nh nÒn",'font'='font2',
[boxrow(label("hµm sè hai biÕn f(x,y)=", 'font'='font1'),
textfield['hamso1'](50,'value'='x^2+y^2')
),
boxrow( label("x=",'font'='font1'),
textfield['x1'](3,'value'='-4'),label("®Õn",'font'='font1'),textfield
['x2'](3,'value'='4')
),
boxrow( label("y=",'font'='font1'),
textfield['y1'](3,'value'='-4'),label("®Õn",'font'='font1'),textfield
['y2'](3,'value'='4')
)]
),
boxrow(s,c,b, 'caption'= "h×nh ®éng",'font'='font2',
[boxrow( label("hµm sè hai biÕn (t tham sè)
f(x,y)=",'font'='font1'), textfield['hamso2'](20,'value'='t' )
),
boxrow( label("t=",'font'='font1'),
textfield['t1'](3,'value'='0'),label("®Õn",'font'='font1'),textfield[
't2'](3,'value'='32')
)]
),
boxrow(c, 'inset'=1, 'spacing'=1, button('display','onclick' =
'a1'),button('animate','onclick'='a1',setoption(hinhnen('play')=true)
),button('pause', setoption(hinhnen('pause')=true)),
button('close',shutdown())
)
))
),
action['a1'](evaluate('hinhnen' =
'hinhdong3d(hamso1,hamso2,x1,x2,y1,y2,t1,t2)' )),
menubar['menu'](
menu("file",
menuitem("display",'onclick'='a1'),
menuitem("animate",'onclick'='a1',setoption(hinhnen('play')=true
)),
menuitem("pause",setoption(hinhnen('pause')=true)),
menuitem("close",'onclick'=shutdown())
))
):
> maplets[display](ve3d);
3.2. ý nghÜa h×nh häc cña tÝch ph©n:
> restart: with(maplets[elements]):with(plots):with(student):
b := 'border'=true:
s := 'inset'=0, 'spacing'=0:
c := 'background'="#ddffff":
xapxileft:=proc(f,a1,b1,n1)
local n,s;
s:=seq(leftbox(f,x=a1..b1,n),n=6..n1):display(s,insequence=true);
end:
xapxiright:=proc(f,a1,b1,n1)
local n,s;
s:=seq(rightbox(f,x=a1..b1,n),n=6..n1):display(s,insequence=true);
end:
xapximid:=proc(f,a1,b1,n1)
local n,s;
s:=seq(middlebox(f,x=a1..b1,n),n=6..n1):display(s,insequence=true)
;
end:
warning, the name changecoords has been redefined
> tichphan:= maplet(
'onstartup'=runwindow('mainwin'),buttongroup['rg1'](),
font['font1']('family'=".vntime", 'bold'=false, 'italic'=false,
size=13),
font['font2']('family'=".vntime", 'bold'=true, 'italic'=false,
size=15),
window['mainwin']('title'= "tich phan va y nghia hinh hoc
",'menubar'='menu', 'layout'='body', 'width'=900, 'height'=800),
boxlayout['body'](
boxrow(s,c,b,
boxcolumn(s,c,b, 'caption'="h×nh vÏ",'font'='font2',
plotter['hinhve'](continuous=false),boxrow(label("gi¸ trÞ tp xÊp
xØ",
'font'='font1'),textfield['xxtp']('value'=evalf(leftsum(sin(x),x=0..2
,45))) ), boxrow( label("gi¸ trÞ tp thùc",
'font'='font1'),textfield['tpt']('value'=evalf(int(sin(x),x=0..2))))
),
boxcolumn(s,c,b,
boxrow(s,c,b, 'caption'= "nhËp hµm sè",'font'='font2',
[boxrow(label("f(x)=", 'font'='font1'),
textfield['f'](50,'value'='sin(x)')
),
boxrow( label("a=",'font'='font1'),
textfield['a1'](3,'value'='0'),label("b=",'font'='font1'),textfield['
b1'](3,'value'='2')
),
boxrow( label("n=",'font'='font1'),
textfield['n1'](3,'value'='40')
)]
),
boxrow(s,c,b, 'caption'= "tæng riemann",'font'='font2',
radiobutton['rb1']("left
point",'value'=true,'group'='rg1','onclick'='a1'),radiobutton['rb2'](
"right
point",'group'='rg1','onclick'='ar'),radiobutton['rb3']("middle
point",'group'='rg1','onclick'='am')
),
boxrow(c, 'inset'=1, 'spacing'=1, button('display','onclick' =
'a1'),button('animate',setoption(hinhve('play')=true)),button('pause'
, setoption(hinhve('pause')=true)), button('close',shutdown())
)
))
),
action['a1'](evaluate('hinhve' = 'xapxileft(f,a1,b1,n1)' ),
evaluate('xxtp' = 'evalf(leftsum(f,x=a1..b1,n1))' ), evaluate('tpt'
= 'evalf(int(f,x=a1..b1))' )),
action['ar'](evaluate('hinhve' = 'xapxiright(f,a1,b1,n1)' ),
evaluate('xxtp' = 'evalf(rightsum(f,x=a1..b1,n1))' ), evaluate('tpt'
= 'evalf(int(f,x=a1..b1))' )),
action['am'](evaluate('hinhve' = 'xapximid(f,a1,b1,n1)' ),
evaluate('xxtp' = 'evalf(middlesum(f,x=a1..b1,n1))' ),
evaluate('tpt' = 'evalf(int(f,x=a1..b1))' )),
menubar['menu'](
menu("file",
menuitem("display",'onclick'='a1'),
menuitem("animate",'onclick'='a1',setoption(hinhve('play')=true)
),
menuitem("pause",setoption(hinhve('pause')=true)),
menuitem("close",'onclick'=shutdown())
))
):
> maplets[display](tichphan);
>
4. kÕt luËn:
ë vd3.2 khi t¨ng c¸c h×nh hép th× gi¸ trÞ xÊp xØ ph¶i t¨ng theo ®Ó so
s¸nh víi kÕt qu¶ thùc cÒa tÝch ph©n(cha lµm ®îc). mÆc dï ®· cè g¾ng
nhng do tr×nh ®é vµ thêi gian cã h¹n nªn ®Ò tµi kh«ng tr¸nh khái thiÕu
sãt. rÊt mong sù gãp ý cÒa thÇy c« vµ b¹n bÌ.
5. tµi liÖu tham kh¶o:
[1]. ph¹m huy §iÓn, tÝnh to¸n, lËp tr×nh vµ gi¶ng d¹y to¸n häc trªn maple,
nxbkh&kt, 2002.
[2]. n.v. quÝ, n.t. dòng, n.v. hµ, gi¶i to¸n trªn m¸y vi tÝnh maple, nxbdn,
1998.
[3]. http://www.maplesoft.com
[4]. nguyÔn ch¸nh tó, sö dông maple trong häc tËp, sö dông vµ gi¶ng d¹y
to¸n, bµi gi¶ng sau ®¹i häc, 2006.

You might also like