2 2 2 x exp(-t) + (2 x + 1) exp(-t) + (x + 1) x
注意与直接输出的f1和f2对比。
?多项式展开(expand).展开(x?1)12成x不同幂次的多项式。
>> clear all >> syms x; >> f=(x-1)^12;
>> pretty(expand(f)) >> syms x; >> f=(x-1)^12;
>> pretty(expand(f))
12 11 10 9 8 7 6 1 + x - 12 x + 66 x - 220 x + 495 x - 792 x + 924 x - 792 x
4 3 2 + 495 x - 220 x + 66 x - 12 x
因式分解(factor)。将表达式x12?1作因式分解。
>> clear all
>> syms x;f=x^12-1; >> pretty(factor(f)) >> clear all
>> syms x;f=x^12-1; >> pretty(factor(f))
2 2 2 4 (x - 1) (1 + x + x) (1 + x) (1 - x + x ) (x + 1) (x - x + 1)
化简(simple或simplify).
将函数f?1x3?612x2?x?8化简。 >> clear all,syms x;f=(1/x^3+6/x^2+12/x+8)^(1/3); >> gi=simple(f)
>> clear all,syms x;f=(1/x^3+6/x^2+12/x+8)^(1/3); >> gi=simple(f)
gi =
13 / 18
5 2 (2*x+1)/x
>> g2=simplify(f)
g2 =
((2*x+1)^3/x^3)^(1/3)
6. 符号表达式的变量替换
subs函数可以对符号表达式中的符号变量进行替换 >> clear
>> f=sym('(x+y)^2+4*x+10') >> f1=subs(f,'x','s') >> f2=subs(f,'x+y','z')
>> clear
>> f=sym('(x+y)^2+4*x+10') f =
(x+y)^2+4*x+10
>> f1=subs(f,'x','s') f1 =
((s)+y)^2+4*(s)+10
>> f2=subs(f,'x+y','z') f2 =
((z))^2+4*x+10
练习:(1) 已知f?(ax?bx?c?3)?a(cx?4bx?1),按照自变量x和自变量a,对表 达式f分别进行降幂排列。
(2)已知符号表达式f?1?sinx,g?2x?1,计算x?0.5式,f的值;计算复合函 数f(g(x)). 7. 符号极限、符号积分与微分
1) 求极限函数的调用格式 >> limit(F,x,a) >> limit(F,a) >> limit(F)
>> limit(F,x,a,'right') >> limit(F,x,a,'left') 例一 >> clear
14 / 18
2222>> f=sym('sin(x)/x+a*x') >> limit(f,'x',0) >> limit(f,'a',0) >> limit(f) >> findsym(f)
>> f=sym('sin(x)/x+a*x') f =
sin(x)/x+a*x
>> limit(f,'x',0) ans = 1
>> limit(f,'a',0) ans = sin(x)/x
>> limit(f) ans = 1
>> fndsym(f)
??? Undefined function or method 'fndsym' for input arguments of type 'sym'.
>> findsym(f) ans = a, x 例二 >> clear
>> f=sym('sqrt(1+1/n)'); >> limit(f,n,inf)
2) 求积分函数的调用格式
>> int(F) >> int(F,v) >> int(F,a,b) >> int(F,v,a,b)
3) 求微分函数的调用格式 >> diff(F) >> diff(F,v) >> diff(F,n) >> diff(F,v,n)
15 / 18
8. 符号方程的求解
1) 常规方程求解函数的调用格式 >> g=solve(eq) >> g=solve(eq,var)
>> g=solve(eq1,eq2,...,var1,var2,...,varn)
求一元二次方程ax?bx?x?0的解。其求解方法有多种形式 2?>> Seq=solve('a*x^2+b*x+c') ?>> Seq=solve('a*x^2+b*x+c=0') ?>> eq='a*x^2+b*x+c'; 或
>> eq='a*x^2+b*x+c=0'; >> Seq=solve(eq) >> syms x a b c;
>> eq=a*x^2+b*x+c; >> Seq=solve(eq)
>> Seq=solve('a*x^2+b*x+c') Seq =
-1/2*(b-(b^2-4*a*c)^(1/2))/a -1/2*(b+(b^2-4*a*c)^(1/2))/a
>> Seq=solve('a*x^2+b*x+c=0') Seq =
-1/2*(b-(b^2-4*a*c)^(1/2))/a -1/2*(b+(b^2-4*a*c)^(1/2))/a >> eq='a*x^2+b*x+c'; >> eq='a*x^2+b*x+c=0'; >> Seq=solve(eq) Seq =
-1/2*(b-(b^2-4*a*c)^(1/2))/a -1/2*(b+(b^2-4*a*c)^(1/2))/a
>> syms x a b c;
>> eq=a*x^2+b*x+c; >> Seq=solve(eq)
16 / 18