东华大学MATLAB数学实验第二版答案(胡良剑)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

数学实验答案Chapter1Page20,ex1(5)等于[exp(1),exp(2);exp(3),exp(4)](7)3=1*3,8=2*4(8)a为各列最小值,b为最小值所在的行号(10)1=4,false,2=3,false,3=2,ture,4=1,ture(11)答案表明:编址第2元素满足不等式(30=20)和编址第4元素满足不等式(40=10)(12)答案表明:编址第2行第1列元素满足不等式(30=20)和编址第2行第2列元素满足不等式(40=10)Page20,ex2(1)a,b,c的值尽管都是1,但数据类型分别为数值,字符,逻辑,注意a与c相等,但他们不等于b(2)double(fun)输出的分别是字符a,b,s,(,x,)的ASCII码Page20,ex3r=2;p=0.5;n=12;T=log(r)/n/log(1+0.01*p)Page20,ex4x=-2:0.05:2;f=x.^4-2.^x;[fmin,min_index]=min(f)最小值最小值点编址x(min_index)ans=0.6500最小值点[f1,x1_index]=min(abs(f))求近似根--绝对值最小的点f1=0.0328x1_index=24x(x1_index)ans=-0.8500x(x1_index)=[];f=x.^4-2.^x;删去绝对值最小的点以求函数绝对值次小的点[f2,x2_index]=min(abs(f))求另一近似根--函数绝对值次小的点f2=0.0630x2_index=65x(x2_index)ans=1.2500Page20,ex5z=magic(10)z=929918156774515840988071416735557644148188202254566370478587192136062697128869325296168755234172476839042492633652358289914830323966796139597293138457210129496783537444653111810077843643502759sum(z)sum(diag(z))z(:,2)/sqrt(3)z(8,:)=z(8,:)+z(3,:)Chapter2Page45ex1先在编辑器窗口写下列M函数,保存为eg2_1.mfunction[xbar,s]=ex2_1(x)n=length(x);xbar=sum(x)/n;s=sqrt((sum(x.^2)-n*xbar^2)/(n-1));例如x=[81706551766690876177];[xbar,s]=ex2_1(x)Page45ex2s=log(1);n=0;whiles=100n=n+1;s=s+log(1+n);endm=nPage40ex3clear;F(1)=1;F(2)=1;k=2;x=0;e=1e-8;a=(1+sqrt(5))/2;whileabs(x-a)ek=k+1;F(k)=F(k-1)+F(k-2);x=F(k)/F(k-1);enda,x,k计算至k=21可满足精度Page45ex4clear;tic;s=0;fori=1:1000000s=s+sqrt(3)/2^i;ends,toctic;s=0;i=1;whilei=1000000s=s+sqrt(3)/2^i;i=i+1;ends,toctic;s=0;i=1:1000000;s=sqrt(3)*sum(1./2.^i);s,tocPage45ex5t=0:24;c=[15141414141516182022232528...313231292725242220181716];plot(t,c)Page45ex6(1)x=-2:0.1:2;y=x.^2.*sin(x.^2-x-2);plot(x,y)y=inline('x^2*sin(x^2-x-2)');fplot(y,[-22])(2)参数方法t=linspace(0,2*pi,100);x=2*cos(t);y=3*sin(t);plot(x,y)(3)x=-3:0.1:3;y=x;[x,y]=meshgrid(x,y);z=x.^2+y.^2;surf(x,y,z)(4)x=-3:0.1:3;y=-3:0.1:13;[x,y]=meshgrid(x,y);z=x.^4+3*x.^2+y.^2-2*x-2*y-2*x.^2.*y+6;surf(x,y,z)(5)t=0:0.01:2*pi;x=sin(t);y=cos(t);z=cos(2*t);plot3(x,y,z)(6)theta=linspace(0,2*pi,50);fai=linspace(0,pi/2,20);[theta,fai]=meshgrid(theta,fai);x=2*sin(fai).*cos(theta);y=2*sin(fai).*sin(theta);z=2*cos(fai);surf(x,y,z)(7)x=linspace(0,pi,100);y1=sin(x);y2=sin(x).*sin(10*x);y3=-sin(x);plot(x,y1,x,y2,x,y3)page45,ex7x=-1.5:0.05:1.5;y=1.1*(x1.1)+x.*(x=1.1).*(x=-1.1)-1.1*(x-1.1);plot(x,y)page45,ex9clear;close;x=-2:0.1:2;y=x;[x,y]=meshgrid(x,y);a=0.5457;b=0.7575;p=a*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y1);p=p+b*exp(-y.^2-6*x.^2).*(x+y-1).*(x+y=1);p=p+a*exp(-0.75*y.^2-3.75*x.^2+1.5*x).*(x+y=-1);mesh(x,y,p)page45,ex10lookforlyapunovhelplyapA=[123;456;780];C=[2-5-22;-5-24-56;-22-56-16];X=lyap(A,C)X=1.0000-1.0000-0.0000-1.00002.00001.0000-0.00001.00007.0000Chapter3Page65Ex1a=[1,2,3];b=[2,4,3];a./b,a.\b,a/b,a\bans=0.50000.50001.0000ans=221ans=0.6552一元方程组x[2,4,3]=[1,2,3]的近似解ans=0000000.66671.33331.0000矩阵方程[1,2,3][x11,x12,x13;x21,x22,x23;x31,x32,x33]=[2,4,3]的特解Page65Ex2(1)A=[41-1;32-6;1-53];b=[9;-2;1];rank(A),rank([A,b])[A,b]为增广矩阵ans=3ans=3可见方程组唯一解x=A\bx=2.38301.48942.0213(2)A=[4-33;32-6;1-53];b=[-1;-2;1];rank(A),rank([A,b])ans=3ans=3可见方程组唯一解x=A\bx=-0.4706-0.29410(3)A=[41;32;1-5];b=[1;1;1];rank(A),rank([A,b])ans=2ans=3可见方程组无解x=A\bx=0.3311-0.1219最小二乘近似解(4)a=[2,1,-1,1;1,2,1,-1;1,1,2,1];b=[123]';%注意b的写法rank(a),rank([a,b])ans=3ans=3rank(a)==rank([a,b])4说明有无穷多解a\bans=1010一个特解Page65Ex3a=[2,1,-1,1;1,2,1,-1;1,1,2,1];b=[1,2,3]';x=null(a),x0=a\bx=-0.62550.6255-0.20850.4170x0=1010通解kx+x0Page65Ex4x0=[0.20.8]';a=[0.990.05;0.010.95];x1=a*x,x2=a^2*x,x10=a^10*xx=x0;fori=1:1000,x=a*x;end,xx=0.83330.1667x0=[0.80.2]';x=x0;fori=1:1000,x=a*x;end,xx=0.83330.1667[v,e]=eig(a)v=0.9806-0.70710.19610.7071e=1.0000000.9400v(:,1)./xans=1.17671.1767成比例,说明x是最大特征值对应的特征向量Page65Ex5用到公式(3.11)(3.12)B=[6,2,1;2.25,1,0.2;3,0.2,1.8];x=[25520]';C=B/diag(x)C=0.24000.40000.05000.09000.20000.01000.12000.04000.0900A=eye(3,3)-CA=0.7600-0.4000-0.0500-0.09000.8000-0.0100-0.1200-0.04000.9100D=[171717]';x=A\Dx=37.569625.786224.7690Page65Ex6(1)a=[41-1;32-6;1-53];det(a),inv(a),[v,d]=eig(a)ans=-94ans=0.2553-0.02130.04260.1596-0.1383-0.22340.1809-0.2234-0.0532v=0.0185-0.9009-0.3066-0.7693-0.1240-0.7248-0.6386-0.41580.6170d=-3.05270003.67600008.3766(2)a=[11-1;02-1;-120];det(a),inv(a),[v,d]=eig(a)ans=1ans=2.0000-2.00001.00001.0000-1.00001.00002.0000-3.00002.0000v=-0.57730.5774+0.0000i0.5774-0.0000i-0.57730.57740.5774-0.57740.5773-0.0000i0.5773+0.0000id=1.00000001.0000+0.0000i0001.0000-0.0000i(3)A=[5765;71087;68109;57910]A=5765710876810957910det(A),inv(A),[v,d]=eig(A)ans=1ans=68.0000-41.0000-17.000010.0000-41.000025.000010.0000-6.0000-17.000010.00005.0000-3.000010.0000-6.0000-3.00002.0000v=0.83040.09330.39630.3803-0.5016-0.30170.61490.5286-0.20860.7603-0.27160.55200.1237-0.5676-0.62540.5209d=0.010200000.843100003.8581000030.2887(4)(以n=5为例)方法一(三个for)n=5;fori=1:n,a(i,i)=5;endfori=1:(n-1),a(i,i+1)=6;endfori=1:(n-1),a(i+1,i)=1;enda方法二(一个for)n=5;a=zeros(n,n);a(1,1:2)=[56];fori=2:(n-1),a(i,[i-1,i,i+1])=[156];enda(n,[n-1n])=[15];a方法

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功