Professional Documents
Culture Documents
Gi i thi u
y Tnh ton hnh th c. y Symbolic Math Toolbox.
Khai bo
y Khai bo bi n: y syms a b c x ho c y a = sym(a) y b = sym(b) y c = sym(c) y x = sym(x) y Khai bo bi n ph c y x = sym(x,real); y = sym(y,real) ho c syms x y real y z = x + i*y
ho c
y f = sym(2*x + b) y sym((sqrt(2) + 1)/3) y g = syms(5) (khc g = 5) y syms x y y h = x^2 + y^2
nh
Hi n th bi n hnh th c d
i d ng s h c
y t = 0.1 y sym(t, f ) y ans = '1.999999999999a'*2^(-4) y sym(t, r ) y ans = 1/10 y sym(t, e ) y ans = 1/10+eps/40 y sym(t, d ) y ans = .10000000000000000555111512312578 y digits(7) y sym(t, d ) y ans = .1000000
o hm
y diff(Y)
Y: hm s ho c bi n hnh th c c n l y
y V d y syms x; f = sin(5*x) y diff(f) y ans = 5*cos(5*x) y g = exp(x)*cos(x) y diff(g) y ans = exp(x)*cos(x) exp(x)*sin(x) y c = sym(5); diff(c) y ans = 0
o hm.
yL y
o hm c p 2
y diff(g,2)
y
o hm a bi n G i f = f(x,y) th
o hm theo x: diff(f,x) o hm theo y: diff(f,y)
ng
ng v i
o V d syms s t f = sin(s*t) diff(f,t) => ans = cos(s*t)*s diff(f,s) => ans = cos(s*t)*t diff(f,t,2) => ans = -sin(s*t)*s^2 findsym(f,1)=> ans = t Suy ra bi n m c nh l t do diff(f,2) = diff(f,t,2)
o hm
syms a x
i v i ma tr n
Tch phn
y int(f,x) ho c int(f) : Tm nguyn hm c a hm f = f(x). y int(f,a,b) : Tnh tch phn c a f t a -> b. y V d
y syms x n a b t yf=x^n y int(f) ( ho c inf(f,x)) y ans = x^(n+1)/(n+1)
y g = cos(a*t + b) y int(g) y ans = sin(a*t + b)/a y h = sin(2*x) y int(h,0,pi/2) y ans = 1 y u = exp(-x^2) y int(u,0,inf) y ans = 1/2*pi^(1/2)
sinx
(x 2 + y 2 )dydx
0 0
y int(int(f,y,0,sin(x)),0,pi); y ans =
pi^2 32/9
Gi i h n
y limit(f) : y limit(f,x,a) :
lim f ( x)
x p0
lim ( x) xpa
ho c limit(f,a)
y limit(f,x,a,left) : y limit(f,x,a,right) :
lim f ( x )
x a
lim f ( x)
x a
y V d y sym h n x y limit((cos(x + h) cos(x))/h,h,0) y ans = - sin(x) y limit((1 + x/n)^n,n,inf) y ans = exp(x) y limit(x/abs(x),x,0,left) y ans = -1 y limit(x/abs(x),x,0,right) y ans = 1 y limit(x/abs(x),x,0) y ans = NaN
Chu i s
y Tnh:
1 1 s1 ! 2 !1 2 2 n !1 n
g
1 2 3
2
...
s2 !
k !0
!1
...
y Khai tri n Taylor: y syms x; taylor(sin(x),x,10); ans = x-1/6*x^3+1/120*x^5-1/5040*x^7+1/362880*x^9 y taylor(exp(x),4,2) ans = exp(2)+exp(2)*(x-2)+1/2*exp(2)*(x-2)^2+1/6*exp(2)*(x-2)^3 y taylor(exp(1/x^2),6,inf) ans = 1+1/x^2+1/2/x^4
n gi n hm f b ng cc nhm cc bi n x c cng s m . Tr ng h p f c nhi u bi n collect(f,y) s ch nh gom nhm theo bi n y. collect(f) gom nhm theo bi n m c nh c ch ra trong findsym(f).
y V d y syms x t
y f = x^3 6*x^2 + 11*x 6 y g = (x 1)*(x 2)*(x 3) y h = -6 + (11 + (-6 + x)*x)*x y pretty(f), pretty(g), pretty(h) y collect(f) => ans = x^3 6*x^2 + 11*x 6 y collect(g) => ans = x^3 6*x^2 + 11*x 6 y collect(h) => ans = x^3 6*x^2 + 11*x 6 y f = (1 + x)*t + x*t y collect(f) => ans = 2*x*t + t y collect(f,t) => ans = 2*x*t + t
y simplify(f): y V d
n gi n bi u th c f.
y f = x*(x*(x 6) + 11) - 6 y simplify(f) => ans = x^3 6*x^2 + 11*x 6 y g = (1 x^2)/(1 x) y simplify(g) => ans = x + 1 y syms x y positive y simplify(log(x*y)) => log(x) + log(y) y h = cos(x)^2 + sin(x)^2 y simplify(h) => ans = 1
y poly2sym(a,x): t o m t a th c theo bi n x v i cc h s c l y l n l t t m ng a. y V d
y syms x; a = [1 4 -7 -10] y p = poly2sym(a,x) y p = x^3 + 4*x^2 7*x - 10
y x = sym2poly(p): trch cc h s c a a th c p ch a vo m ng s. y V d
y syms x; p = 4*s^2 2*s^2 + 5*s 16 y x = sym2poly(p) y x = 4 -2 5 -16
i s tuy n
y Cc php ton: v i 2 ma tr n A v B
y Cc hm x l ma tr n: inv(A)
y V d
y c = floor(10*rand(4)) y D = sym(c) y A = inv(D) y inv(A)*A y det(A) y b = ones(1,4) y x = b/A y x*A y A^3
y C th dng cc hm rt g n v l y trn ma tr n. y V d y syms a b s y K = [a+b, a-b;b-a, a+b] y G = [cos(s) sin(s);-sin(s) cos(s)] y L = K^2 y collect(L)
y factor(L) y diff(L,a) y int(K,a) y J = K/G y simplify(J*G) y simplify(G*(G.))
IV. Gi i ph
y solve(f) : gi i ph y V d
ng trnh
ng trinh f(x) = 0.
is
y solve(f) : gi i ph
ng trnh theo bi n m c c ch
nh
c ng
y solve(f-g): gi i ph
= g(x)).
ng trnh.
y V d
Gi i h :
2 2 y =0 x x-y / 2=
y= [ -2*alpha] [ -2*alpha] [ 0] [ 0]
u 2 + v 2 = a2 y Gi i h : + v = 1 u 2 - 2a = 3 a y S = solve(u^2+v^2=a^2,u+v=1,a^22*a=3)
yS=
Gi i ph
y V d y Gi i:
ng trnh vi phn
dy ! 1 y 2 , y (0) ! 1 dt
y Hm: dsolve
y Gi i:
y Gi i:
y dsolve(D3u=u,u(0)=1,Du(0)=-1,D2u(0)=pi),x)
df ! 3 f (t ) 4 g (t ) , f (0) ! 0 dt y Gi i: dg ! 4 f (t ) 3 g (t ) , g (0) ! 1 dt
y [f g] = dsolve(Df = 3*f + 4*g,Dg = -4*f + 3*g,
f(0) = 0,g(0) = 1)
y f = exp(3*t)*sin(4*t); g = exp(3*t)*cost(4*t)
V. V
y Trong 2 D: Hm ezplot(f). V d
y syms t x y y f = sin(2*x)
th
y Trong 3 D y Hm ezplot3(x,y,z) y V d
y syms x y z t y x = 3*t/(1 + t^3) y y = 3*t^2/(1 + t^3) y z = sin(t) y ezplot3(x,y,z)