数学实验(MATLAB)课后习题答案教程
- 格式:pdf
- 大小:2.99 MB
- 文档页数:137
实验一 MATLAB 运算基础1. 先求下列表达式的值,然后显示MATLAB 工作空间的使用情况并保存全部变量。
(1) 0122sin851z e =+ (2) 221ln(1)2z x x =++,其中2120.455i x +⎡⎤=⎢⎥-⎣⎦(3) 0.30.330.3sin(0.3)ln , 3.0, 2.9,,2.9,3.022a a e e a z a a --+=++=--(4) 2242011122123t t z t t t t t ⎧≤<⎪=-≤<⎨⎪-+≤<⎩,其中t =0:0.5:2.5 解: M 文件:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2)t=0:0.5:2.5;z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1) 运算结果:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2)t=0:0.5:2.5;z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1)z1 =0.2375z2 =0.7114 - 0.0253i 0.8968 + 0.3658i0.2139 + 0.9343i 1.1541 - 0.0044iz3 =Columns 1 through 40.7388 + 3.1416i 0.7696 + 3.1416i 0.7871 + 3.1416i 0.7913 + 3.1416iColumns 5 through 80.7822 + 3.1416i 0.7602 + 3.1416i 0.7254 + 3.1416i 0.6784 + 3.1416iColumns 9 through 120.6196 + 3.1416i 0.5496 + 3.1416i 0.4688 + 3.1416i 0.3780 + 3.1416iColumns 13 through 160.2775 + 3.1416i 0.1680 + 3.1416i 0.0497 + 3.1416i -0.0771 + 3.1416iColumns 17 through 20-0.2124 + 3.1416i -0.3566 + 3.1416i -0.5104 + 3.1416i -0.6752 + 3.1416iColumns 21 through 24-0.8536 + 3.1416i -1.0497 + 3.1416i -1.2701 + 3.1416i -1.5271 + 3.1416iColumns 25 through 28-1.8436 + 3.1416i -2.2727 + 3.1416i -2.9837 + 3.1416i -37.0245 Columns 29 through 32-3.0017 -2.3085 -1.8971 -1.5978Columns 33 through 36-1.3575 -1.1531 -0.9723 -0.8083Columns 37 through 40-0.6567 -0.5151 -0.3819 -0.2561Columns 41 through 44-0.1374 -0.0255 0.0792 0.1766Columns 45 through 480.2663 0.3478 0.4206 0.4841Columns 49 through 520.5379 0.5815 0.6145 0.6366Columns 53 through 560.6474 0.6470 0.6351 0.6119Columns 57 through 600.5777 0.5327 0.47740.4126Column 610.3388z4 =0 0.2500 0 1.2500 1.0000 2.2500 2. 已知:求下列表达式的值:(1) A+6*B和A-B+I(其中I为单位矩阵)(2) A*B和A.*B(3) A^3和A.^3(4) A/B及B\A(5) [A,B]和[A([1,3],:);B^2]解:M 文件:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]运算结果:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]ans =18 52 -1046 7 10521 53 49ans =12 31 -332 8 840 67 1ans =68 44 62309 -72 596154 -5 241ans =12 102 468 0 2619 -130 49ans =37226 233824 48604247370 149188 60076678688 454142 118820 ans =1728 39304 -6439304 343 65850327 274625 343 ans =16.4000 -13.6000 7.600035.8000 -76.2000 50.200067.0000 -134.0000 68.0000109.4000 -131.2000 322.8000-53.0000 85.0000 -171.0000-61.6000 89.8000 -186.2000ans =12 34 -4 1 3 -134 7 87 2 0 33 65 7 3 -2 7ans =12 34 -43 65 74 5 111 0 1920 -5 403. 设有矩阵A和B(1) 求它们的乘积C。
数学实验练习2.1画出下列常见曲线的图形。
(其中a=1,b=2,c=3)1、立方抛物线3xy=解:x=-5:0.1:0;y=(-x).^(1/3);y=-y;x=0:0.1:5;y=[y,x.^(1/3)];x=[-5:0.1:0,0:0.1:5];plot(x,y)2、高斯曲线2x e=y-解:fplot('exp(-x.^2)',[-5,5])3、笛卡儿曲线)3(13,1333222axy y x t at y t at x =++=+=解:ezplot('x.^3+y.^3-3*x*y',[-5,5])xyx.3+y.3-3 x y = 0或t=-5:0.1:5; x=3*t./(1+t.^2); y=3*t.^2./(1+t.^2); plot(x,y)4、蔓叶线)(1,1322322xa x y t at y t at x -=+=+=解:ezplot('y.^2-x.^3/(1-x)',[-5,5])xyy.2-x.3/(1-x) = 0或t=-5:0.1:5; x=t.^2./(1+t.^2); y=t.^3./(1+t.^2); plot(x,y)5、摆线)cos 1(),sin (t b y t t a x -=-= 解:t=0:0.1:2*pi;x=t-sin(t); y=2*(1-cos(t)); plot(x,y)6、星形线)(sin ,cos 32323233a y x t a y t a x =+== 解:t=0:0.1:2*pi; x=cos(t).^3; y=sin(t).^3;plot(x,y)或ezplot('x.^(2/3)+y.^(2/3)-1',[-1,1])xyx.2/3+y.2/3-1 = 07、螺旋线ct z t b y t a x ===,sin ,cos 解:t=0:0.1:2*pi; x=cos(t); y=2*sin(t); z=3*t; plot3(x,y,z) grid on8、阿基米德螺线θa r = 解:x =0:0.1:2*pi; r=x; polar(x,r)902701809、对数螺线θa e r = 解:x =0:0.1:2*pi; r=exp(x); polar(x,r)90270180010、双纽线))()((2cos 22222222y x a y x a r -=+=θ 解:x=0:0.1:2*pi; r=sqrt(cos(2*x)); polar(x,r)90270或ezplot('(x.^2+y.^2).^2-(x.^2-y.^2)',[-1,1]) grid onxy(x.2+y.2).2-(x.2-y.2) = 011、双纽线)2)((2sin 222222xy a y x a r =+=θ 解:x=0:0.1:2*pi; r=sqrt(sin(2*x)); polar(x,r)90270或ezplot('(x.^2+y.^2).^2-2*x*y',[-1,1]) grid onxy(x.2+y.2).2-2 x y = 012、心形线)cos 1(θ+=a r 解:x =0:0.1:2*pi; r=1+cos(x); polar(x,r)90270练习2.21、求出下列极限值。
实验一 MATLAB 运算基础1、 先求下列表达式得值,然后显示MATLAB 工作空间得使用情况并保存全部变量。
(1) 0122sin 851z e =+(2) 21ln(2z x =+,其中2120.455i x +⎡⎤=⎢⎥-⎣⎦ (3) 0.30.330.3sin(0.3)ln , 3.0, 2.9,,2.9,3.022a a e e a z a a --+=++=--L (4) 2242011122123t t z t t t t t ⎧≤<⎪=-≤<⎨⎪-+≤<⎩,其中t =0:0、5:2、5 解:4、 完成下列操作:(1) 求[100,999]之间能被21整除得数得个数。
(2) 建立一个字符串向量,删除其中得大写字母。
解:(1) 结果:(2)、 建立一个字符串向量 例如:ch='ABC123d4e56Fg9';则要求结果就是:实验二 MATLAB 矩阵分析与处理1、 设有分块矩阵33322322E R A O S ⨯⨯⨯⨯⎡⎤=⎢⎥⎣⎦,其中E 、R 、O 、S 分别为单位矩阵、随机矩阵、零矩阵与对角阵,试通过数值计算验证22E R RS A OS +⎡⎤=⎢⎥⎣⎦。
解: M 文件如下;5、 下面就是一个线性方程组:1231112340.951110.673450.52111456x x x ⎡⎤⎢⎥⎡⎤⎡⎤⎢⎥⎢⎥⎢⎥⎢⎥=⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎣⎦⎣⎦⎢⎥⎢⎥⎣⎦(1) 求方程得解。
(2) 将方程右边向量元素b 3改为0、53再求解,并比较b 3得变化与解得相对变化。
(3) 计算系数矩阵A 得条件数并分析结论。
解: M 文件如下:实验三 选择结构程序设计1、 求分段函数得值。
2226035605231x x x x y x x x x x x x ⎧+-<≠-⎪=-+≤<≠≠⎨⎪--⎩且且及其他用if 语句实现,分别输出x=-5、0,-3、0,1、0,2、0,2、5,3、0,5、0时得y 值。
数学实验答案Chapter 1Page20,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,ex3>> r=2;p=0.5;n=12;>> T=log(r)/n/log(1+0.01*p)Page20,ex4>> x=-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 =24>> x(x1_index)ans =-0.8500>> x(x1_index)=[];f=x.^4-2.^x; 删去绝对值最小的点以求函数绝对值次小的点>> [f2,x2_index]=min(abs(f)) 求另一近似根--函数绝对值次小的点f2 =0.0630x2_index =65>> x(x2_index)ans =1.2500>> z=magic(10)z =92 99 1 8 15 67 74 51 58 4098 80 7 14 16 73 55 57 64 414 81 88 20 22 54 56 63 70 4785 87 19 21 3 60 62 69 71 2886 93 25 2 9 61 68 75 52 3417 24 76 83 90 42 49 26 33 6523 5 82 89 91 48 30 32 39 6679 6 13 95 97 29 31 38 45 7210 12 94 96 78 35 37 44 46 5311 18 100 77 84 36 43 50 27 59>> sum(z)>> sum(diag(z))>> z(:,2)/sqrt(3)>> z(8,:)=z(8,:)+z(3,:)Chapter 2Page 45 ex1先在编辑器窗口写下列M函数,保存为eg2_1.m function [xbar,s]=ex2_1(x)n=length(x);xbar=sum(x)/n;s=sqrt((sum(x.^2)-n*xbar^2)/(n-1));例如>>x=[81 70 65 51 76 66 90 87 61 77];>>[xbar,s]=ex2_1(x)Page 45 ex2s=log(1);n=0;while s<=100n=n+1;s=s+log(1+n);endm=nPage 40 ex3clear;F(1)=1;F(2)=1;k=2;x=0;e=1e-8; a=(1+sqrt(5))/2;while abs(x-a)>ek=k+1;F(k)=F(k-1)+F(k-2); x=F(k)/F(k-1);enda,x,k计算至k=21可满足精度clear;tic;s=0;for i=1:1000000s=s+sqrt(3)/2^i;ends,toctic;s=0;i=1;while i<=1000000s=s+sqrt(3)/2^i;i=i+1;ends,toctic;s=0;i=1:1000000;s=sqrt(3)*sum(1./2.^i);s,tocPage 45 ex5t=0:24;c=[15 14 14 14 14 15 16 18 20 22 23 25 28 ...31 32 31 29 27 25 24 22 20 18 17 16];plot(t,c)Page 45 ex6(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,[-2 2]) (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*(x>1.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+y>1);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, ex10lookfor lyapunovhelp lyap>> A=[1 2 3;4 5 6;7 8 0];C=[2 -5 -22;-5 -24 -56;-22 -56 -16];>> X=lyap(A,C)X =1.0000 -1.0000 -0.0000-1.0000 2.0000 1.0000-0.0000 1.0000 7.0000Chapter 3Page65 Ex1>> a=[1,2,3];b=[2,4,3];a./b,a.\b,a/b,a\bans =0.5000 0.5000 1.0000ans =2 2 1ans =0.6552 一元方程组x[2,4,3]=[1,2,3]的近似解ans =0 0 00 0 00.6667 1.3333 1.0000矩阵方程[1,2,3][x11,x12,x13;x21,x22,x23;x31,x32,x33]=[2,4,3]的特解Page65 Ex 2(1)>> A=[4 1 -1;3 2 -6;1 -5 3];b=[9;-2;1];>> rank(A), rank([A,b]) [A,b]为增广矩阵ans =3ans =3 可见方程组唯一解>> x=A\bx =2.38301.48942.0213(2)>> A=[4 -3 3;3 2 -6;1 -5 3];b=[-1;-2;1];>> rank(A), rank([A,b])ans =3ans =3 可见方程组唯一解>> x=A\bx =-0.4706-0.2941(3)>> A=[4 1;3 2;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=[1 2 3]';%注意b的写法>> rank(a),rank([a,b])ans =3ans =3 rank(a)==rank([a,b])<4说明有无穷多解>> a\bans =110 一个特解Page65 Ex3>> a=[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 =11通解kx+x0Page65 Ex 4>> x0=[0.2 0.8]';a=[0.99 0.05;0.01 0.95];>> x1=a*x, x2=a^2*x, x10=a^10*x>> x=x0;for i=1:1000,x=a*x;end,xx =0.83330.1667>> x0=[0.8 0.2]';>> x=x0;for i=1:1000,x=a*x;end,xx =0.83330.1667>> [v,e]=eig(a)v =0.9806 -0.70710.1961 0.7071e =1.0000 00 0.9400>> v(:,1)./xans =1.17671.1767 成比例,说明x是最大特征值对应的特征向量Page65 Ex5用到公式(3.11)(3.12)>> B=[6,2,1;2.25,1,0.2;3,0.2,1.8];x=[25 5 20]'; >> C=B/diag(x)C =0.2400 0.4000 0.05000.0900 0.2000 0.01000.1200 0.0400 0.0900>> A=eye(3,3)-CA =0.7600 -0.4000 -0.0500-0.0900 0.8000 -0.0100-0.1200 -0.0400 0.9100>> D=[17 17 17]';x=A\Dx =37.569625.786224.7690Page65 Ex 6(1)>> a=[4 1 -1;3 2 -6;1 -5 3];det(a),inv(a),[v,d]=eig(a) ans =-94ans =0.2553 -0.0213 0.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.4158 0.6170d =-3.0527 0 00 3.6760 00 0 8.3766(2)>> a=[1 1 -1;0 2 -1;-1 2 0];det(a),inv(a),[v,d]=eig(a) ans =1ans =2.0000 -2.0000 1.00001.0000 -1.0000 1.00002.0000 -3.0000 2.0000v =-0.5773 0.5774 + 0.0000i 0.5774 - 0.0000i-0.5773 0.5774 0.5774-0.5774 0.5773 - 0.0000i 0.5773 + 0.0000id =1.0000 0 00 1.0000 + 0.0000i 00 0 1.0000 - 0.0000i(3)>> A=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10]A =5 76 57 10 8 76 8 10 95 7 9 10>> det(A),inv(A), [v,d]=eig(A)ans =1ans =68.0000 -41.0000 -17.0000 10.0000-41.0000 25.0000 10.0000 -6.0000-17.0000 10.0000 5.0000 -3.000010.0000 -6.0000 -3.0000 2.0000v =0.8304 0.0933 0.3963 0.3803-0.5016 -0.3017 0.6149 0.5286-0.2086 0.7603 -0.2716 0.55200.1237 -0.5676 -0.6254 0.5209d =0.0102 0 0 00 0.8431 0 00 0 3.8581 00 0 0 30.2887(4)(以n=5为例)方法一(三个for)n=5;for i=1:n, a(i,i)=5;endfor i=1:(n-1),a(i,i+1)=6;endfor i=1:(n-1),a(i+1,i)=1;enda方法二(一个for)n=5;a=zeros(n,n);a(1,1:2)=[5 6];for i=2:(n-1),a(i,[i-1,i,i+1])=[1 5 6];enda(n,[n-1 n])=[1 5];a方法三(不用for)n=5;a=diag(5*ones(n,1));b=diag(6*ones(n-1,1));c=diag(ones(n-1,1));a=a+[zeros(n-1,1),b;zeros(1,n)]+[zeros(1,n);c,zeros(n-1,1)] 下列计算>> det(a)ans =665>> inv(a)ans =0.3173 -0.5865 1.0286 -1.6241 1.9489-0.0977 0.4887 -0.8571 1.3534 -1.62410.0286 -0.1429 0.5429 -0.8571 1.0286-0.0075 0.0376 -0.1429 0.4887 -0.58650.0015 -0.0075 0.0286 -0.0977 0.3173>> [v,d]=eig(a)v =-0.7843 -0.7843 -0.9237 0.9860 -0.92370.5546 -0.5546 -0.3771 -0.0000 0.3771-0.2614 -0.2614 0.0000 -0.1643 0.00000.0924 -0.0924 0.0628 -0.0000 -0.0628-0.0218 -0.0218 0.0257 0.0274 0.0257d =0.7574 0 0 0 00 9.2426 0 0 00 0 7.4495 0 00 0 0 5.0000 00 0 0 0 2.5505Page65 Ex 7(1)>> a=[4 1 -1;3 2 -6;1 -5 3];[v,d]=eig(a)v =0.0185 -0.9009 -0.3066-0.7693 -0.1240 -0.7248-0.6386 -0.4158 0.6170d =-3.0527 0 00 3.6760 00 0 8.3766>> det(v)ans =-0.9255 %v行列式正常, 特征向量线性相关,可对角化>> inv(v)*a*v 验算ans =-3.0527 0.0000 -0.00000.0000 3.6760 -0.0000-0.0000 -0.0000 8.3766>> [v2,d2]=jordan(a) 也可用jordanv2 =0.0798 0.0076 0.91270.1886 -0.3141 0.1256-0.1605 -0.2607 0.4213 特征向量不同d2 =8.3766 0 00 -3.0527 - 0.0000i 00 0 3.6760 + 0.0000i>> v2\a*v2ans =8.3766 0 0.00000.0000 -3.0527 0.00000.0000 0.0000 3.6760>> v(:,1)./v2(:,2) 对应相同特征值的特征向量成比例ans =2.44912.44912.4491(2)>> a=[1 1 -1;0 2 -1;-1 2 0];[v,d]=eig(a)v =-0.5773 0.5774 + 0.0000i 0.5774 - 0.0000i-0.5773 0.5774 0.5774-0.5774 0.5773 - 0.0000i 0.5773 + 0.0000id =1.0000 0 00 1.0000 + 0.0000i 00 0 1.0000 - 0.0000i>> det(v)ans =-5.0566e-028 -5.1918e-017i v的行列式接近0, 特征向量线性相关,不可对角化>> [v,d]=jordan(a)v =1 0 11 0 01 -1 0d =1 1 00 1 10 0 1 jordan标准形不是对角的,所以不可对角化(3)>> A=[5 7 6 5;7 10 8 7;6 8 10 9;5 7 9 10]A =5 76 57 10 8 76 8 10 95 7 9 10>> [v,d]=eig(A)v =0.8304 0.0933 0.3963 0.3803-0.5016 -0.3017 0.6149 0.5286-0.2086 0.7603 -0.2716 0.55200.1237 -0.5676 -0.6254 0.5209d =0.0102 0 0 00 0.8431 0 00 0 3.8581 00 0 0 30.2887>> inv(v)*A*vans =0.0102 0.0000 -0.0000 0.00000.0000 0.8431 -0.0000 -0.0000-0.0000 0.0000 3.8581 -0.0000-0.0000 -0.0000 0 30.2887本题用jordan不行, 原因未知(4)参考6(4)和7(1)Page65 Exercise 8只有(3)对称, 且特征值全部大于零, 所以是正定矩阵. Page65 Exercise 9(1)>> a=[4 -3 1 3;2 -1 3 5;1 -1 -1 -1;3 -2 3 4;7 -6 -7 0]>> rank(a)ans =3>> rank(a(1:3,:))ans =2>> rank(a([1 2 4],:)) 1,2,4行为最大无关组ans =3>> b=a([1 2 4],:)';c=a([3 5],:)';>> b\c 线性表示的系数ans =0.5000 5.0000-0.5000 1.00000 -5.0000Page65 Exercise 10>> a=[1 -2 2;-2 -2 4;2 4 -2]>> [v,d]=eig(a)v =0.3333 0.9339 -0.12930.6667 -0.3304 -0.6681-0.6667 0.1365 -0.7327d =-7.0000 0 00 2.0000 00 0 2.0000>> v'*vans =1.0000 0.0000 0.00000.0000 1.0000 00.0000 0 1.0000 v确实是正交矩阵Page65 Exercise 11设经过6个电阻的电流分别为i1, ..., i6. 列方程组如下20-2i1=a; 5-3i2=c; a-3i3=c; a-4i4=b; c-5i5=b; b-3i6=0;i1=i3+i4;i5=i2+i3;i6=i4+i5;计算如下>> A=[1 0 0 2 0 0 0 0 0;0 0 1 0 3 0 0 0 0;1 0 -1 0 0 -3 0 0 0; 1 -1 0 0 0 0 -4 0 0;0 -1 1 0 0 0 0 -5 0;0 1 0 0 0 0 0 0 -3; 0 0 0 1 0 -1 -1 0 0;0 0 0 0 -1 -1 0 1 0;0 0 0 0 0 0 -1 -1 1];>>b=[20 5 0 0 0 0 0 0 0]'; A\bans =13.34536.44018.54203.3274-1.18071.60111.72630.42042.1467Page65 Exercise 12>> A=[1 2 3;4 5 6;7 8 0];>> left=sum(eig(A)), right=sum(trace(A))left =6.0000right =6>> left=prod(eig(A)), right=det(A) 原题有错, (-1)^n应删去left =27.0000right =27>> fA=(A-p(1)*eye(3,3))*(A-p(2)*eye(3,3))*(A-p(3)*eye(3,3)) fA =1.0e-012 *0.0853 0.1421 0.02840.1421 0.1421 0-0.0568 -0.1137 0.1705>> norm(fA) f(A)范数接近0ans =2.9536e-013Chapter 4Page84 Exercise 1(1)roots([1 1 1])(2)roots([3 0 -4 0 2 -1])(3)p=zeros(1,24);p([1 17 18 22])=[5 -6 8 -5];roots(p)(4)p1=[2 3];p2=conv(p1, p1);p3=conv(p1, p2);p3(end)=p3(end)-4; %原p3最后一个分量-4roots(p3)Page84 Exercise 2fun=inline('x*log(sqrt(x^2-1)+x)-sqrt(x^2-1)-0.5*x');fzero(fun,2)Page84 Exercise 3fun=inline('x^4-2^x');fplot(fun,[-2 2]);grid on;fzero(fun,-1),fzero(fun,1),fminbnd(fun,0.5,1.5)Page84 Exercise 4fun=inline('x*sin(1/x)','x');fplot(fun, [-0.1 0.1]);x=zeros(1,10);for i=1:10, x(i)=fzero(fun,(i-0.5)*0.01);end;x=[x,-x]Page84 Exercise 5fun=inline('[9*x(1)^2+36*x(2)^2+4*x(3)^2-36;x(1)^2-2*x(2)^2-20*x(3);16*x(1)-x(1)^3-2*x(2)^ 2-16*x(3)^2]','x');[a,b,c]=fsolve(fun,[0 0 0])Page84 Exercise 6fun=@(x)[x(1)-0.7*sin(x(1))-0.2*cos(x(2)),x(2)-0.7*cos(x(1))+0.2*sin(x(2))];[a,b,c]=fsolve(fun,[0.5 0.5])Page84 Exercise 7clear; close; t=0:pi/100:2*pi;x1=2+sqrt(5)*cos(t); y1=3-2*x1+sqrt(5)*sin(t);x2=3+sqrt(2)*cos(t); y2=6*sin(t);plot(x1,y1,x2,y2); grid on; 作图发现4个解的大致位置,然后分别求解y1=fsolve('[(x(1)-2)^2+(x(2)-3+2*x(1))^2-5,2*(x(1)-3)^2+(x(2)/3)^2-4]',[1.5,2])y2=fsolve('[(x(1)-2)^2+(x(2)-3+2*x(1))^2-5,2*(x(1)-3)^2+(x(2)/3)^2-4]',[1.8,-2])y3=fsolve('[(x(1)-2)^2+(x(2)-3+2*x(1))^2-5,2*(x(1)-3)^2+(x(2)/3)^2-4]',[3.5,-5])y4=fsolve('[(x(1)-2)^2+(x(2)-3+2*x(1))^2-5,2*(x(1)-3)^2+(x(2)/3)^2-4]',[4,-4])Page84 Exercise 8(1)clear;fun=inline('x.^2.*sin(x.^2-x-2)');fplot(fun,[-2 2]);grid on; 作图观察x(1)=-2;x(3)=fminbnd(fun,-1,-0.5);x(5)=fminbnd(fun,1,2);fun2=inline('-x.^2.*sin(x.^2-x-2)');x(2)=fminbnd(fun2,-2,-1);x(4)=fminbnd(fun2,-0.5,0.5);x(6)=2feval(fun,x)答案: 以上x(1)(3)(5)是局部极小,x(2)(4)(6)是局部极大,从最后一句知道x(1)全局最小,x(2)最大。
数学实验(M A T L A B版韩明版)5.1,5.3,5.5,5.6部分答案-CAL-FENGHAI-(2020YEAR-YICAI)_JINGBIAN练习5.1B的分布规律和分布函数的图形,通过观1、仿照本节的例子,分别画出二项分布()7.0,20察图形,进一步理解二项分布的性质。
解:分布规律编程作图:>> x=0:1:20;y=binopdf(x,20,0.7);>> plot(x,y,'*')图像:yx分布函数编程作图:>> x=0:0.01:20;>>y=binocdf(x,20,0.7)>> plot(x,y)图像:1x观察图像可知二项分布规律图像像一条抛物线,其分布函数图像呈阶梯状。
2、仿照本节的例子,分别画出正态分布()25,2N的概率密度函数和分布函数的图形,通过观察图形,进一步理解正态分布的性质。
解:概率密度函数编程作图:>> x=-10:0.01:10;>> y=normpdf(x,2,5);>> plot(x,y)图像:00.010.020.030.040.050.060.070.08x y分布函数编程作图:>> x=-10:0.01:10;>> y=normcdf(x,2,5);>> plot(x,y)图像:01x y观察图像可知正态分布概率密度函数图像像抛物线,起分布函数图像呈递增趋势。
3、设()1,0~N X ,通过分布函数的调用计算{}11<<-X P ,{}22<<-X P , {}33<<-X P .解:编程求解:>> x1=normcdf(1)-normcdf(-1),x2=normcdf(2)-normcdf(-2),x3=normcdf(3)-normcdf(-3) x1 = 0.6827x2 = 0.9545x3 = 0.9973即:{}6827.011=<<-X P ,{}9545.022=<<-X P ,{}9973.033=<<-X P .4、设()7.0,20~B X ,通过分布函数的调用计算{}10=X P 与{}10<X P .解:编程求解:>> x1=binopdf(10,20,0.7),x2=binocdf(10,20,0.7)-binopdf(10,20,0.7) x1 = 0.0308x2 = 0.0171即:{}0308.010==X P ,{}0171.010=<X P5、设()8~P X ,求:(1){}4≤X P ;(2){}52≤<X P .解:(1)编程求解:>> p=poisscdf(4,8)p = 0.0996即:{}0996.04=≤X P(2)编程求解:>> p=poisscdf(5,8)-poisscdf(2,8)p = 0.1775即:{}1775.052=≤<X P6、(1)设()1,0~N X ,求01.0z ;(2)对2χ分布,求()8205.0χ;(3)对()1305.0t ;(4)对F 分布,求()10,1505.0F 。
实验一 MATLAB 运算基础1. 先求下列表达式的值,然后显示MATLAB 工作空间的使用情况并保存全部变量。
(1) 0122sin851z e =+ (2) 221ln(1)2z x x =++,其中2120.455i x +⎡⎤=⎢⎥-⎣⎦ (3) 0.30.330.3sin(0.3)ln , 3.0, 2.9,,2.9,3.022a a e e a z a a --+=++=-- (4) 2242011122123t t z t t t t t ⎧≤<⎪=-≤<⎨⎪-+≤<⎩,其中t =0:0.5:2.5 解: M 文件:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2) t=0:0.5:2.5; z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1)运算结果:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2)t=0:0.5:2.5;z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1) z1 =0.2375z2 =0.7114 - 0.0253i 0.8968 + 0.3658i0.2139 + 0.9343i 1.1541 - 0.0044i2. 已知:1234413134787,2033657327A B --⎡⎤⎡⎤⎢⎥⎢⎥==⎢⎥⎢⎥⎢⎥⎢⎥-⎣⎦⎣⎦求下列表达式的值:(1) A+6*B 和A-B+I (其中I 为单位矩阵)(2) A*B 和A.*B(3) A^3和A.^3(4) A/B 及B\A(5) [A,B]和[A([1,3],:);B^2]解: M 文件:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]运算结果:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]ans =18 52 -1046 7 10521 53 49ans =12 31 -332 8 840 67 1 ans =68 44 62309 -72 596154 -5 241 ans =12 102 468 0 2619 -130 49 ans =37226 233824 48604247370 149188 60076678688 454142 118820 ans =1728 39304 -6439304 343 65850327 274625 343 ans =16.4000 -13.6000 7.600035.8000 -76.2000 50.200067.0000 -134.0000 68.0000ans =109.4000 -131.2000 322.8000-53.0000 85.0000 -171.0000-61.6000 89.8000 -186.2000ans =12 34 -4 1 3 -134 7 87 2 0 33 65 7 3 -2 7 ans =12 34 -43 65 74 5 111 0 1920 -5 403. 设有矩阵A和B1234530166789101769,111213141502341617181920970212223242541311A B ⎡⎤⎡⎤⎢⎥⎢⎥-⎢⎥⎢⎥⎢⎥⎢⎥==-⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎣⎦⎣⎦ (1) 求它们的乘积C 。
实验一 MATLAB 运算基础1. 先求下列表达式的值,然后显示MATLAB 工作空间的使用情况并保存全部变量。
(1) 0122sin851z e =+ (2) 221ln(1)2z x x =++,其中2120.455i x +⎡⎤=⎢⎥-⎣⎦(3) 0.30.330.3sin(0.3)ln , 3.0, 2.9,,2.9,3.022a a e e a z a a --+=++=--(4) 2242011122123t t z t t t t t ⎧≤<⎪=-≤<⎨⎪-+≤<⎩,其中t =0:0.5:2.5 解: M 文件:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2)t=0:0.5:2.5;z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1) 运算结果:z1=2*sin(85*pi/180)/(1+exp(2))x=[2 1+2*i;-.45 5];z2=1/2*log(x+sqrt(1+x^2))a=-3.0:0.1:3.0;z3=(exp(0.3.*a)-exp(-0.3.*a))./2.*sin(a+0.3)+log((0.3+a)./2)t=0:0.5:2.5;z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t.^2-1)+(t>=2&t<3) .*(t.^2-2*t+1)z1 =0.2375z2 =0.7114 - 0.0253i 0.8968 + 0.3658i0.2139 + 0.9343i 1.1541 - 0.0044iz3 =Columns 1 through 40.7388 + 3.1416i 0.7696 + 3.1416i 0.7871 + 3.1416i 0.7913 + 3.1416iColumns 5 through 80.7822 + 3.1416i 0.7602 + 3.1416i 0.7254 + 3.1416i 0.6784 + 3.1416iColumns 9 through 120.6196 + 3.1416i 0.5496 + 3.1416i 0.4688 + 3.1416i 0.3780 + 3.1416iColumns 13 through 160.2775 + 3.1416i 0.1680 + 3.1416i 0.0497 + 3.1416i -0.0771 + 3.1416iColumns 17 through 20-0.2124 + 3.1416i -0.3566 + 3.1416i -0.5104 + 3.1416i -0.6752 + 3.1416iColumns 21 through 24-0.8536 + 3.1416i -1.0497 + 3.1416i -1.2701 + 3.1416i -1.5271 + 3.1416iColumns 25 through 28-1.8436 + 3.1416i -2.2727 + 3.1416i -2.9837 + 3.1416i -37.0245 Columns 29 through 32-3.0017 -2.3085 -1.8971 -1.5978Columns 33 through 36-1.3575 -1.1531 -0.9723 -0.8083Columns 37 through 40-0.6567 -0.5151 -0.3819 -0.2561Columns 41 through 44-0.1374 -0.0255 0.0792 0.1766Columns 45 through 480.2663 0.3478 0.4206 0.4841Columns 49 through 520.5379 0.5815 0.6145 0.6366Columns 53 through 560.6474 0.6470 0.6351 0.6119Columns 57 through 600.5777 0.5327 0.47740.4126Column 610.3388z4 =0 0.2500 0 1.2500 1.0000 2.2500 2. 已知:求下列表达式的值:(1) A+6*B和A-B+I(其中I为单位矩阵)(2) A*B和A.*B(3) A^3和A.^3(4) A/B及B\A(5) [A,B]和[A([1,3],:);B^2]解:M 文件:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]运算结果:A=[12 34 -4;34 7 87;3 65 7];B=[1 3 -1;2 0 3;3 -2 7]; A+6.*BA-B+eye(3)A*BA.*BA^3A.^3A/BB\A[A,B][A([1,3],:);B^2]ans =18 52 -1046 7 10521 53 49ans =12 31 -332 8 840 67 1ans =68 44 62309 -72 596154 -5 241ans =12 102 468 0 2619 -130 49ans =37226 233824 48604247370 149188 60076678688 454142 118820 ans =1728 39304 -6439304 343 65850327 274625 343 ans =16.4000 -13.6000 7.600035.8000 -76.2000 50.200067.0000 -134.0000 68.0000109.4000 -131.2000 322.8000-53.0000 85.0000 -171.0000-61.6000 89.8000 -186.2000ans =12 34 -4 1 3 -134 7 87 2 0 33 65 7 3 -2 7ans =12 34 -43 65 74 5 111 0 1920 -5 403. 设有矩阵A和B(1) 求它们的乘积C。
第一次练习教学要求:熟练掌握Matlab 软件的基本命令和操作,会作二维、三维几何图形,能够用Matlab 软件解决微积分、线性代数与解析几何中的计算问题。
补充命令vpa(x,n) 显示x 的n 位有效数字,教材102页fplot(‘f(x)’,[a,b]) 函数作图命令,画出f(x)在区间[a,b]上的图形 在下面的题目中m 为你的学号的后3位(1-9班)或4位(10班以上) 1.1 计算30sin limx mx mx x →-与3sin limx mx mxx →∞- syms xlimit((902*x-sin(902*x))/x^3) ans =366935404/3limit((902*x-sin(902*x))/x^3,inf)//inf 的意思 ans = 0 1.2 cos1000xmxy e =,求''y syms xdiff(exp(x)*cos(902*x/1000),2)//diff 及其后的2的意思 ans =(46599*cos((451*x)/500)*exp(x))/250000 - (451*sin((451*x)/500)*exp(x))/250 1.3 计算2211x y edxdy +⎰⎰dblquad(@(x,y) exp(x.^2+y.^2),0,1,0,1)//双重积分 ans = 2.13941.4 计算4224x dx m x +⎰ syms xint(x^4/(902^2+4*x^2))//不定积分 ans =(91733851*atan(x/451))/4 - (203401*x)/4 + x^3/12 1.5 (10)cos ,x y e mx y =求//高阶导数syms xdiff(exp(x)*cos(902*x),10) ans =-356485076957717053044344387763*cos(902*x)*exp(x)-3952323024277642494822005884*sin(902*x)*exp(x)1.6 0x =的泰勒展式(最高次幂为4).syms xtaylor(sqrt(902/1000+x),5,x)//泰勒展式 ans =-(9765625*451^(1/2)*500^(1/2)*x^4)/82743933602 +(15625*451^(1/2)*500^(1/2)*x^3)/91733851-(125*451^(1/2)*500^(1/2)*x^2)/406802 + (451^(1/2)*500^(1/2)*x)/902 +(451^(1/2)*500^(1/2))/500 1.7 Fibonacci 数列{}n x 的定义是121,1x x ==12,(3,4,)n n n x x x n --=+=用循环语句编程给出该数列的前20项(要求将结果用向量的形式给出)。
数学实验练习2.1画出下列常见曲线的图形。
(其中a=1,b=2,c=3)1、立方抛物线3xy=解:x=-5:0.1:0;y=(-x).^(1/3);y=-y;x=0:0.1:5;y=[y,x.^(1/3)];x=[-5:0.1:0,0:0.1:5];plot(x,y)2、高斯曲线2x e=y-解:fplot('exp(-x.^2)',[-5,5])3、笛卡儿曲线)3(13,1333222axy y x t at y t at x =++=+=解:ezplot('x.^3+y.^3-3*x*y',[-5,5])xyx.3+y.3-3 x y = 0或t=-5:0.1:5; x=3*t./(1+t.^2); y=3*t.^2./(1+t.^2); plot(x,y)4、蔓叶线)(1,1322322xa x y t at y t at x -=+=+=解:ezplot('y.^2-x.^3/(1-x)',[-5,5])xyy.2-x.3/(1-x) = 0或t=-5:0.1:5; x=t.^2./(1+t.^2); y=t.^3./(1+t.^2); plot(x,y)5、摆线)cos 1(),sin (t b y t t a x -=-= 解:t=0:0.1:2*pi;x=t-sin(t); y=2*(1-cos(t)); plot(x,y)6、星形线)(sin ,cos 32323233a y x t a y t a x =+== 解:t=0:0.1:2*pi; x=cos(t).^3; y=sin(t).^3;plot(x,y)或ezplot('x.^(2/3)+y.^(2/3)-1',[-1,1])xyx.2/3+y.2/3-1 = 07、螺旋线ct z t b y t a x ===,sin ,cos 解:t=0:0.1:2*pi; x=cos(t); y=2*sin(t); z=3*t; plot3(x,y,z) grid on8、阿基米德螺线θa r = 解:x =0:0.1:2*pi; r=x; polar(x,r)902701809、对数螺线θa e r = 解:x =0:0.1:2*pi; r=exp(x); polar(x,r)90270180010、双纽线))()((2cos 22222222y x a y x a r -=+=θ 解:x=0:0.1:2*pi; r=sqrt(cos(2*x)); polar(x,r)90270或ezplot('(x.^2+y.^2).^2-(x.^2-y.^2)',[-1,1]) grid onxy(x.2+y.2).2-(x.2-y.2) = 011、双纽线)2)((2sin 222222xy a y x a r =+=θ 解:x=0:0.1:2*pi; r=sqrt(sin(2*x)); polar(x,r)90270或ezplot('(x.^2+y.^2).^2-2*x*y',[-1,1]) grid onxy(x.2+y.2).2-2 x y = 012、心形线)cos 1(θ+=a r 解:x =0:0.1:2*pi; r=1+cos(x); polar(x,r)90270练习2.21、求出下列极限值。
东北大学《MATLAB语言与应用》实验东北大学MATLAB实验课习题答案第一部分MATLAB语言编程、科学绘图与基本数学问题求解2、>> A=[1,2,3,4;4,3,2,1;2,3,4,1;3,2,4,1]A =1 2 3 44 3 2 12 3 4 13 24 1B=[1+4j,2+3j,3+2j,4+1j;4+1j,3+2j,2+3j,1+4j;2+3j,3+2j,4+1j,1+4j;3+2j,2+3j,4+1j,1+4j]B =1.0000 + 4.0000i2.0000 +3.0000i 3.0000 + 2.0000i4.0000 + 1.0000i4.0000 + 1.0000i 3.0000 + 2.0000i 2.0000 + 3.0000i 1.0000 + 4.0000i2.0000 +3.0000i 3.0000 + 2.0000i4.0000 + 1.0000i 1.0000 + 4.0000i3.0000 + 2.0000i 2.0000 + 3.0000i4.0000 + 1.0000i 1.0000 + 4.0000i >> A(5,6)=5A =1 2 3 4 0 04 3 2 1 0 02 3 4 1 0 03 24 1 0 00 0 0 0 0 53、A=magic(8)A =64 2 3 61 60 6 7 579 55 54 12 13 51 50 1617 47 46 20 21 43 42 2440 26 27 37 36 30 31 3332 34 35 29 28 38 39 2541 23 22 44 45 19 18 4849 15 14 52 53 11 10 568 58 59 5 4 62 63 1 >> B=A(2:2:end,:)B =9 55 54 12 13 51 50 1640 26 27 37 36 30 31 3341 23 22 44 45 19 18 488 58 59 5 4 62 63 1 4.i=0:63;s=sum(2.^i)s =1.8447e+0195、(1) >> z=sin(1./t);Warning: Divide by zero.>> plot(t,z)-1-0.8-0.6-0.4-0.20.20.40.60.81-1-0.8-0.6-0.4-0.200.20.40.60.81(2)>> t=[-pi:0.05:-1.8,-1.799:.001:-1.2,-1.2:0.05:1.2,1.201:0.001:1.8,1.81:0.05:pi]; >> y=sin(tan(t))-tan(sin(t)); >> plot(t,y)-4-3-2-101234-3-2-11236.三视图>> surf(x,y,z),shading flat;zlim([0,15])>> xx=[-2:.1:-1.2,-1,1:0.02:-0.9,-0.8:0.1:0.8,0.9:0.02:1.1,1.2:0.1:2]; >> yy=[-1:0.1:-0.2,-0.1:0.02:0.1,0.2:.1:1];>> [x,y]=meshgrid(xx,yy);>> subplot(224),surf(x,y,z)>> subplot(221),surf(x,y,z),view(0,90);>> subplot(222),surf(x,y,z),view(90,0);>> subplot(223),surf(x,y,z),view(0,0);1-2-1012-1-0.500.51-1-0.500.510204060-2-11202040607.(1)>> syms x;f=(3.^x+9.^x)^(1./x);L=limit(f,x,inf) L = 9(2)>>syms x y;f=x*y/(sqrt(x*y+1)-1);L1=limit(limit(f,x,0),y,0) L1 = 2 (3)>> syms x y;>> f=(1-cos(x^2+y^2))/((x^2+y^2)*exp(x^2+y^2)); >> L=limit(limit(f,x,0),y,0) L = 08.先建立M文件:function result=paradiff(y,x,t,n)if mod(n,1)~=0,error('n should positive integer,please correct') elseif n==1,result=diff(y,t)/diff(x,t);else,result=diff(paradiff(y,x,t,n-1),t)/diff(x,t);end,end然后调用函数:>> syms t;x=log(cos(t));y=cos(t)-t*sin(t);>> f=paradiff(y,x,t,1);>> [n,d]=numden(f);>> F=simple(n)/simple(d)F =(2*sin(t)+t*cos(t))*cos(t)/sin(t)>> syms t;x=log(cos(t));y=cos(t)-t*sin(t);>> f=paradiff(y,x,t,1);>> syms t;x=log(cos(t));y=cos(t)-t*sin(t);>> f=paradiff(y,x,t,2);>> [n,d]=numden(f);>> F=simple(n)/simple(d)F =-cos(t)*(3*cos(t)^2*sin(t)+cos(t)^3*t-2*sin(t)-2*t*cos(t))/sin(t)^3 >> subs(F,t,pi/3)ans =1.53879.>> syms x y t;>> f=exp(-t^2);>> I=simple(int(f,t,0,x*y))I =1/2*pi^(1/2)*erf(x*y)>> F=x/y*diff(I,x,2)-2*diff(diff(I,x),y)+diff(I,y,2)F =2*x^2*y^2*exp(-x^2*y^2)-2*exp(-x^2*y^2)-2*x^3*y*exp(-x^2*y^2) >> K=simple(F)K =-2*exp(-x^2*y^2)*(-x^2*y^2+1+x^3*y)10.(1)>> syms n;>> S=symsum(1/((2*n)^2-1),n,1,inf)S =1/2(2)>> syms k n>> limit(n*symsum(1/(n^2+k*pi),k,1,n),n,inf)ans =111.(1)>> syms t;>> syms a positive;>> x=a*(cos(t)+t*sin(t));>> y=a*(sin(t)-t*cos(t));>> I=int((x^2+y^2)*sqrt(diff(x,t)^2+diff(y,t)^2),t,0,2*pi)I =2*a^3*pi^2+4*a^3*pi^4(2)>> syms t;>> syms a b c positive;>> x=c/a*cos(t);>> y=c/b*sin(t);>> F=[y*x^3+exp(y),x*y^3+x*exp(y)-2*y];>> ds=[diff(x,t);diff(y,t)];>> I=int(F*ds,t,pi,0)I =2/15*c*(-2*c^4+15*b^4)/a/b^412.首先编写M程序:function A=vander(v)n=length(v);v=v(:);A=sym(ones(n));for j=n-1:-1:1,A(:,j)=v.*A(:,j+1);end>> syms a b c d e;>> A=[a,b,c,d,e];>> V=vander(A)V =[ a^4, a^3, a^2, a, 1][ b^4, b^3, b^2, b, 1][ c^4, c^3, c^2, c, 1][ d^4, d^3, d^2, d, 1][ e^4, e^3, e^2, e, 1]>> det(V),simple(ans)ans =(c-d)*(b-d)*(b-c)*(a-d)*(a-c)*(a-b)*(-d+e)*(e-c)*(e-b)*(e-a) 13.>> A=[-2,0.5,-0.5,0.5;0,-1.5,0.5,-0.5;2,0.5,-4.5,0.5;2,1,-2,-2]; >> [V J]=jordan(sym(A))V =[ 0, 1/2, 1/2, -1/4][ 0, 0, 1/2, 1][ 1/4, 1/2, 1/2, -1/4][ 1/4, 1/2, 1, -1/4]J =[ -4, 0, 0, 0][ 0, -2, 1, 0][ 0, 0, -2, 1][ 0, 0, 0, -2]14.先编写M文件:function X=lyap(A,B,C)if nargin==2,C=B;B=A';end[nr,nc]=size(C);A0=kron(A,eye(nc))+kron(eye(nr),B');tryC1=C';x0=-inv(A0)*C1(:);X=reshape(x0,nc,nr)';catch,error('singular matrix found.'),end数值解为:>> A=[3,-6,-4,0,5;1,4,2,-2,4;-6,3,-6,7,3;-13,10,0,-11,0;0,4,0,3,4]; >> B=[3,-2,1;-2,-9,2;-2,-1,9];>> C=[-2,1,-1;4,1,2;5,-6,1;6,-4,-4;-6,6,-3];>> X=lyap(A,B,C)X =-4.0569 -14.5128 1.56530.0356 25.0743 -2.74089.4886 25.9323 -4.41772.6969 21.6450 -2.88517.7229 31.9100 -3.7634>> norm(A*X+X*B+C)ans =3.9870e-013解析解为:>> X=lyap(sym(A),B,C)X =[ -434641749950/107136516451, -4664546747350/321409549353, 503105815912/321409549353][ 3809507498/107136516451, 8059112319373/321409549353, -880921527508/321409549353][ 1016580400173/107136516451, 8334897743767/321409549353, -1419901706449/321409549353][ 288938859984/107136516451, 6956912657222/321409549353, -927293592476/321409549353][ 827401644798/107136516451, 10256166034813/321409549353, -1209595497577/321409549353]>> A*X+X*B+Cans =[ 0, 0, 0][ 0, 0, 0][ 0, 0, 0][ 0, 0, 0][ 0, 0, 0]15.(1)>> A=[-4.5,0,0.5,-1.5;-0.5,-4,0.5,-0.5;1.5,1,-2.5,1.5;0,-1,-1,-3];>> A=sym(A);syms t;>> expm(A*t)ans =[ 1/2*exp(-5*t)+1/2*exp(-3*t)-1/2*t*exp(-3*t)+1/2*t^2*exp(-3*t), t*exp(-3*t)-1/2*exp(-3*t)+1/2*exp(-5*t),1/2*t^2*exp(-3*t)+1/2*t*exp(-3*t),1/2*t^2*exp(-3*t)-1/2*t*exp(-3*t)-1/2*exp(-3*t)+1/2*exp(-5*t)][ -1/2*exp(-3*t)+1/2*exp(-5*t)+1/2*t*exp(-3*t), 1/2*exp(-5*t)+1/2*exp(-3*t),1/2*t*exp(-3*t),-1/2*exp(-3*t)+1/2*exp(-5*t)+1/2*t*exp(-3*t)][ 1/2*exp(-3*t)-1/2*exp(-5*t)+1/2*t*exp(-3*t), 1/2*exp(-3*t)-1/2*exp(-5*t),1/2*t*exp(-3*t)+exp(-3*t),1/2*exp(-3*t)-1/2*exp(-5*t)+1/2*t*exp(-3*t)][ -1/2*t^2*exp(-3*t), -t*exp(-3*t), -t*exp(-3*t)-1/2*t^2*exp(-3*t), exp(-3*t)-1/2*t^2*exp(-3*t)](2)编写M程序function F=funm(A,fun,x)[V,J]=jordan(A);v1=[0,diag(J,1)'];v2=[find(v1==0),length(v1)+1];for i=1:length(v2)-1v_lambda(i)=J(v2(i),v2(i));v_n(i)=v2(i+1)-v2(i);endm=length(v_lambda);F=sym([]);for i=1:mJ1=J(v2(i):v2(i)+v_n(i)-1,v2(i):v2(i)+v_n(i)-1);fJ=funJ(J1,fun,x);F=diagm(F,fJ);endF=V*F*inv(V);function fJ=funJ(J,fun,x)lam=J(1,1);f1=fun;fJ=subs(fun,x,lam)*eye(size(J));H=diag(diag(J,1),1);H1=H;for i=2:length(J)f1=diff(f1,x);a1=subs(f1,x,lam);fJ=fJ+a1*H1;H1=H1*H/i;endfunction A=diagm(A1,A2)A=A1;[n,m]=size(A);[n1,m1]=size(A2);A(n+1:n+n1,m+1:m+m1)=A2;>> A=[-4.5,0,0.5,-1.5;-0.5,-4,0.5,-0.5;1.5,1,-2.5,1.5;0,-1,-1,-3];>> syms x t;>> A1=funm(sym(A),sin(x*t),x)A1 =[ -1/2*sin(5*t)+1/2*sin(3*t)*t^2-1/2*cos(3*t)*t-1/2*sin(3*t), -1/2*sin(5*t)+cos(3*t)*t+1/2*sin(3*t),1/2*cos(3*t)*t+1/2*sin(3*t)*t^2,-1/2*sin(5*t)+1/2*sin(3*t)+1/2*sin(3*t)*t^2-1/2*cos(3*t)*t][ -1/2*sin(5*t)+1/2*cos(3*t)*t+1/2*sin(3*t), -1/2*sin(5*t)-1/2*sin(3*t),1/2*cos(3*t)*t, -1/2*sin(5*t)+1/2*cos(3*t)*t+1/2*sin(3*t)] [ 1/2*sin(5*t)+1/2*cos(3*t)*t-1/2*sin(3*t), 1/2*sin(5*t)-1/2*sin(3*t),-sin(3*t)+1/2*cos(3*t)*t,1/2*sin(5*t)+1/2*cos(3*t)*t-1/2*sin(3*t)][ -1/2*sin(3*t)*t^2, -cos(3*t)*t, -cos(3*t)*t-1/2*sin(3*t)*t^2, -sin(3*t)-1/2*sin(3*t)*t^2](3)>> A=[-4.5,0,0.5,-1.5;-0.5,-4,0.5,-0.5;1.5,1,-2.5,1.5;0,-1,-1,-3];>> syms x t;>> A1=funm(sym(A),exp(x*t)*sin(x^2*exp(x*t)*t),x)A1 =[ 1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t^2*exp(-3*t)*sin(9*exp(-3*t)*t)+t*exp(-3* t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*exp(-3* t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp( -3*t)*t-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))-1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)-1/2*e xp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9* exp(-3*t)*t),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+t*exp(-3*t)*sin(9*exp(-3*t)*t)+exp(-3*t)*cos(9* exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*exp(-3*t)*t),1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)* t+9*t^2*exp(-3*t))+1/2*t^2*exp(-3*t)*sin(9*exp(-3*t)*t)+t*exp(-3*t)*cos(9*exp(-3 *t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp(-3*t)*t-12*t^2 *exp(-3*t)+9*t^3*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)-1/2*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*t^2*exp(-3 *t)*sin(9*exp(-3*t)*t)+t*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3 *t))-1/2*exp(-3*t)*sin(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp(-3*t)*t-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))-1/2*t*ex p(-3*t)*sin(9*exp(-3*t)*t)-1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2* exp(-3*t))][1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t) *cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*exp(-3*t) *t),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*exp(-3*t)*sin(9*exp(-3*t)*t),1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)* t+9*t^2*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*exp(-3*t) *t)][-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t )*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*exp(-3* t)*t),-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*exp(-3*t)*sin(9*exp(-3*t)*t),exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t)*cos( 9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t)),-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*exp(-3*t)*t)+1/2*exp(-3*t )*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*exp(-3* t)*t)][-1/2*t^2*exp(-3*t)*sin(9*exp(-3*t)*t)-t*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t) *t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp(-3*t)*t-12*t^2*exp(-3*t)+9*t^3*e xp(-3*t)),-t*exp(-3*t)*sin(9*exp(-3*t)*t)-exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2 *exp(-3*t)),-t*exp(-3*t)*sin(9*exp(-3*t)*t)-exp(-3*t)*cos(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2 *exp(-3*t))-1/2*t^2*exp(-3*t)*sin(9*exp(-3*t)*t)-t*exp(-3*t)*cos(9*exp(-3*t)*t)*(-6 *exp(-3*t)*t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9* t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp(-3*t)*t-12*t^2*exp(-3*t) +9*t^3*exp(-3*t)),exp(-3*t)*sin(9*exp(-3*t)*t)-1/2*t^2*exp(-3*t)*sin(9*exp(-3*t)*t)-t*exp(-3*t)*cos(9 *exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*exp(-3*t)*t)*(-6*exp(-3*t)*t+9*t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*exp(-3*t)*t)*(2*exp(-3*t)*t-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))]第二部分数学问题求解与数据处理1.(1)>> syms a t;>> f=sin(a*t)/t;laplace(f)ans =atan(a/s)(2)>> syms t a;f=t^5*sin(a*t);laplace(f)ans =60*i*(-1/(s-i*a)^6+1/(s+i*a)^6)(3)>> syms t a;>> f=t^8*cos(a*t);laplace(f)ans =20160/(s-i*a)^9+20160/(s+i*a)^92.(1)>> syms s a b;F=1/(s^2*(s^2-a^2)*(s+b));ilaplace(F)ans =1/2/a^3/b^2/(a^2-b^2)*(2*t*a*b^3+2*(1-exp(-b*t)-b*t)*a^3+( -2*a+exp(a*t)*(a-b)+exp(-a*t)*(a+b))*b^2)(2)>> syms a b s;F=sqrt(s-a)-sqrt(s-b);ilaplace(F)ans =1/2/t^(3/2)/pi^(1/2)*(exp(b*t)-exp(a*t))(3)>> syms a b s; F=log((s-a)/(s-b));ilaplace(F)ans =(exp(b*t)-exp(a*t))/t3(1)>> syms x;f=x^2*(3*sym(pi)-2*abs(x));F=fourier(f) F =-6*(4+pi^2*dirac(2,w)*w^4)/w^4>> ifourier(F)ans =x^2*(-4*x*heaviside(x)+3*pi+2*x)(2)>> syms t;f=t^2*(t-2*sym(pi))^2;F=fourier(f)F =2*pi*(dirac(4,w)-4*pi^2*dirac(2,w)+4*i*pi*dirac(3,w)) >> ifourier(F)ans =x^2*(-2*pi+x)^24.(1)>> syms k a T;f=cos(k*a*T);F=ztrans(f)(z-cos(a*T))*z/(z^2-2*z*cos(a*T)+1)>> f1=iztrans(F)f1 =cos(a*T*n)(2)>> syms k T a;f=(k*T)^2*exp(-a*k*T);F=ztrans(f)F =T^2*z*exp(-a*T)*(z+exp(-a*T))/(z-exp(-a*T))^3>> f1=iztrans(F)f1 =T^2*(1/exp(a*T))^n*n^2(3)>> syms a k T;f=(a*k*T-1+exp(-a*k*T))/a;>> F=ztrans(f)F =1/a*(a*T*z/(z-1)^2-z/(z-1)+z/exp(-a*T)/(z/exp(-a*T)-1)) >> iztrans(F)ans =(-1+a*T*n+(1/exp(a*T))^n)/a5.用数值方法求解(1)>> syms x;>> x1=solve('exp(-(x+1)^2+pi/2)*sin(5*x+2)')x1 =-2/5验证过程>> subs('exp(-(x+1)^2+pi/2)*sin(5*x+2)',x,x1)ans =(2)>> syms x;>> y1=solve('(x^2+y^2+x*y)*exp(-x^2-y^2-x*y)=0','y')y1 =(-1/2+1/2*i*3^(1/2))*x(-1/2-1/2*i*3^(1/2))*x验证过程>>y2=simple(subs('(x^2+y^2+x*y)*exp(-x^2-y^2-x*y)=0','y',y1)) y2 =(x^2+(-1/2+1/2*i*3^(1/2))^2*x^2+x^2*(-1/2+1/2*i*3^(1/2)))* exp(-x^2-(-1/2+1/2*i*3^(1/2))^2*x^2-x^2*(-1/2+1/2*i*3^(1/2) )) = 0(x^2+(-1/2-1/2*i*3^(1/2))^2*x^2+x^2*(-1/2-1/2*i*3^(1/2)))*e xp(-x^2-(-1/2-1/2*i*3^(1/2))^2*x^2-x^2*(-1/2-1/2*i*3^(1/2))) = 06.首先求出积分:>> syms x c;y=int((exp(x)-c*x)^2,x,0,1)y =-1/2-2*c+1/2*exp(2)+1/3*c^2编写一个出M文件:function y=new(c)y=-1/2-2*c+1/2*exp(2)+1/3*c^2;>> x=fminsearch('new',0)x =3.00007.编写M文件:function [c,ce]=f2(x);ce=[];c=[x(1)+x(2);x(1)*x(2)-x(1)-x(2)+1.5;-10-x(1)*x(2)];>> f=@(x)exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1); >> A=[];B=[];Aeq=[];Beq=[];xm=[-10;-10];xM=[10;10];>> x0=(xm+xM)/2;>> ff=optimset;ff.TolX=1e-10;ff.TolFun=1e-20;>> x=fmincon(f,x0,A,B,Aeq,Beq,xm,xM,@f2,ff)Maximum number of function evaluations exceeded;increase OPTIONS.MaxFunEvals.x =0.41950.4195>> i=1;x=x0;>> while (1)[x,a,b]=fmincon('f',x,A,B,Aeq,Beq,xm,xM,'f2',ff);if b>0,break;endi=i+1;end>> x,ix =1.1825-1.7398i =58书上所描述的ipslv_mex下载地址已经失效了,其他网站上也没有这个函数的下载地址,所以这个题目没有找到该函数,运行失败。