Professional Documents
Culture Documents
V th cc hm s
> with(plots):
Warning, the name changecoords has been redefined
> with(plottools):
Warning, the assigned name arrow now has a global binding
> plot(x^3+4*x^2-1,x=-10..5,y=-10..15,thickness=2,numpoints=1000):
3. Cc thao tc vi s nguyn t
- Phn tch mt s n thnh tha s nguyn t: lnh ifactor(n);
- Kim tra mt s n c phi l s nguyn t khng?: lnh isprime(n);
- Tm s nguyn t ng sau mt s n cho trc: lnh nextprime(n);
- Tm s nguyn t ng trc mt s n cho trc: lnh prevprime(n);
- Tm c s chung ln nht ca 2 s nguyn dng a, b: lnh gcd(a,b);
- Tm bi s chung nh nht ca 2 s nguyn dng a, b: lnh lcm(a,b);
- Tm s d khi chia a cho b: lnh irem(a,b);
- Tm thng nguyn khi chia a cho b: lnh iquo(a,b);
> ifactor(3000000000):
> ifactor(1223334444555556666667777777):
> gcd(157940,78864):
> lcm(12,15):
> prevprime(100):
> nextprime(100):
> nextprime(%):
> irem(145,7):
> iquo(145,7):
> y:=irem(145,7,'x'):
> x:
BI 2. CC THAO CC I S C BN
1. Khai trin, n gin v phn tch biu thc i s
Khai trin biu thc i s
- C php: expand(bieu_thuc_dai_so);
> expand(bt);
> bt:=(x+y)^15;
bt := ( x C y ) 15
> expand(bt);
bt := x2 K 1
> subs(x=2,bt);
x K1
bt :=
xC2
> convert(bt,parfrac);
xK2C
3
xC2
2. nh ngha hm s
Cch 1: s dng ton t ->
C php: ten_ham := bien -> bieu_thuc_ham_so;
> f := x->x^2+1/2:
> f(a+b):
BI 3. V TH V CC VN LIN QUAN
1. Khi to cc hm v th
> with(plots):
Warning, the previous binding of the name arrow has been removed and it now has an assigned
value
> with(plottools):
V th ca hm s khng lin tc
Khi v th ca mt hoc nhiu hm s c im gin on, ta phi thm tuy chn discont =
true th c v chnh xc hn
> g:=x->(x^2-1)/(x-2):
> plot(g(x),x=-10..10,y=-5..15,discont=true,color=blue):
V th hm n
C nhng hm s m chng ta khng c c cng thc tng minh y=f(x), khi v c
th ca chng, ta s dng hm implicitplot
C php: implicitplot([bt_1, bt_2,...], x=gt_dau..gt_cuoi, y=gt_dau..gt_cuoi, cac_tuy_chon);
> implicitplot(x^2/9+y^2/4=1,x=-4..4,y=-2..2):
> implicitplot(x^2-y^2-x^4=0,x=-1..1,y=-1..1):
ng dng: v th ca hm hu t
> f:=x->(x^2-1)/(x-2):
> bt:=convert(f(x),parfrac):
> tcx:=x->x+2:
> g1:=plot([f(x),tcx(x)],x=-10..10,y=-5..15,color=[blue,red],discont=true):
> g2:=implicitplot(x=2,x=-10..10,y=-5..15,color=green):
> display({g1,g2}):
V th hm thng thng
C php: plot3d(ham_can_ve, x=gt_dau..gt_cuoi, y=gt_dau..gt_cuoi,z=gt_dau..gt_cuoi,
cac_tuy_chon);
> plot3d(x*exp(x^2),x=-2..2,y=-2..2,title="Do thi trong khong gian 3 chieu"):
> plot3d(-exp(-abs(x*y)/10)*sin(x+y)-cos(x*y),x=-Pi..Pi,y=-Pi..Pi,grid=[51,51]):
V th hm n
C php: implicitplot3d(ham_can_ve, x=gt_dau..gt_cuoi,
y=gt_dau..gt_cuoi,z=gt_dau..gt_cuoi, cac_tuy_chon);
> implicitplot3d(x^2+y^2/4+z^2/9=1,x=-3..3,y=-3..3,z=-3..3):
4. S vn ng ca th
C php: animate(ham_co_tham_so,x=gt_dau..gt_cuoi, tham_so = gt_dau..gt_cuoi);
animate3d(ham_co_tham_so,x=gt_dau..gt_cuoi, y=gt_dau..gt_cuoi, tham_so =
gt_dau..gt_cuoi);
ngha: hin th s bin i, vn ng ca th khi tham s thay i trong khong cho trc
> animate3d(cos(t*x)*sin(t*y),x=-Pi..Pi,y=-Pi..Pi,t=1..5):
> animate(t*x^2,x=-3..3,t=-5..5):
2. Tnh o hm
Tnh o hm cp 1
C php: diff(ham_so, bien);
Diff(ham_so, bien);
ngha: tnh o hm cp 1 ca ham_so theo bien. Kt qu c th hin di dng cng thc
(lnh Diff) hoc kt qu c th (lnh diff)
> f := x->x^2*sqrt(x^2+1):
> Diff(f(x),x):
> value(%):
> diff(f(x),x):
> simplify(%):
Tnh o hm cp cao
C php: diff(ham_so, bien, bien, bien, ...);
Diff(ham_so, bien, bien, bien, ...);
hoc
diff(ham_so, bien$k);
Diff(ham_so, bien$k);
ngha: tnh o hm cp k ca ham_so theo bien. Kt qu c th hin di dng cng thc
(lnh Diff) hoc kt qu c th (lnh diff)
> g := x->5*x^3-3*x^2-2*x^(-3):
> diff(g(x),x,x):
> h := x -> x^4 + x*sin(x):
> diff(h(x),x$2):
> simplify(%):
10
4. Mt s ng dng
Bi ton tnh din tch hnh thang cong
Bi 1. Tnh din tch hnh thang cong gii hn bi hm s f(x)=3*x-x^3 , trc Ox v hai
ng thng x=0, x=1.
> restart:
> with(plots):
Warning, the name changecoords has been redefined
> with(plottools):
Warning, the assigned name arrow now has a global binding
> f := x->3*x-x^2:
> g1:=plot(f(x),x=0..3,y=0..3,filled = true):
> g2:=implicitplot(x=3,x=0..4,y=0..3,color=blue):
> display({g1,g2}):
> int(f(x),x=0..3):
Bi 2. Tnh din tch hnh thang cong gii hn bi hai hm s f(x) = x^2 v g(x) =
1
2
> f := x->x^2:
> g := x->sqrt(x):
> a:=solve(f(x)=g(x),x):
> plot([f(x),g(x)],x=a[1]..a[2]):
> abs(int(abs(f(x)-g(x)),x=a[1]..a[2])):
11
Bi ton kho st hm s
Kho st v v th hm s
f(x) =
0 Kx2 C 3$xK3 1
2$ ( xK1 )
> f:=x->(-x^2+3*x-3)/(2*(x-1)):
> f1 := x->diff(f(x),x):
> f1(x):
> simplify(f1(x)):
> a:=solve(f1(x)=0,x):
> ct1:=a[1]:
> ct2:=a[2]:
> f(ct1):
> f(ct2):
> f2:=x->diff(f(x),x$2):
> f2(x):
> simplify(f2(x)):
> f(x):
> convert(f(x),parfrac,x):
> g1:=plot([-0.5*x+1,f(x)],x=-3..5,y=-2..4,color=[blue,red],discont=true):
> g2:=implicitplot(x=1,x=-3..5,y=-2..4,color=green):
> display({g1,g2}):
12
Cc hm trn i tng im
- nh ngha im: point(ten_diem, hoanh_do, tung_do);
- Hin th ta ca mt im: coordinates(ten_diem);
- Xc nh trung im on thng to bi hai im: midpoint(ten_trung_diem, diem_1,
diem_2);
> point(A,2,3):
> point(B,-3,1):
> coordinates(A):
> coordinates(B):
> midpoint(M,A,B):
> coordinates(M):
14
Cc hm trn i tng im
- nh ngha im: point(ten_diem, hoanh_do, tung_do,cao_do);
- Hin th ta ca mt im: coordinates(ten_diem);
- Xc nh trung im on thng to bi hai im: midpoint(ten_trung_diem, diem_1,
diem_2);
> point(A,2,3,1):
> point(B,-3,1,3):
> coordinates(A):
> coordinates(B):
> midpoint(M,A,B):
> coordinates(M):