南邮数学实验答案
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
练习1
1
1)
clear all;
m=4318;
syms x;
limit((m*x-sin(m*x))/x^3,x,0)
2)
clear all;
syms x;
f=inline('exp(x)*cos(4318*x/1000.0)','x');
diff(f(x),10)
3)
clear all;
syms x;
int('x^4/(4318^2+4*x^2)','x')
4)
clear all;
syms x;
taylor(sqrt(4318/1000.0+x),0,9)
2
clear all;
A=[-2,1,1;0,2,0;-4,1,4318];
[P,D]=eig(A)
a=det(A)
inverteda=inv(A)
3
clear all;
close all;
clc;
hold on;
ezplot('exp(-(x)*(x)/(2*(4318/600)*(4318/600)))/(sqrt(2*pi)*4318/600)',)
ezplot('exp(-(x-1)*(x-1)/(2*(4318/600)*(4318/600)))/(sqrt(2*pi)*4318/600)',)
ezplot('exp(-(x+1)*(x+1)/(2*(4318/600)*(4318/600)))/(sqrt(2*pi)*4318/600)',)
title('u=-1/u=1/u=0')
4
1)
clear all;
close all;
clc;
t=0:pi/1000:20;
u=0:pi/10000:2;
x=u.*sin(t);
y=u.*cos(t);
z=100.*t/4318;
plot3(x,y,z)
2)
clear all;
clc;
ezmesh('sin(4318*x*y)',[0,3],[0,3])
3)
clear all;
close all;
clc;
[t,u]=meshgrid(0:.01*pi:2*pi,0:.01*pi:2*pi);
x=sin(t).*(4318./100+cos(u));
y=cos(t).*(4318./100+cos(u));
z=sin(u);
surf(x,y,z);
练习2
1
judge.m
function vector=judge(x);
vector=[];
i=2;
while isempty(vector)&(i
vector=[i,x-i];
end
i=i+1;
end
ex2-1.m
clear all;
m=4318;
oddnumber=0;
for i=1:2:m;
if isempty(judge(i))==0
oddnumber=oddnumber+1;
end
end
evennumber=0;
for i=1:2:m;
if isempty(judge(i))==0
evennumber=evennumber+1;
end
end
oddnumber
evennumber
2
clear all;
clc
m=4318;
p=7+m/1000;
sum=0;
for i=1:200
i
sum=sum+1/i^p;
vpa(sum,17)
end
3
clear all;
clc;
x=3;
while x~=fex2_3(x)
x=fex2_3(x);
end
vpa(x,6)
fex2_3.m
function y=fex2_3(x)
m=4318;
y=(x+4318/x)/2;
vpa(x,6)
4
ex2_4_1.m
clear all;
clc;
x=-10000;
answer=[];
vpa(x,17)
for a=-10000:10000
for b=-10000:10000
for c=-10000:10000
for d=-10000:10000
for e=-10000:10000
if vpa(fex2_4_1(x,a,b,c,d,e),17)==x
answer=[x,a,b,c,d,e]
end
end
end
end
end
end
fex2_4_1.m
function y=fex2_4_1(x,a,b,c,d,e)
y=(a*x^2+b*x+c)/(d*x+e);
ex2_4_2.m
clear all;
clc;
x=-10000;
answer=[];
vpa(x,17)
for a=-10000:10000
for b=-10000:10000
for c=-10000:10000
for d=-10000:10000
for e=-10000:10000
if vpa(fex2_4_2(x,a,b,c,d,e),17)==x
answer=[x,a,b,c,d,e]
end
end
end
end
end
end
fex2_4_2.m
function y=fex2_4_1(x,a,b,c,d,e)
y=(a*x+b)/(c*x^2+d*x+e);
练习3
1
clear all;
format long
clc;
format long
A=[4,2;1,3];
a=rand;
b=rand;
x=[a;b]
t=[];
for i=1:40
x=A*x;
t(i,1:2)=[i,x(1,1)/x(2,1)];
end
t
2
clear all;
clc;
T=[];
syms n;
n=input('n=');
B=1/10*[62,581,511,-1012;-100,-957,-844,1668;560,5394,
4761,-9388;230,2218,1958,-3859];
x=[1;3;-2;2];
[P,D]=eig(B)
disp(['xn=x*T'])
T=P*D^n*P
3
clear all;
clc;
format long;
A=[2.1,3.4,-1.2,2.3;0.8,-0.3,4.1,2.8;2.3,7.9,-1.5,1.4;3.5,7.2,1.7,-9.0]
x=[1;2;3;4]
for i=1:300
fprintf('i=%5i',i)
x=A*x
end
4
clear all;
clc;
format long;
A=[2.1,3.4,-1.2,2.3;0.8,-0.3,4.1,2.8;2.3,7.9,-1.5,1.4;3.5,7.2,1.7,-9.0]
x=[1;2;3;4]
y=[];
for i=1:10000000
fprintf('i=%5i',i)
x=A*x
y=x./max(x)
x=y;
end
5
clear all;
clc;
A=[3/4,1/2,1/4;1/8,1/4,1/2;1/8,1/41/4]
x=[.5;.25;.25];
for i=1:10
fprintf('Day=%2i',i+1)
P=A*P;
vpa(p,4)
end
6
clear all;
clc;
t=[];
A=[3/4,7/18;1/4,11/18];
[p,d]=eig(A);
t=p(:,1)./[0.6087;3913];
vpa(t,4)
7
clear all;
clc;
t=[];
A=[3/4,1/2,1/4;1/8,1/4,1/2;1/8,1/41/4]
x=[.5;.25;.25];
for i=1:10
P=A*P;
end
[p,d]=eig(A);
t=p(:,1)./P;
vpa(p,4)
练习4
1
clear all;
clc;
a=input('a=')
b=input('b=')
syms s,r;
s=volume(a,b,0.00001);
r=0.00001;
for i=0.00001:.001:10
if s>volume(a,b,i);
r=i;
s=volume(a,b,i);
end
end
fprintf('r=%10.5f smin=%10.5f',r,s)
2
clear all;
clc;
m=input('m=')
a=m/300;
b=m/400;
syms s,r;
s=volume(a,b,0.00001);
r=0.00001;
for i=0.00001:.001:10
if s>volume(a,b,i);
r=i;
s=volume(a,b,i);
end
end
fprintf('r=%10.5f smin=%10.5f',r,s)
3
ex4_3_1.m
clear all;
clc;
a=1;
b=1;
c=1;
syms s,r,R,h,H;
r=0.1;
R=0.1;
h=0.1;
H=(355-(1/3)*pi*h*(R^2+r^2+r*R))/(pi*R^2);
T=[a,b,c,r,R,h,H];
s=volume2(a,b,c,r,R,h,H);
for r=0.1:0.1:10
for R=0.1:0.1:10
for h=0.1:0.1:10
H=(355-(1/3)*pi*h*(R^2+r^2+r*R))/(pi*R^2);
if(s>volume2(a,b,c,r,R,h,H))&(h>0)&(H>0)&(r>0)&(R>0)
T=[a,b,c,r,R,h,H];
s=volume2(a,b,c,r,R,h,H);
end
end
end
end
fprintf('smin=%10.5f',s)
vpa(T,4)
volume2.m
function y=volume2(a,b,c,r,R,h,H)
l=sqrt(h^2+(R-r)^2);
y=pi*r^2*a+pi*R^2*b+(pi*r*l+pi*R*l)*c+2*pi*R*b*H;
ex4_3_2.m
clear all;
clc;
a=m/300;
b=m/400;
c=m/100;
syms s,r,R,h,H;
r=0.1;
R=0.1;
h=0.1;
H=(355-(1/3)*pi*h*(R^2+r^2+r*R))/(pi*R^2);
T=[a,b,c,r,R,h,H];
s=volume2(a,b,c,r,R,h,H);
for r=0.1:0.1:10
for R=0.1:0.1:10
for h=0.1:0.1:10
H=(355-(1/3)*pi*h*(R^2+r^2+r*R))/(pi*R^2);
if(s>volume2(a,b,c,r,R,h,H))&(h>0)&(H>0)&(r>0)&(R>0)
T=[a,b,c,r,R,h,H];
s=volume2(a,b,c,r,R,h,H);
end
end
end
end
fprintf('smin=%10.5f',s)
vpa(T,4)