当前位置:文档之家› 数学实验答案

数学实验答案

实验一%sy1ljq20111668%第一大题%1x=[3,2*pi];y1=sin(x)+exp(x)%y1= 20.2267 535.4917%2x=2:2:10y2=x.^2+sqrt(2*x)%y2= 6.0000 18.8284 39.4641 68.0000 104.4721 %3a=2*pi,b=35/180*pi,c=exp(2);y31=sin(a/5)+cos(b)*cy32=tan(b)*cot(a/3)%y31 =7.0038%y32 =-0.4043%6a1=-6.28,a2=7.46,a3=5.37;a11=fix(a1)a21=fix(a2)a31=fix(a3)%a11=-6%a21=7%a31=5%7y71=abs(a1*a2+a3)y72=a1^2*sqrt(a2*a3/2) %y71 =41.4788%y72 =176.5066%8save sy1clear%9load sy1%10A=[2 -5 6;8 3 1;-4 6 9]; A1=A'A2=det(A)A3=5*Asave sy1 A1 A2 A3%A1 = 2 8 -4-5 3 66 1 9%A2 =782%A3 = 10 -25 3040 15 5-20 30 45%第二大题%1X=0:pi/10:2*pi;Y=cos(X);S=[X',Y']%S =0 1.00000.3142 0.9511 0.6283 0.80900.9425 0.58781.2566 0.3090 1.5708 0.00001.8850 -0.30902.1991 -0.5878 2.5133 -0.80902.8274 -0.95113.1416 -1.0000 3.4558 -0.95113.7699 -0.80904.0841 -0.5878 4.3982 -0.30904.7124 -0.00005.0265 0.3090 5.3407 0.5878 5.6549 0.80905.9690 0.95116.2832 1.0000%2a22=input('a22='); b22=input('b22=');c22=input('c22=');s=(a22+b22+c22)/2;A2=sqrt(s*(s-a22)*(s-b22)*(s-c22))%A2=19.5225%3sumjs=0;sumos=0;for i=1:2:99sumjs=sumjs+i;sumos=sumos+i+1;endsumjssumos%sumjs =2500%sumos =2550%4i=0;while i<=1000i=i+1;if(rem(i,3)==2&rem(i,5)==3&rem(i,7)==2)iendend%i=23,128,233,338,443,548,653,758,863,968, %第三大题x=[3 -4 8];y=(x.^2+5*x).*exp(2-x)%y= 1.0e+003 *% 0.0088 -1.6137 0.0003实验二%sy2ljq20111668%第一大题%1.1x1=[3,5,-1,2,8,12];y1=3*x1.^2+exp(x1)-x1+2%y1 =1.0e+005 *% 0.0005 0.0022 0.0001 0.0002 0.0317 1.6318 %1.2x2=[-2,-1,0,1,2,3,4];y2=(sin(x2+2)-1)/(x2.^3+6)%y2 =-0.0292%第二大题%2.1x=input('x=');if x<0y11=exp(x)+x.^3;elsey11=2*x-sin(4*x);endx,y11%x =6.2832,y11 =12.5664%x =-12,y11 =-1.7280e+003%2.2x=input('x=')if x>0y2=5*x+3;elseif x<0y2=3*x.^2;else y2=4;endx,y2%x=45,y2=228%x=-32,y2=3072 %第三大题x=input('x=');if x>0y3=log(2*x); elsey3=2*x.^3-x+5; endx,y3%x =4,y3 =2.0794 %x=0,y3=5%x=-2,y3=-9%第四大题%4.1for i=1:6for j=1:6if i==jA(i,j)=5;elseif abs(i-j)==1A(i,j)=2;elseA(i,j)=1;endendendA%A = 5 2 1 1 1 1% 2 5 2 1 1 1% 1 2 5 2 1 1% 1 1 2 5 2 1% 1 1 1 2 5 2% 1 1 1 1 2 5%4.2t=[3,2,5,4,-2,-3];for i=1:6A(i,:)=t.^(i-1);endA%A = 1 1 1 1 1 1% 3 2 5 4 -2 -3% 9 4 25 16 4 9% 27 8 125 64 -8 -27 % 81 16 625 256 16 81% 243 32 3125 1024 -32 -243 %4.3n=input('n=')s=0;k=1;while k<=ns=s+1/k;k=k+1;ends%n =15,s =3.3182%n=20,s =3.5977%4.4i=0;a=1;b=1;j=4;abwhile i<=40while j>0j=j-1;i=i+1;c=a+b;ca=b;b=c;endj=4;end%4.5n=input('n=')a=input('a=')i=1;sn=0;while i<=nsn=sn+a.^i;i=i+1;endsn%n=6,a=2,sn=126%第五大题n=input('0<=n<=100,n=') switch fix(n/10)case{10,9}s='优秀';case{8,7}s='良好';case 6s='及格';case{5,4,3,2,1,0}s='不及格';ends%n =56,s =不及格%第六大题j=1;for i=1:200flag = isprime(i);if flagA(1,j)=i;j=j+1;endendA%第七大题p=input('p=');w=input('w=');s=input('s=');if s<50a=1;elseif 250>=s&&s<500 a=2;elseif 500>=s&&s<1000 a=3;elseif 1000>=s&&s<2000 a=4;elseif 2000>=s&&s<3000 a=5;elsea=6;endswitch acase 1d=0;case 2d=0.02;case 3d=0.05;case 4d=0.08;case 5d=0.1;case 6d=0.15endf=p*w*s*(1-d);f实验三%sy3ljq20111668%第一大题%1.1x11=[2 -5 8 -1 7 1 -8 3 2 5 9]%x11 =2 -5 8 -1 7 1 -8 3 2 5 9%1.2x12=2:2:22%x12 =2 4 6 8 10 12 14 16 18 20 22 %1.3x13=linspace(0,2*pi,20)%x13 =Columns 1 through 80 0.3307 0.6614 0.9921 1.3228 1.6535 1.9842 2.3149Columns 9 through 162.6456 2.97623.3069 3.6376 3.96834.2990 4.6297 4.9604 Columns 17 through 205.2911 5.6218 5.95256.2832%1.4x14=rand(1,8)%x14 =0.4565 0.0185 0.8214 0.4447 0.6154 0.7919 0.9218 0.7382 %1.5x15=rand(6,1)%x15 =0.95010.23110.60680.48600.89130.7621%1.6x16=x11(abs(x11)>3)%x16 =-5 8 7 -8 5 9%1.7m1=[5 4 9];m2=[8 6 3];d=norm(m1-m2)%d=7%1.8x18=4+x11+7*x12%x18 =20 27 54 59 81 89 94 119 132 149 167%1.9x19=dot(x11,x12)%x19 =376%1.10x10=cross(x11(find([1 1 1 0 0 0 0 0 0 0 0])),x12(find([1 1 1 0 0 0 0 0 0 0 0]))) %x10 =-62 4 18%第二大题%2.1figureaxis([0 8 0 8])x21=[0 0 8 8 0 0 8 8 4 4];y21=[0 8 8 0 0 4 4 0 0 8];line(x21,y21)%2.2y22=[4 5 5 3 2 3 5 6 7 8];plot(y22).%2.3x23=0.1:0.01:10;xlabel('x轴')y23=30./x23;ylabel('y轴')plot(x23,y23)%2.4x24=linspace(-5,5,30);y24=5*x24.*cos(x24);plot(x24,y24)%2.5x25=linspace(-2*pi,2*pi,30);y25=sin(x25);z25=cos(x25);plot(x25,y25,'bo-',x25,z25,'r*--') %2.6x26=-8:1:8;f1=3*x26.^2;f2=exp(x26+1);f3=cos(4*x26-6);f4=x26.*sin(2*x26);f5=log(x26.^2+3);f6=2*x26.^3+4*x26.^2-6*x26+1; subplot(2,3,1)plot(x26,f1,'r-')title('f1=3*x26.^2')subplot(2,3,2)plot(x26,f2,'m--')title('f2=exp(x26+1)')subplot(2,3,3)plot(x26,f3,'b-*')title('f3=cos(4*x26-6)')subplot(2,3,4)plot(x26,f4,'k-o')title('f4=x26.*sin(2*x26)')subplot(2,3,5)plot(x26,f5,'c-.')title('f5=log(x26.^2+3)')subplot(2,3,6)plot(x26,f6,'g:')title('f6=2*x26.^3+4*x26.^2-6*x26+1') %第三大题%3.1syms msubplot(2,2,1)m=0:0.1:4*pi;polar(m,cos(m/3),'r')subplot(2,2,2)m=0:0.1:5*pipolar(m,exp(0.3*m),'g')subplot(2,2,3)m=0.6*pi:0.1*pi:6*pir=m.^(-1)*4;polar(m,r,'b')%3.3t33=linspace(0,8*pi,100);x33=cos(t33);y33=sin(t33);plot3(x33,y33,z33); %第四大题figureaxis([0,10,0,10])hold onk=input('k=')for i=1:kx=[];y=[];n=0;while(1)[xx,yy,b]=ginput(1) plot(xx,yy,'r')x=[x,xx]y=[y,yy]n=n+1;实验四%sy4ljq20111668%1.1t=linspace(0,pi,20);r=2+cos(t)+sin(t); cylinder(r,30)shading interp%1.2[x,y]=meshgrid(-3:0.1:3);mesh(x,y,z2);title('双曲抛物面曲面网线图');axis off%1.3[x,y]=meshgrid(-5:0.5:5);z3=sqrt(x.^2-2.*y);surf(x,y,z3);shading interp%1.4n=30theta=(-n:2:n)/n*pi;phi=(-n:2:n)'/n*pi/2;cosphi=cos(phi);cosphi(1)=0;cosphi(n+1)=0;sintheta=sin(theta);sintheta(1)=0;sintheta(n+1) =0;x=cosphi*cos(theta);y=cosphi*sintheta;z4=sin(x)-cos(y);surf(x,y,z4)shading interp%1.5ezsurf(@(x,y)(x^2+y^2+6*sin(2*x)),[-2*pi 2*pi -2*pi 2*pi])shading interp%2.1x21=1:10y21=fix(rand(1,10)*30);bar(x21,y21)%2.2y221=[2.5 3 4.5 5 2.8];y222=[2 2.2 3 2.5 1.8];x=1:5;area(x,y221,'facecolor',[0.75 0.6 0.9],'edgecolor','b') hold onarea(x,y222,'facecolor',[0.5 0.9 0.7],'edgecolor','r') hold offgtext('住房修建统计')gtext('入住率')%2.3y22=rand(1,50);hist(y22,5)%2.4y23=[46 75 148 214 98 35];subplot(1,2,1)pie(y23,[0 0 0 1 0 0])subplot(1,2,2)pie3(y23,[0 0 0 1 0 0])%2.5[x,y,z]=peaks(30);subplot(2,2,1) surf(x,y,z) subplot(2,2,2) contour(x,y,z,15) subplot(2,2,3) contour3(z,20) subplot(2,2,4) [c,h]=contour(z); %3.1A=[56 36 4 421 19 51 931 31 23 1527 40 14 1921 51 24 426 29 9 2656 10 5 2924 13 31 3232 10 14 44]for i=1:9 subplot(3,3,i) pie(A(i,:))endfigurebar(A)%4.1figure(1)t=linspace(-0.5*pi,0.75*pi,500);x=sin(t);y=t.*cos(t)comet(x,y)%4.2t=0:0.01:100;x=2*(t.^2);y=2*sin(t);z=5*cos(3*t);comet3(x,y,z)实验五%sy5ljq20111668%第一大题%1.1A1=[1 3 5 7;2 4 6 8;9 8 6 3;-6 0 4 3] A2=[3 5 -2 34 8 3 06 7 4 -12 5 6 9]%A1 =1 3 5 72 4 6 89 8 6 3-6 0 4 3%A2 =3 5 -2 34 8 3 06 7 4 -12 5 6 9%1.2A3=[x1 x2 x3 x4 x5;y1 y2 y3 y4 y5] x=input('x=')A4=[sin(x) x.^2;1+x cos(x)]%1.3B=rand(4,4)%1.4t=[2 3 4 2 5 3];F=vander(t)F1=rot90(F)%F = 32 16 8 4 2 1243 81 27 9 3 11024 256 64 16 4 132 16 8 4 2 13125 625 125 25 5 1243 81 27 9 3 1%F1 =1 1 1 1 1 12 3 4 2 5 34 9 16 4 25 98 27 64 8 125 2716 81 256 16 625 8132 243 1024 32 3125 243%1.5C=magic(4)% C =16 2 3 13% 5 11 10 8% 9 7 6 12% 4 14 15 1%1.6Q=zeros(4,4)E=eye(4,4)N=ones(4,4)%1.7A6=[B E Q;N C A1]%第二大题%2.1a21=max(A1)a22=min(A1)a23=mean(A1)a24=median(A1)a25=std(A1)a26=sum(A1)%a21 =9 8 6 8%a22 = -6 0 4 3%a23 =1.5000 3.7500 5.2500 5.2500 %a24 =1.5000 3.5000 5.5000 5.0000 %a25 =6.1373 3.3040 0.9574 2.6300 %a26 =6 15 21 21%2.2a27=A1+A2A28=A1*A2%2.3a29=A2(:,[1 3 2 3]) %a29 =3 -2 5 -24 3 8 36 47 42 6 5 6%第三大题%3.1A=fix(30*rand(6)) %A =28 24 8 13 25 21 27 0 5 12 0 1212 4 0 25 20 926 6 22 15 11 51 5 13 6 24 510 18 27 20 15 20 %3.2A31=A'A32=det(A)%A31 =28 27 12 26 1 10 24 0 4 6 5 188 5 0 22 13 2713 12 25 15 6 2025 0 20 11 24 1521 12 9 5 5 20A32 =94663484%3.3%a32=det(A)不等于0A33=inv(A)A33 =0.0138 0.0124 -0.0074 0.0233 -0.0043 -0.0233 0.0404 -0.0743 0.0053 0.0305 -0.0658 0.0087 -0.0182 0.0032 -0.0220 0.0189 0.0174 0.0181 -0.0153 -0.0249 0.0475 0.0159 -0.0409 0.0159 0.0064 0.0030 0.0038 -0.0056 0.0473 -0.0207 -0.0081 0.0791 -0.0216 -0.0762 0.0433 0.0290 %3.4[D,X]=eig(A)%第四大题%4.1A41=[1 -5 2 -3;5 3 6 -1;2 4 2 1];b41=[11;-1;-6];A1=[A b];if rank(A1)=rank(A)rr=rref(A1)x='由行的最简形式rr写通解'elsex='方程组无解'end%4.2A=[0 1 1 -1;1 0 -1 1;1 -1 0 1;-1 1 1 0]; [D,X]=eig(A)P=orth(D)P*P'%第五大题A=input('请输入二次矩阵A=')P=orth(D)%6.1c1=[4 2 6 2 7 5 8]P1=poly2sym(c1)%6.2c2=[1 4 7]c22=poly(c2)P2=poly2sym(c22)%6.3c3=[1 -2 4 -6];r=roots(c3)%6.4c4=[1 -9 21 1 -30]r=roots(c3)%6.5c51=[1 0 4 -3 0 9];c52=[1 -6 4 8];f1=poly2sym(c51)f2=poly2sym(c52)g1=f1+f2gp2=conv(c51,c52)g2=poly2sym(gp2)[q,r]=deconv(c51,c52)%6.6c66=[3 5 -2 4 6 -7 1];P66=polyder(c66)f6=poly2sym(P66)%6.8x=1:2:15;y=[1.9221 -1.8389 -0.3916 2.1648 -1.4101 -0.9911 2.2351 -0.8691] c=polyfit(x,y,6);z=polyval(c,x);polt(x,y,'ro-',x,z,':')实验六%sy6ljq20111668%第一大题%1.function y=f(x);if x>0y=4*x^3+5*sqrt(x)-7elsey=x^2+sin(x)end%f(12) =6.9223e+003%f(-32)=1.0234e+003%2function y=f2(x);if x<0y=sin(5*x)+6*x^3elsey=exp(2*x)+3*xend%f2(-6)=-1.2950e+003%f2(11)=3.5849e+009%3syms xy=(1+x)/(x-3)g=finverse(y)%g =(1+3*x)/(-1+x)%4syms xf4=3*x^4+5*x^3-6*x^2+7;g4=8*x^3+2*x^2+x-9;u1=f4+g4u2=f4-g4u3=f4*g4u4=f4/g4u5=f4^g4u6=compose(f4,g4)%u1 =3*x^4+13*x^3-4*x^2-2+xu3 =(3*x^4+5*x^3-6*x^2+7)*(8*x^3+2*x^2+x-9)u4 =(3*x^4+5*x^3-6*x^2+7)/(8*x^3+2*x^2+x-9)u5 =(3*x^4+5*x^3-6*x^2+7)^(8*x^3+2*x^2+x-9)u6 =3*(8*x^3+2*x^2+x-9)^4+5*(8*x^3+2*x^2+x-9)^3-6*(8*x^3+2*x^2+x-9)^2+7 % 5f5=-452*x^2+224*x^3+60*x^4-296*x+320f51=factor(f5)f52=horner(f5)x=solve(f5)%6fzero('x*exp(x)-2*x^2+5',[-2,2])%ans = -1.5278%第二大题一元微积分%1syms xy1=limit((x^2)*(3^(1/x)+3^(-1/x)-2),inf) %2syms xy21=limit(x*log(sin(x)),x,0,'right')y22=limit((sin(sqrt(x^2+1))-sin(x))/x,inf)%3f=taylor(sin(x),x,5,1)%第三大题f1=limit(x^2+1,x,0,'right');f2=limit(exp(x)+x,x,0,'left');if f1==f2a='函数在该点连续';elsea='函数在该点不连续';enda%第四大题%1syms xy=sin(x^3)y41=diff(y,x,1)%2syms x ay=x^(1/a)+a^(1/x)+x^(1/x)y42=diff(y,x,1)%3syms xy=atan(log(x))y43=diff(y,x,2)%4syms xy=(x*asin(x))/sqrt(1-x^2)+log(1-x^2)y44=diff(y,x,2)%第五大题%1syms xy51='2*x^3-6*x^2-18*x+7';[x1,minf]=fminbnd(y51,1,2)%2syms xy52='x+sqrt(16-x)';[x2,maxf]=fminbnd('-x-sqrt(16-x)',-2,2)%第六大题syms xy611=x^5*cos(x^3)y621=(sin(x))^10y631=1/(((x+1)^2*(x-1)^4)^(1/3))y61=int(y611)y62=int(y621)y63=int(y631)%y61 =1/3*cos(x^3)+1/3*x^3*sin(x^3)%y62=-1/10*sin(x)^9*cos(x)-9/80*sin(x)^7*cos(x)-21/160*sin(x)^5*cos(x)-21 /128*sin(x)^3*cos(x)-63/256*cos(x)*sin(x)+63/256*x%y63 =-3/2*(x-1)*(x+1)/((x+1)^2*(x-1)^4)^(1/3)%第七大题syms xy711='sin(x(1/6))'y721='1/((x+1)*sqrt(x^2-1))'y71=int(y711,0,1)y72=int(y721,1,2)%y71 =int(sin(x(1/6)),x = 0 .. 1)%y72 =1/3*3^(1/2)%第八大题%1function y=pmtxmj(y1,y2,a,b)y=int((y2-y1),a,b);syms xy1=x^2;y2=sqrt(x);a=0;b=1;A=pmtxmj(y1,y2,a,b)%2function y=pmqxhc(x,y,a,b)y=int(sqrt((diff(x))^2+(diff(y))^2),a,b);syms tx=cos(t)+t*sin(t)y=sin(t)-t*cos(t)a=0;b=pi;s=pmqxhc(x,y,a,b)%s =1/2*pi^2%3function y=xzttj(f,a,b)y=int(pi*f^2,a,b);syms xf=x^2+1v=xzttj(f,-1,1)%v =56/15*pi实验七%第一大题%1syms x y zz=atan((x+y)/(1-x*y));f1=diff(z,x)f2=diff(z,y)f3=diff(diff(z,x),y)%2syms z x yz=(x^2+2*y)*exp(x*y)dz=diff(z,x)*'dx'+diff(z,y)*'dy'%dz =(2*x*exp(x*y)+(x^2+2*y)*y*exp(x*y))*dx+(2*exp(x*y)+(x^2+2*y)*x*exp(x*y))*dy%3syms u x y zu=sqrt(x^2+y^2+z^2)f31=diff(u,x,2)f32=diff(u,y,2)f33=diff(u,z,2)x=1;y=2;z=3;f311=eval(f31)f321=eval(f32)f331=eval(f33)%f311 =0.2482f321 = 0.1909f331 =0.0955%4syms u x y zu=x*y^2*z^3*sin((2*x)/(5*z*y^2))f41=diff(diff(diff(u,x),y),z)%f41=6*y*z^2*sin(2/5*x/z/y^2)-12/5/y*z*cos(2/5*x/z/y^2)*x-16/125*x^3/z*cos(2/5*x/z/y^2) /y^5%第二大题%1f='cos(x(1))+sin(x(2))-sin(2+x(1)+x(2))'[x,minf]=fminsearch(f,[0,pi]);minf=eval(f)%minf =-2.3577%2f2='-sin(x(1))*sin(x(2))*sin(x(1)+x(2))'[x,minf]=fminsearch(f2,[0,0])maxf=-eval(f2)%maxf =0.6495%3[x,y]=meshgrid(-2:0.05:1);z=(x+y.^2+2*y)*exp(2*x);surf(x,y,z)%x0=(1,-1)f31='(x(1)+x(2).^2+2*x(2))*exp(2*x(1))'[x,minf]=fminsearch(f31,[-1,1])minf=eval(f31)%x =0.5000 -1.0000minf =-1.3591[x,y]=meshgrid(-5:0.5:5);f=exp(2*x)*(x+y^2+2*y);surf(x,y,f)z3='exp(2*x(1))*(x(1)+x(2)^2+2*x(2))' [x,minz3]=fminsearch(z3,[-6,-4])%第三大题%1f1='(x+1)*y^2's1=int(int(f1,y,x,x^2),x,2,4)%s1 =357836/105%2syms x y zf2='z*(x+y)'s2=int(int(int(f2,z,x^2+y^2,2),y,-sqrt(1+x^2),sqrt(1+x^2)),x,-2,2) %s2=0%第四大题不考%1function s=sxjf(f,x,y,z,a,b)syms ts=int(f*sqrt(diff(x,t)^2+diff(y,t)^2+diff(z,t)^2),t,a,b);syms t ax=sqrt(1/2)*a*cos(t);y=sqrt(1/2)*a*cos(t);z=a*sin(t);f2=sqrt(2*y^2+z^2);a=0;b=2*pi;s1=sxjf(f2,x,y,z,a,b)%s1 =2*a^2*pi%2function s=zxjf(p,q,r,x,y,z,a,b)syms ts=int(p*diff(x,t)+q*diff(y,t)+r*diff(z,t),t,a,b);x=t;y=x^(2/3);z=0;p=x^2+y;q=x-y^2;r=0;s2=zxjf(p,q,r,x,y,z,0,1)%s2 =1%3function s=sxjf(f,x,y,z,a1,b1)syms ts=int(f*sqrt(diff(x,t)^2+diff(y,t)^2+diff(z,t)^2));syms a tx=a*cos(t);y=a*sin(t);z=0;f=(x^2+y^2)^5;s=sxjf(f,x,y,z,0,2*pi)%s =2*pi*a^11*csgn(a)%4function s=sxjf(f,x,y,z,a1,b1)syms ts=int(f*sqrt(diff(x,t)^2+diff(y,t)^2+diff(z,t)^2),t,a1,b1); syms tx=cos(t)*exp(t);y=sin(t)*exp(t);z=exp(t);f2=1/(x^2+y^2+z^2);a1=0;b1=2;s2=sxjf(f2,x,y,z,a1,b1)%s2 =1/2*3^(1/2)-1/2*3^(1/2)*exp(-2)%第五大题%1y=dsolve('2*D2y+Dy-y=2*exp(x)')%y =exp(1/2*t)*C2+exp(-t)*C1-2*exp(x)52y=dsolve('D2y+y+sin(2*x)=0','y(pi)=1','Dy(pi)=1')%y =-sin(t)+cos(t)*(-1-sin(2*x))-sin(2*x)。

相关主题