《数学实验课后习题解答.docx》由会员分享,可在线阅读,更多相关《数学实验课后习题解答.docx(65页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、数学实验课后习题解答王汝军编写实验一 曲线绘图【练习与思考】画出下列常见曲线的图形。以直角坐标方程表示的曲线:1 .立方曲线y = X3clear;x=-2:0.1:2;y=x3;plot(x,y)2.立方抛物线,=3clear;y=-2:0.1:2;=y.3;plot(x,y)grid on3 .高斯曲线y = e T2clear;x=-3:0.1:3;y=exp(-x,2);plot(x,y);grid on %axis equal以参数方程表示的曲线24 . 奈尔抛物线x=t3,y=t2 (y=x3)clear;t=-3:0.05:3;x=t.3;y=t.2;plot(x,y)axis
2、equalgrid on5 . 半立方抛物线x=t2,y=t3(y2=x3) clear;t=-3:0.05:3;x=t.2;y=t.3; plot(x,y) %axis equal grid on6 .迪卡尔曲线 X = H, y =把(X 3 + y 3 - 3 Oxy = 0)1 + 121 + 12clear;a=3;t=-6:0.1:6;x=3*a*t./(1+t.2);y=3*a*t2Z(1+t2);plot(x,y)7 .蔓叶线X =旦,y = 士 (y2 =旦) 1 + 21 + 2 a - Xclear;a=3;t=-6:0.1:6;x=3*a*t.2.Z(1+t.2);y=
3、3*a*t.3.Z(1+t.2); plot(x,y)8 .摆线 X = a(t - sin t), y = b(1 - cost) clear;clc;a=1;b=1;t=0:pi/50:6*pi;x=a*(t-sin(t);y=b*(1-cos(t);plot(x,y);axis equalgrid on222X = acos31, y = asin31 (X3 + y 3 = a3)9 . 内摆线(星形线)clear;a=1;t=0:pi/50:2*pi;x=a*cos(t).3;y=a*sin(t).3;plot(x,y)tcost)10 .圆的渐伸线(渐开线)X = a(CoSt +
4、1Sint),y = a(Sint clear;a=1;t=0:pi/50:6*pi;x=a*(cos(t)+t.*sin(t);y=a*(sin(t)+t.*cos(t);plot(x,y)grid on11 . 空间螺线x =a cos t, y = b sin t, Z = Ctcleara=3;b=2;c=1;t=0:pi/50:6*pi;x=a*cos(t);y=b*sin(t);z=c*t;plot3(x,y,z)grid on以极坐标方程表示的曲线:12 .阿基米德线r = a,r 0 clear;a=1;phy=0:pi/50:6*pi;rho=a*phy;polar(phy,
5、rho,r-*)13 .对数螺线r = eaclear;a=0.1;phy=0:pi/50:6*pi;rho=exp(a*phy);polar(phy,rho)14 .双纽线 r2 = a2 cos2 (X2 + y2)2 = a2(X2 - y2) clear;a=1;phy=-pi/4:pi/50:pi/4;rho=a*sqrt(cos(2*phy);polar(phy,rho)hold onpolar(phy,-rho)15 .双纽线 r2 = a2 sin 2 (X2 + y2)2 = 2a2y) clear;a=1;phy=0:pi/50:pi/2;rho=a*sqrt(sin(2*
6、phy);polar(phy,rho)hold onpolar(phy,-rho)16 .四叶玫瑰线r = asin2,r 0clear;closea=1;phy=0:pi/50:2*pi;rho=a*sin(2*phy);polar(phy,rho)17 . 三叶玫瑰线r =a sin 3, r 0clear;closea=1;phy=0:pi/50:2*pi;rho=a*sin(3*phy);polar(phy,rho)18 .三叶玫瑰线r = acos3,r 0clear;closea=1;phy=0:pi/50:2*pi;rho=a*cos(3*phy);polar(phy,rho)实
7、验二 极限与导数【练习与思考】1求下列各极限(1)lim(1 - )n (2)limn n3 + 3n(3)lim( n + 2 - 2 n + 1 + n)nnnclear;syms ny1=limit(1-1n)n,n,inf)y2=limit(n3+3n)(1n),n,inf)y3=limit(sqrt(n+2)-2*sqrt(n+1)+sqrt(n),n,inf)y1 =1/exp(1)y2 =3(4)lim( 2 - 1 )x1 x2 - 1 x - 1 clear;y3 =0(5)lim xcot 2x (6)lim( x2 + 3x - x) x0xsyms X ;y4=limi
8、t(2(x2-1)-1(x-1),x,1) y5=limit(x*cot(2*x),x,0) y6=limit(sqrt(x2+3*x)-x,x,inf)y4 =-1/2 y5 =1/2 y6 =3/2m(7)lim(cos ) xxxclear;(8)lim( 1 - 1 ) x1 x e x - 1(9)limx0xsyms x my7=limit(cos(m/x),x,inf) y8=limit(1/x-1/(exp(x)-1),x,1) y9=limit(1+x)(1/3)-1)/x,x,0)y7 =1y8 =(exp(1) - 2)(exp(1) - 1)y9 =1/32 .考虑函数
9、f (X) = 3X2 sin(X3), - 2 X epsla=a+fn;n=n+1;fn=fn/n;ep=fn;endfnvpa(a,100)nfn =8.3482e-101ans =2.71828182845904553488480814849026501178741455078125n =70精确到小数点后100位,这时应计算到这个无穷级数的前71项,理由是误差小于 10的负100次方,需要最后一项小于10的负100次方,由上述循环知n=70时最 后一项小于10的负100次方,故应计算到这个无穷级数的前71项.4 . 用练习3中所用观测法判断下列级数的敛散性(1) n 2 + n 3n
10、 =1clear;clc;epsl=0.000001;N=50000;p=1000;syms nUn=1/(n2+n3);s1=symsum(Un,1,N);s2=symsum(Un,1,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa); fprintf(级数) disp(Un) if saepsldisp(收敛) elsedisp(发散) end级数1(n3 + n2)收敛clear;closesyms ns=;for k=1:100s(k)=symsum(1/(n3 + n2),1,k);endplot(s,.);n2n n=1 clear;c
11、lc; epsl=0.000001; N=50000;p=1000;syms nUn=1/(n*2n);SI=SymSUm(Un,1,N);s2=symsum(Un,1,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa);fprintf(级数)disp(Un)if saepsldisp(收敛)elsedisp(发散) end级数1(2n*n)收敛 clear;closesyms n s=;for k=1:100s(k)=symsum(1(2n*n),1,k);endplot(s,.)(3) sin1n n=1 clear;clc; epsl=0.00
12、000000000001; N=50000;p=100;syms nUn=1/sin(n);SI=SymSUm(Un,1,N);s2=symsum(Un,1,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa);fprintf(级数)disp(Un)if abs(sa)epsldisp(收敛)elsedisp(发散)end级数1/sin(n)发散clear;closesyms ns=;for k=1:100s(k)=symsum(1sin(n),1,k);endplot(s,.)发散(4) ln n n3 n=1 clear;clc; epsl=0.0
13、000001;N=50000;p=1000;syms nUn=log(n)/(n3);SI=SymSUm(Un,1,N); s2=symsum(Un,1,N+p); Sa=VPa(S2-s1); sa=setstr(sa);sa=str2num(sa); fprintf(级数) disp(Un) if saepsl disp(收敛)elsedisp(发散) end级数log(n)n3收敛clear;closesyms ns=;for k=1:100s(k)=symsum(log(n)/n3,1,k);endplot(s,.)史nnn=1clear;closesyms ns=;he=0;for
14、k=1:100he=he+factorial(k)/kk;s(k)=he;endplot(s,.),(lnn) nn =3clear;clc;epsl=0.0000001;N=50000;p=1000;syms nUn=1/log(n)n;s1=symsum(Un,3,N);s2=symsum(Un,3,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa);fprintf(级数) disp(Un) if saepsldisp(收敛) elsedisp(发散) end级数1log(n)n收敛clear;closesyms ns=;for k=3:100s
15、(k)=symsum(1Aog(n)n,3,k);endplot(s,.)(7)n ln nn =1 clear;clc;epsl=0.0000001;N=50000;p=100;syms nUn=1/(log(n)*n);SI=SymSum(Un,3,N);s2=symsum(Un,3,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa);fprintf(级数)disp(Un)if (sa)epsldisp(收敛)elsedisp(发散) end级数 1(n*log(n)发散clear;closesyms ns=;for k=3:300s(k)=sy
16、msum(1(n*log(n),2,k);endplot(s,.) (-1) nnn 2 +1n =1clear;clc;epsl=0.0000001;N=50000;p=100;syms nUn=(-1)n*n/(n2+1);SI=SymSUm(Un,3,N);s2=symsum(Un,3,N+p);sa=vpa(s2-s1);sa=setstr(sa);sa=str2num(sa);fprintf(级数)disp(Un)if (sa)epsldisp(收敛)elsedisp(发散)end级数(-1)n*n)/(n2 + 1)收敛clear;closesyms ns=;for k=3:300
17、s(k)=symsum(-1)n*n(n2+1),2,k);endplot(s,.)实验四积分【练习与思考】并用diff验证J arcsin Xdx , J sec 3 Xdx,1(不定积分)用int计算下列不定积分Jxsin X2dx , J dx , J上, 1 + cos xex +1解:Matlab代码为:syms xy1=x*sin(x2);y2=1/(1+cos(x);y3=1/(exp(x)+1);y4=asin(x);y5=sec(x)3;f1=int(y1)f2=int(y2)f3=int(y3)f4=int(y4)f5=int(y5)dy=simplify(diff(f1;
18、f2;f3;f4;f5)dy =x*sin(x2)tan(x/2)2/2 + 1/21/(exp(x) + 1)asin(x)(cot(pi/4 + x/2)*(tan(pi/4 + x/2)2/2 + 1/2)/2 + 1/(2*cos(x) + tan(x)2/cos(x)f1 =-cos(x2)/2f2 =tan(x/2)f3 =x - log(exp(x) + 1)f4 =x*asin(x) + (1 - x2)(1/2)f5 =log(tan(pi/4 + x/2)/2 + tan(x)/(2*cos(x)2(定积分)用trapz,quad,int计算下列定积分sin x1 dx ,
19、 0xJIxxdx,0J2 ex sin(2 X )dx ,J100e -X2 dx解:Matlab代码为clear;x=(0+eps):0.05:1;y1=sin(x)./x;f1=trapz(x,y1)f1 =0.9460fun1=(x)Sin(X)./x;f12=quad(fun1,0+eps,1)f12 =0.9461f13=vpa(int(sin(x)/x,0,1),5)f13 =0.946083(椭圆的周长)用定积分的方法计算椭圆x2 +止=1的周长 94解:椭圆的参数方程为厂3y = 2sin t由参数曲线的弧长公式得S = J2 :X(t)2 + y (t)2dt = J2 J
20、9sin21 + 4cos2 tdt = J2 5sin21 + 4dt 000Matlab代码为s=vpa(int(sqrt(5*sin(t)2+4),t,0,2*pi),5)s =15.8654 .(二重积分)计算数值积分 (1 + X + y) dxdyX2+y22y解:fxy=(x,y)1+x+y;ylow=(x)1-sqrt(1-x.2);yup=(x)1+sqrt(1-x.2); s=quad2d(fxy,-1,1,ylow,yup)s =6.2832或符号积分法:syms X yxi=int(1+x+y,y,1-sqrt(1-x2),1+sqrt(1-x2);s=int(xi,x
21、,-1,1)s =2*pi5 .(假奇异积分)用trapz,quad8计算积分1 x1/3 cosXdX,会出现什么问题?-1分析原因,并求出正确的解。解:Matlab代码为clearx=-1:0.05:1;y=x.(1/3).*cos(x);s1=trapz(x,y)fun5=(x)xC(1/3).*cos(x);s2=quad(fun5,-1,1)int(x(1/3)*cos(x),x,-1,1)s1 =0.9036 + 0.5217is2 =0.9114 + 0.5262iWarning: Explicit integral could not be found.ans =int(x(1
22、/3)*cos(x), x = -1.1) ,原函数不存在,不能用int函数运算。 用梯形法和辛普森法计算数值积分时,由于对负数的开三次方运算结果为复 数,所以导致结果错误且为复数;显然被积函数为奇函数,在对称区间上的积分等于0,此时可以这样处理:(1)重新定义被积函数%fun5.mfunction y=fun5(x)m,n=size(x);for k=1:mfor l=1:ny(k,l)=nthroot(x(k,l),3)*cos(x(k,l);endendend用辛普森法:s=quad(fun5,-1,1)s = 0用梯形法clear;x=-1:0.01:1;y=fun5(x);s=tra
23、pz(x,y)s =-1.3878e-0176(假收敛现象)考虑积分I(k) = ksinXldx , 0(1)用解析法求I(k);clear;syms x k;Ik=int(abs(sin(x),0,k*pi)Warning: Explicit integral could not be found. Ik = int(abs(sin(x), x = 0.pi*k)(2)分别用trapz,quad和quad8求I(4), I(6)和I(8) ,发现什么问题? clear;for k=4:2:8;x=0:pi/1000:k*pi;y=abs(sin(x);trapz(x,y) endans =
24、8.0000ans =12.0000ans =16.0000for k=4:2:8fun6=(x)abs(sin(x);quad(fun6,0,k*pi)endans =8.0000ans =12.0000ans =16.00007(Simpson积分法)编制一个定步长Simpson法数值积分程序.计算公式为h.- -、I S = - (f + 4 f + 2 f + 4 f + + 2 f + 4 f + f )n 3 1234n-1nn+1b - a其中 n 为偶数,-=,f = f (a + (i -1)-), i = 1,2,n +1.ni解:Matlab代码为%fun7.mfunct
25、ion y=fun7(f_name,a,b,n)%f_name为被积函数%a,b为积分区间%n为偶数,用来确定步长h=(b-a)/nif mod(n,2)=0disp(n必须为偶数)return;endif nargin4n=100;endif nargin3disp(请输入积分区间)endif nargin=0disp(error)endh=(b-a)/n;x=a:h:b;s=0;for k=1:n+1if k=1|k=(n+1)xishu=1;elseif mod(k,2)=0xishu=4;elsexishu=2;ends=s+feval(f_name,x(k)*xishu;endy=s*h/3;end8(广义积分)计算广义积分exp(- X2)tan(x)Sin Xdx ,J dx ,Jdx- 1 + X40 X0 1 - X 2并验证公式exp(-)2 dx=1,Sinxdx=.-V 20 X2解:Matlab代码为clear;syms XSI=VPa(int(exp(-x2)(1+x4),-inf,inf),5)s2=quad(x)tan(x)./Sqrt(X),0,1)s3=quad(
限制150内