#############################
01 展开:展开因式:expand(f)
--- 幂函数:则根据次数从高到低 --- 三角函数:展开角部分 --- 指数:展开指数部分
>> z=(x+y+3)*(2*x-4*y+7)+sin(x+y)+exp(x+y)+log(x*y) z = exp(x + y) + log(x*y) + sin(x + y) + (2*x - 4*y + 7)*(x + y + 3) >> expand(z) ans = 13*x - 5*y + log(x*y) + exp(x)*exp(y) + cos(x)*sin(y) + cos(y)*sin(x) - 2*x*y + 2*x^2 - 4*y^2 + 21 >>
>> z=(x+y+3)*(2*x-4*y+7) z = (2*x - 4*y + 7)*(x + y + 3) >> expand(z) ans = 2*x^2 - 2*x*y + 13*x - 4*y^2 - 5*y + 21 >>
02 合并:因式分解:factor(f)
>> z1=3*x^3+2*x^2+x+2 z1 = 3*x^3 + 2*x^2 + x + 2 >> factor(z1) ans = [ x + 1, 3*x^2 - x + 2] >>
>> z1=x^2+2*x*y+y^2 z1 = x^2 + 2*x*y + y^2 >> factor(z1) ans = [ x + y, x + y] >>
03 合并同类项:collect(f)
>> z2=x^2+x*y*7-x^2+y+x-8 z2 = x + y + 7*x*y - 8 >> collect(z2) ans = (7*y + 1)*x + y - 8 >> collect(z2,y) ans = (7*x + 1)*y + x - 8 >> collect(z2,x) ans = (7*y + 1)*x + y - 8 >>
04 化简:simplify(f)
>> z3=x^2+y^2-2*x*y+sin(x)^2+cos(x)^2 z3 = cos(x)^2 + sin(x)^2 - 2*x*y + x^2 + y^2 >> simplify(z3) ans = x^2 - 2*x*y + y^2 + 1 >>
05 解方程:solve(f,x)
>> z=x^3+x-6 z = x^3 + x - 6 >> solve(z,x) ans = root(z^3 + z - 6, z, 1) root(z^3 + z - 6, z, 2) root(z^3 + z - 6, z, 3) >> z=x^2+x-2 z = x^2 + x - 2 >> solve(z,x) ans = -2 1 >>
06 级数求和:symsum(f,n,a,b)
--- 级数求和:symsum(f,n,a,b):f为一个级数的通项,是一个符号表达式,求自变量n为从a到b的通项和;
其中inf可表示无穷大
>> f=n f = n >> symsum(f,n,1,n) ans = (n*(n + 1))/2 >> symsum(f,n,1,10) ans = 55 >> f=1/n^2 f = 1/n^2 >> symsum(f,n,1,inf) ans = pi^2/6 >>
07 求极限:limit(f,x,a)
--- 某点极限: limit(f,x,a) --- 某点左极限:limit(f,x,a,'left') --- 某点右极限:limit(f,x,a,'right') --- 无穷极限: limit(f,x,inf) --- 正无穷极限:limit(f,x,inf,'right') --- 负无穷极限:limit(f,x,inf,'left')
>> f=sin(x)/x f = sin(x)/x >> limit(f,x,0) ans = 1 >> limit(f,x,0,'right') ans = 1 >> limit(f,x,0,'left') ans = 1 >> limit(f,x,inf) ans = 0 >> limit(f,x,inf,'right') ans = 0 >> limit(f,x,inf,'left') ans = 0 >>
>> help limit --- sym/limit 的帮助 --- limit Limit of an expression. limit(F,x,a) takes the limit of the symbolic expression F as x -> a. limit(F,a) uses symvar(F) as the independent variable. limit(F) uses a = 0 as the limit point. limit(F,x,a,'right') or limit(F,x,a,'left') specify the direction of a one-sided limit. Examples: syms x a t h; limit(sin(x)/x) returns 1 limit((x-2)/(x^2-4),2) returns 1/4 limit((1+2*t/x)^(3*x),x,inf) returns exp(6*t) limit(1/x,x,0,'right') returns inf limit(1/x,x,0,'left') returns -inf limit((sin(x+h)-sin(x))/h,h,0) returns cos(x) v = [(1 + a/x)^x, exp(-x)]; limit(v,x,inf,'left') returns [exp(a), 0]
08:求导数:diff(f,x,n)
--- diff(f,x,n) 表示函数f对自变量x求n阶导数
>> f=x^2+exp(x)+log(x)+sin(x)+cos(x) f = cos(x) + exp(x) + log(x) + sin(x) + x^2 >> diff(f,x,2) ans = exp(x) - cos(x) - sin(x) - 1/x^2 + 2 >>
09 泰勒展开:taylor(f,x,a,'Order',n)
--- taylor(f,x,a,'Order',n) 表示函数f在自变量x=a处的泰勒展开式,n为展开的阶数
>> f=exp(x) f = exp(x) >> taylor(f,x,0,'Order',3) ans = x^2/2 + x + 1 >> taylor(f,x,1,'Order',3) ans = exp(1) + exp(1)*(x - 1) + (exp(1)*(x - 1)^2)/2 >>
10 求积分:int(f,x,a,b)
--- int(f,x) 表示函数f对自变量x的不定积分 --- int(f,x,a,b) 表示函数f对自变量x从a到b的定积分,a和b可以为正负inf
>> f=sin(x) f = sin(x) >> int(f,x,0,pi) ans = 2 >> int(f,x) ans = -cos(x) >>
美化符号表达式:pretty(f)
>> f=sin(pi/3) f = 0.8660 >> pretty(f) 未定义与 'double' 类型的输入参数相对应的函数 'pretty'。 >> f=sin(sym(pi/3)) f = 3^(1/2)/2 >> pretty(f) sqrt(3) ------- 2 >>
##########################