赞
踩
limit函数:
limit(f,x,a,‘left’)
limit(f,x,a,‘right’)
limit(f,x,a)
limit(f)
含有符号对象的函数表达式f,a为极限点,’left’,'right’表示左,右极限,如果是双侧极限的话省略该参数,只有一个参数时指函数趋于0的极限,不建议省略太多参数,尽量写最完整的参数形式,不同版本省略参数容易出错。
例子:
(
1
)
l
i
m
x
→
+
∞
(
1
+
a
/
x
)
x
(1) lim_{x\to +\infty}(1+a/x)^x
(1)limx→+∞(1+a/x)x
(
2
)
l
i
m
x
→
a
t
a
n
x
−
t
a
n
a
x
−
a
,
(
0
<
a
<
π
/
2
)
(2) lim_{x\to a} \frac{tanx-tana}{x-a},(0<a<\pi/2)
(2)limx→ax−atanx−tana,(0<a<π/2)
(
3
)
l
i
m
x
→
2
(
3
x
+
2
)
1
/
3
−
2
x
−
2
(3) lim_{x\to 2}\frac{(3x+2)^{1/3}-2}{x-2}
(3)limx→2x−2(3x+2)1/3−2
(
4
)
l
i
m
n
→
∞
(
1
−
(
2
n
−
1
2
n
)
)
(4) lim_{n\to \infty}(1-\sqrt(\frac{2n-1}{2n}))
(4)limn→∞(1−(
2n2n−1))
clear clc syms x a f=(1+a/x)^x; T1=limit(f,x,inf,'left') clear syms x a f=(tan(x)-tan(a))/(x-a); T2=limit(f,x,a) clear syms x f=((3*x+2)^(1/3)-2)/(x-2); T3=limit(f,x,2) clear syms n f=n*(1-sqrt((2*n-1)/2/n)); T4=limit(f,n,inf) %结果 T1 = exp(a) T2 = tan(a)^2 + 1 T3 = 1/4 T4 = 1/4
diff函数
diff(f,x,n) 表示求函数f关于变量x的n阶导数,n=1时可省略,f和x都使用符号对象
例子
(
1
)
(1)
(1)求函数
y
=
l
n
(
x
+
2
1
−
x
)
y=ln(\frac{x+2}{1-x})
y=ln(1−xx+2)的一阶和三阶导数
(
2
)
y
=
l
n
(
1
x
2
+
e
1
/
x
)
+
a
r
c
t
a
n
(
1
−
x
2
)
,
求
d
y
/
d
x
(2) y=ln(\frac{1}{x^2}+e^{1/x})+arctan(1-x^2),求dy/dx
(2)y=ln(x21+e1/x)+arctan(1−x2),求dy/dx
(
3
)
y
=
a
r
c
t
a
n
(
x
3
+
2
)
+
l
n
(
(
x
−
1
x
+
1
)
)
,
求
d
y
/
d
x
(3)y=arctan(x^3+2)+ln(\sqrt(\frac{x-1}{x+1})),求dy/dx
(3)y=arctan(x3+2)+ln((
x+1x−1)),求dy/dx
(
4
)
y
=
x
2
e
−
x
+
(
s
i
n
x
)
2
x
,
求
d
2
y
/
d
x
2
(4)y=x^2e^{-x}+(sinx)^{2x},求d^2y/dx^2
(4)y=x2e−x+(sinx)2x,求d2y/dx2
clear clc %T1 syms x f=log((x+2)/(1-x)); T1_dy=diff(f,x) T1_d3y=diff(f,x,3) %T2 f=log(1/x/x+exp(1/x))+atan(1-x^2); T2_dy=diff(f,x) %T3 f=atan(x^3+2)+log(sqrt((x-1)/(x+1))); T3_dy=diff(f,x) %T4 f=x^2*exp(-x)+sin(x)^(2*x); T4_d2y=diff(f,x,2) %结果 T1_dy = ((1/(x - 1) - (x + 2)/(x - 1)^2)*(x - 1))/(x + 2) T1_d3y = (2*(1/(x - 1) - (x + 2)/(x - 1)^2)*(x - 1))/(x + 2)^3 - (2*(2/(x - 1)^2 - (2*(x + 2))/(x - 1)^3))/(x + 2) - (2*(1/(x - 1) - (x + 2)/(x - 1)^2))/(x + 2)^2 + (2*(2/(x - 1)^2 - (2*(x + 2))/(x - 1)^3)*(x - 1))/(x + 2)^2 + ((6/(x - 1)^3 - (6*(x + 2))/(x - 1)^4)*(x - 1))/(x + 2) T2_dy = - (2*x)/((x^2 - 1)^2 + 1) - (exp(1/x)/x^2 + 2/x^3)/(exp(1/x) + 1/x^2) T3_dy = (3*x^2)/((x^3 + 2)^2 + 1) + ((1/(x + 1) - (x - 1)/(x + 1)^2)*(x + 1))/(2*(x - 1)) T4_d2y = 2*exp(-x) - 4*x*exp(-x) + 2*log(sin(x))*(2*log(sin(x))*sin(x)^(2*x) + 2*x*cos(x)*sin(x)^(2*x - 1)) + x^2*exp(-x) + 2*cos(x)*sin(x)^(2*x - 1) + 2*x*cos(x)*(2*log(sin(x))*sin(x)^(2*x - 1) + cos(x)*sin(x)^(2*x - 2)*(2*x - 1)) - 2*x*sin(x)*sin(x)^(2*x - 1) + (2*cos(x)*sin(x)^(2*x))/sin(x) >>
还可以利用diff求偏导数,参数方程导数,隐函数方程导数。
z
=
f
(
x
,
y
)
,
∂
z
/
∂
x
=
d
i
f
f
(
f
,
x
)
z=f(x,y),\partial z/\partial x=diff(f,x)
z=f(x,y),∂z/∂x=diff(f,x)
y
=
y
(
t
)
,
x
=
x
(
t
)
,
d
y
/
d
x
=
(
d
y
/
d
t
)
/
(
d
x
/
d
t
)
=
d
i
f
f
(
y
,
t
)
/
d
i
f
f
(
x
,
t
)
y=y(t),x=x(t),dy/dx=(dy/dt)/(dx/dt)=diff(y,t)/diff(x,t)
y=y(t),x=x(t),dy/dx=(dy/dt)/(dx/dt)=diff(y,t)/diff(x,t)
F
(
x
,
y
)
=
0
,
d
y
/
d
x
=
−
F
x
/
F
y
=
−
d
i
f
f
(
F
,
x
)
/
d
i
f
f
(
F
,
y
)
F(x,y)=0,dy/dx=-F_x/F_y=-diff(F,x)/diff(F,y)
F(x,y)=0,dy/dx=−Fx/Fy=−diff(F,x)/diff(F,y)
int函数(不定积分与定积分)和quad函数(定积分的数值计算),int函数是先求出函数的原函数,如果求定积分,再在原函数的基础上按照牛顿——莱布尼茨公式求得定积分的值
int(f) ——计算函数f关于默认变量的不定积分
int(f,x) ——计算函数f关于变量x的不定积分
int(f,x,a,b) ——计算函数f关于变量x从a到b的定积分
函数f不用句柄变量,最好使用符号对象,quad(f,a,b) ——数值积分 一般用函数文件,f为@函数名
例子
(1)
∫
(
x
5
+
x
3
−
x
/
4
)
d
x
\int(x^5+x^3-\sqrt x/4)dx
∫(x5+x3−x
/4)dx
(2)
∫
0
1
x
e
x
/
(
1
+
x
)
2
d
x
\int_0^1xe^x/(1+x)^2dx
∫01xex/(1+x)2dx
(3)
∫
−
2
−
1
1
x
(
x
2
−
1
)
d
x
\int_{-2}^{-1}\frac{1}{x\sqrt(x^2-1)}dx
∫−2−1x(
x2−1)1dx
(4)
∫
−
∞
+
∞
1
(
x
2
+
1
)
(
x
2
+
4
)
d
x
\int_{-\infty}^{+\infty}\frac{1}{(x^2+1)(x^2+4)}dx
∫−∞+∞(x2+1)(x2+4)1dx
(5)
∫
0
π
x
s
i
n
(
x
)
1
+
c
o
s
(
x
)
2
d
x
\int_0^{\pi}\frac{xsin(x)}{1+cos(x)^2}dx
∫0π1+cos(x)2xsin(x)dx
(6)
∫
−
1
1
g
(
x
)
d
x
\int_{-1}^1g(x)dx
∫−11g(x)dx,
g
(
x
)
=
1
+
x
2
c
o
s
(
x
)
,
x
<
=
0
,
g
(
x
)
=
e
−
x
s
i
n
(
x
)
,
x
>
0
g(x)=1+x^2cos(x),x<=0, g(x)=e^{-x}sin(x),x>0
g(x)=1+x2cos(x),x<=0,g(x)=e−xsin(x),x>0
% 不定积分与定积分 clear clc %T1 syms x f=x^5-x^3-sqrt(x)/4; int(f,x) %T2 clear syms x f=x*exp(x)/(1+x)^2; int(f,x,0,1) %T3 clear syms x f=1/x/sqrt(x^2-1); int(f,x,-2,-1) %T4 clear syms x f=1/(x^2+1)/(x^2+4); int(f,x,-inf,inf) %T5 clear syms x f=x*sin(x)/(1+cos(x)^2); int(f,x,0,pi) %int((x*sin(x))/(cos(x)^2 + 1), x, 0, pi) ——说明求不出了 quad(@fun,0,pi) %注意函数运算符使用点运算,quad是数值积分,矩阵间运算存在维数问题 clear %T6 quad(@g,-1,0)+quad(@g,0,1) %分段函数的积分 clear syms x f1=1+x^2; f2=exp(-x); int(f1,x,-1,0)+int(f2,x,0,1) %结果 ans = x^6/6 - x^(3/2)/6 - x^4/4 ans = exp(1)/2 - 1 ans = -pi/3 ans = pi/6 ans = int((x*sin(x))/(cos(x)^2 + 1), x, 0, pi) ans = 2.4674 ans = 1.4850 ans = 0.8586 ans = 7/3 - exp(-1)
通过Fubini定理和特征函数将二重积分化成二次积分来计算,嵌套使用int函数即可
三重积分也是这样。此外,还可以通过坐标变换(eg极坐标下的二重积分)简化积分。这些是高等数学(数学分析/微积分)的内容了。
例子
第一型曲线积分,先对曲线进行参数化,将曲线积分转化为定积分,再用int函数计算
对曲线进行参数化
平面曲线:
r
:
t
→
r
(
t
)
=
(
x
(
t
)
,
y
(
t
)
)
,
t
∈
[
a
,
b
]
r:t\to r(t)=(x(t),y(t)),t∈[a,b]
r:t→r(t)=(x(t),y(t)),t∈[a,b],
∫
L
f
d
s
=
∫
a
b
f
(
x
(
t
)
,
y
(
t
)
)
(
x
′
(
t
)
2
+
y
′
(
t
)
2
)
d
t
\int_Lfds=\int_a^bf(x(t),y(t))\sqrt(x'(t)^2+y'(t)^2)dt
∫Lfds=∫abf(x(t),y(t))(
x′(t)2+y′(t)2)dt
空间曲线:
r
:
t
→
r
(
t
)
=
(
x
(
t
)
,
y
(
t
)
,
z
(
t
)
)
,
t
∈
[
a
,
b
]
r:t\to r(t)=(x(t),y(t),z(t)),t∈[a,b]
r:t→r(t)=(x(t),y(t),z(t)),t∈[a,b],
∫
L
f
d
s
=
∫
a
b
f
(
x
,
y
,
z
)
(
x
′
(
t
)
2
+
y
′
(
t
)
2
+
z
′
(
t
)
2
)
d
t
\int_Lfds=\int_a^bf(x,y,z)\sqrt(x'(t)^2+y'(t)^2+z'(t)^2)dt
∫Lfds=∫abf(x,y,z)(
x′(t)2+y′(t)2+z′(t)2)dt
特殊地,
y
=
g
(
x
)
y=g(x)
y=g(x)
∫
L
f
d
s
=
∫
a
b
f
(
x
,
g
(
x
)
)
(
1
+
g
′
(
x
)
2
)
d
x
\int_Lfds=\int_a^bf(x,g(x))\sqrt(1+g'(x)^2)dx
∫Lfds=∫abf(x,g(x))(
1+g′(x)2)dx
第一型曲面积分,先对曲面进行参数化,将曲面积分转化为二重积分,再转化为二次积分,用int函数计算
参数化
对曲面进行参数化
r
:
(
u
,
v
)
→
ϕ
(
u
,
v
)
=
(
x
(
u
,
v
)
,
y
(
u
,
v
)
,
z
(
u
,
v
)
)
,
(
u
,
v
)
∈
D
r:(u,v)\to \phi(u,v)=(x(u,v),y(u,v),z(u,v)),(u,v)∈D
r:(u,v)→ϕ(u,v)=(x(u,v),y(u,v),z(u,v)),(u,v)∈D,
∬
Σ
f
d
s
=
∬
D
f
(
ϕ
(
u
,
v
)
)
(
E
F
−
G
2
)
d
u
d
v
,
E
=
<
ϕ
u
,
ϕ
u
>
,
F
=
<
ϕ
v
,
ϕ
v
>
,
G
=
<
ϕ
u
,
ϕ
v
>
\iint_\Sigma fds=\iint_Df(\phi(u,v))\sqrt(EF-G^2)dudv,E=<\phi_u,\phi_u>,F=<\phi_v,\phi_v>,G=<\phi_u,\phi_v>
∬Σfds=∬Df(ϕ(u,v))(
EF−G2)dudv,E=<ϕu,ϕu>,F=<ϕv,ϕv>,G=<ϕu,ϕv>
特殊地,
z
=
g
(
x
,
y
)
z=g(x,y)
z=g(x,y)
∬
Σ
f
d
s
=
∬
D
f
(
x
,
y
,
z
)
(
1
+
g
x
2
+
g
y
2
)
d
x
d
y
\iint_\Sigma fds=\iint_Df(x,y,z)\sqrt(1+g_x^2+g_y^2)dxdy
∬Σfds=∬Df(x,y,z)(
1+gx2+gy2)dxdy
1.级数的收敛性及级数求和
s y m s u m ( u n , n , a , b ) symsum(u_n,n,a,b) symsum(un,n,a,b) 其中 u n u_n un为级数通项, n n n为求和变量,计算数项级数 ∑ a b u n \sum_a^bu_n ∑abun,若级数收敛,则返回和,发散求得的和为inf或NaN,因此利用该函数可以同时解决求和问题和收敛问题
例子
(
1
)
s
1
=
∑
n
=
1
∞
2
n
−
1
2
n
,
s
2
=
∑
n
=
1
∞
1
n
(
2
n
+
1
)
(1)s1=\sum_{n=1}^{\infty}\frac{2n-1}{2^n},s2=\sum_{n=1}^{\infty}\frac{1}{n(2n+1)}
(1)s1=∑n=1∞2n2n−1,s2=∑n=1∞n(2n+1)1
(
2
)
s
1
=
∑
n
=
1
∞
s
i
n
x
n
2
,
s
2
=
∑
n
=
1
∞
(
−
1
)
n
−
1
x
n
n
(2)s1=\sum_{n=1}^{\infty}\frac{sinx}{n^2},s2=\sum_{n=1}^{\infty}(-1)^{n-1}\frac{x^n}{n}
(2)s1=∑n=1∞n2sinx,s2=∑n=1∞(−1)n−1nxn
clear clc %常数项级数 syms n u1=(2*n-1)/2^n; u2=1/n/(2*n+1); s1=symsum(u1,n,1,inf) s2=symsum(u2,n,1,inf) %函数项级数 clear syms n x f1=sin(x)/n/n; f2=(-1)^(n-1)*x^n/n; s1=symsum(f1,n,1,inf) s2=symsum(f2,n,1,inf) %结果 s1 = 3 s2 = 2 - 2*log(2) s1 = (pi^2*sin(x))/6 s2 = piecewise(x == -1, -Inf, abs(x) <= 1 & x ~= -1, log(x + 1)) >>
2.函数的泰勒展开
taylor(f,x,a,‘order’,n)——函数f在a处展开,x是自变量,即展开为(x-a)的幂级数,展开项数为n,即n-1次
taylor(f,x,a)——默认展开6项,即5次幂
taylor(f,x)——默认在0处展开,即麦克劳林展开
taylor(f)
例子
(1)将
s
i
n
(
x
)
sin(x)
sin(x)展开5次和19次
(2)将
1
/
(
x
2
+
5
x
−
3
)
1/(x^2+5x-3)
1/(x2+5x−3)展开为
(
x
−
2
)
(x-2)
(x−2)的幂级数
%T1 clear clc syms x f=sin(x); T11=taylor(f,x) T12=taylor(f,x,'order',20) %T2 clear syms x f=1/(x^2+5*x-3); taylor(f,x,2) %结果 T11 = x^5/120 - x^3/6 + x T12 = - x^19/121645100408832000 + x^17/355687428096000 - x^15/1307674368000 + x^13/6227020800 - x^11/39916800 + x^9/362880 - x^7/5040 + x^5/120 - x^3/6 + x ans = (70*(x - 2)^2)/1331 - (9*x)/121 - (531*(x - 2)^3)/14641 + (4009*(x - 2)^4)/161051 - (30240*(x - 2)^5)/1771561 + 29/121 >>
dsolve函数
dsolve(‘方程1’,‘方程2’,…,‘方程n’,‘初始条件1’,…,‘初始条件m,'自变量’),
记号:在表达微分方程时,用字母D表示求导,D2,D3等表示求取高阶导,后面的字母为因变量,自变量可以指定,也可以缺省由系统选定
例如微分方程 d 2 y / d x 2 = 0 d^2y/dx^2=0 d2y/dx2=0,表示为 D 2 y = 0 D2y=0 D2y=0
例子
(
1
)
d
y
/
d
x
=
1
/
(
x
+
y
)
(1)dy/dx=1/(x+y)
(1)dy/dx=1/(x+y)
(
2
)
y
y
′
′
−
y
′
2
=
0
(2)yy''-y'^2=0
(2)yy′′−y′2=0
(
3
)
d
x
/
d
t
+
5
x
+
y
=
e
t
,
d
y
/
d
t
−
x
−
3
y
=
e
2
t
(3)dx/dt+5x+y=e^t,dy/dt-x-3y=e^{2t}
(3)dx/dt+5x+y=et,dy/dt−x−3y=e2t
(
4
)
d
x
/
d
t
+
2
x
−
d
y
/
d
t
=
10
c
o
s
t
,
x
∣
t
=
0
=
2
,
d
x
/
d
t
+
d
y
/
d
t
+
2
y
=
4
e
−
2
t
,
y
∣
t
=
0
=
=
0
(4)dx/dt+2x-dy/dt=10cost, x|_{t=0}=2,dx/dt+dy/dt+2y=4e^{-2t},y|_{t=0}==0
(4)dx/dt+2x−dy/dt=10cost,x∣t=0=2,dx/dt+dy/dt+2y=4e−2t,y∣t=0==0——求特解
clear clc %T1 y=dsolve('Dy=1/(x+y)','x') %T2 y=dsolve('y*D2y-Dy^2=0','x') %T3 [x,y]=dsolve('Dx+5*x+y=exp(t)','Dy-x-3*y=exp(2*t)','t') %T4 [x,y]=dsolve('Dx+2*x-Dy=10*cos(t)','Dx+Dy+2*y=4*exp(-2*t)','x(0)=2','y(0)=0','t') %结果 y = - x - 1 y = C21 C20*exp(C19*x) x = exp(t*(15^(1/2) - 1))*(C22 - exp(2*t - 15^(1/2)*t)*((7*exp(t))/12 + 15^(1/2)/165 + (3*15^(1/2)*exp(t))/20 + 1/22))*(15^(1/2) - 4) - exp(-t*(15^(1/2) + 1))*(C23 - exp(2*t + 15^(1/2)*t)*((7*exp(t))/12 - 15^(1/2)/165 - (3*15^(1/2)*exp(t))/20 + 1/22))*(15^(1/2) + 4) y = exp(t*(15^(1/2) - 1))*(C22 - exp(2*t - 15^(1/2)*t)*((7*exp(t))/12 + 15^(1/2)/165 + (3*15^(1/2)*exp(t))/20 + 1/22)) + exp(-t*(15^(1/2) + 1))*(C23 - exp(2*t + 15^(1/2)*t)*((7*exp(t))/12 - 15^(1/2)/165 - (3*15^(1/2)*exp(t))/20 + 1/22)) x = 4*cos(t) - 2*exp(-2*t) + 3*sin(t) - 2*exp(-t)*sin(t) y = sin(t) - 2*cos(t) + 2*exp(-t)*cos(t)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。