5.10 matlab (int ,det,dsolve,simple,factor,symsum,taylor)

1.积分运算

MATLAB中计算一元函数的(不)定积分使用int函数.

①int(s)计算符号表达式s的不定积分

  syms x;s = x^2;int(s)

  计算x^2的不定积分.


②int(s,x)计算符号表达式关于x的不定积分

syms x a;s = x^2 + a;int(s,x)

计算x^2+a的不定积分.


③int(s,[a,b])计算符号表达式在区间[a,b]的不定积分

  syms x;s = exp(x);I =int(s,[0,1]);double(I)

  计算函数exp(x)在区间[0,1]上的定积分.

  最后用double将结果显示为数值结果,也可以用vpa(I,k)显示精度为k的结果.


④int(s,x,a,b)计算符号表达式关于x的定积分 //

  syms x a;s = exp(x)+a;I =int(s,0,1)

  计算函数exp(x)+a在区间[0,1]上的定积分.

  由于结果中含有a所以无需/不能用double显示结果.


2.计算行列式的值

det();    简化  有些版本 simple   simplify不一定哪个可以用  版本问题



1 求解微分方程 y''+3y'+2y=sinx;


>> dsolve('D2y+3*Dy+2*y=sin(x)','x')
 
ans =
 
-3/10*cos(x)+1/10*sin(x)-exp(-2*x)*C1+exp(-x)*C2


2 计算  x*x/(1-cosx) 当x趋于0的极限
 
>> f1=x*x/(1-cos(x))
 
f1 =
 
x^2/(1-cos(x))
 
 
>> limit(f1,x,0)
 
ans =
 
2


3 xsin(x)的积分上限  2^0.5   下限 2


>> f2=x*sin(x)
 
f2 =
 
x*sin(x)
 
>> int(f2)
 
ans =
 
sin(x)-x*cos(x)
 
 
>> int(f2,x)
 
ans =
 
sin(x)-x*cos(x)


>> int(f2,x,0,3)
 
ans =
 
sin(3)-3*cos(3)
 
 
>> int(f2,x,power(2,0.5),2)
 
ans =
 
sin(2)-2*cos(2)-sin(2^(1/2))+2^(1/2)*cos(2^(1/2))


4 计算行列式[1 1 1 1;a b c d;a*a b*b c*c d*d;a*a*a b*b*b c*c*c d*d*d],并简化
> syms a b c d
>> f3=[1 1 1 1;a b c d;a*a b*b c*c d*d;a*a*a b*b*b c*c*c d*d*d]
 
f3 =
 
[   1,   1,   1,   1]
[   a,   b,   c,   d]
[ a^2, b^2, c^2, d^2]
[ a^3, b^3, c^3, d^3]
 
 
>> f3_1=det(f3)
 
f3_1 =
 
b*c^2*d^3-b*d^2*c^3-b^2*c*d^3+b^2*d*c^3+b^3*c*d^2-b^3*d*c^2-a*c^2*d^3+a*d^2*c^3+a*b^2*d^3-a*b^2*c^3-a*b^3*d^2+a*b^3*c^2+a^2*c*d^3-a^2*d*c^3-a^2*b*d^3+a^2*b*c^3+a^2*b^3*d-a^2*b^3*c-a^3*c*d^2+a^3*d*c^2+a^3*b*d^2-a^3*b*c^2-a^3*b^2*d+a^3*b^2*c
 
 
>> find simplify


ans =


     1     2     3     4     5     6     7     8


>> f3_2=simplify(f3_1)
 
f3_2 =
 
b*c^2*d^3-b*d^2*c^3-b^2*c*d^3+b^2*d*c^3+b^3*c*d^2-b^3*d*c^2-a*c^2*d^3+a*d^2*c^3+a*b^2*d^3-a*b^2*c^3-a*b^3*d^2+a*b^3*c^2+a^2*c*d^3-a^2*d*c^3-a^2*b*d^3+a^2*b*c^3+a^2*b^3*d-a^2*b^3*c-a^3*c*d^2+a^3*d*c^2+a^3*b*d^2-a^3*b*c^2-a^3*b^2*d+a^3*b^2*c
 
 
>> f3_2=simple(f3_1)
 
f3_2 =
 
(-d+c)*(b-d)*(b-c)*(-d+a)*(a-c)*(a-b)




5 因式分解1001, 因式分解 x^8 - 1
 
>> factor(1001)


ans =


     7    11    13


>> factor(x^8-1)
 
ans =
 
(x-1)*(1+x)*(1+x^2)*(1+x^4)




6  对 x*x/(1-cosx) 求二次导数


>> f4=x*x/(1-cos(x))
 
f4 =
 
x^2/(1-cos(x))
 
 
>> diff(f4,x,2)
 
ans =
 
2/(1-cos(x))-4*x/(1-cos(x))^2*sin(x)+2*x^2/(1-cos(x))^3*sin(x)^2-x^2/(1-cos(x))^2*cos(x)


7 求级数和 1/1/1 + 1/2/2+ 。。。。。
>> syms t
>> ff=1/t^2
 
ff =
 
1/t^2
 
 
>> symsum(ff,t,1,inf)
 
ans =
 
1/6*pi^2


8 对e^x  在0点taylor展开。%忽略9阶及9阶以上小量的展开 


>> taylor(f7,9,x,0)
 
ans =
 
1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6+1/5040*x^7+1/40320*x^8


 


9 taylortool 查看 学习
10 funtool 查看 学习

猜你喜欢

转载自blog.csdn.net/mcuwangzai/article/details/80262158
int