y****e 发帖数: 1012 | 1 大家过年好~~有几个题目不是很清楚~
给了几段matlab程序,问题问发生了什么问题?
1.
close all
k=0;
n=100;
for delta = [.1 .01 .008 .007 .005 .003 ]
x = linspace(1-delta,1+delta,n)';
y = x.^6 - 6*x.^5 + 15*x.^4 - 20*x.^3 + 15*x.^2 - 6*x + ones(n,1);
k = k+1;
subplot(2,3,k)
plot(x,y,x,zeros(1,n))
axis([1-delta 1+delta -max(abs(y)) max(abs(y))])
end
2.
% p = smallest positive integer so 1+1/2^p = 1.
x=1; p=0; y=1; z=x+y;
while x~=z
y=y/2;
p=p+1;
z=x+y;
end
disp(sprintf('p = %2.0f is the smallest positive integer so 1+1/2^p = 1.',p
))
3.
% q = smallest positive integer so 1/2^q = 0.
x=1; q=0;
while x>0
x=x/2;
q=q+1;
end;
disp(sprintf('q = %2.0f is the smallest positive integer so 1/2^q = 0.',q))
4.
% r = smallest positive integer so 2^r = inf.
x=1; r=0;
while x~=inf
x=2*x;
r=r+1;
end
disp(sprintf('r = %2.0f is the smallest positive integer so 2^r = inf.',r))
% The Kahan example. In exact arithmetic f/e = 0/0:
5.
disp(' ')
echo on
h = 1./2.;
x = 2./3. - h;
y = 3./5. - h;
e = (x+x+x) - h;
f = (y+y+y+y+y)-h;
z = f/e;
echo off
disp(sprintf('\nz = %10.5f',z))
感觉1题说的是稳定性,随着x范围变小,y的稳定性变差
2题感觉是计算机器的精度p=53
3题q=1075=53+1023-1,感觉是计算下溢(不确定)
4题r=1024,感觉是计算指数上限U
5题完全没思路
大家帮忙看看吧~
谢谢啊~ |
|