> 其他 >
mathlab数学实验题编程判断函数f(x)=(x-1)/(x+1) 的迭代序列是否收敛.
人气:265 ℃ 时间:2020-09-20 14:31:28
解答
count = 0;
flag1 = 0;
flag2 = 0;
x = 2;
while(1)
y = x+1;
if ((x-1)/(x+1) == (y-1)/(y+1))
count = count + 1;
end
if((count = 0) & ((x-1)/(x+1) = (y-1)/(y+1)))
count = 0;
end
if(count == 5)
flag1 = 1;
break;
end
x = x*2;
end
x = -2;
while(1)
y = x-1;
if ((x-1)/(x+1) == (y-1)/(y+1))
count = count +1;
end
if((count = 0) & ((x-1)/(x+1) = (y-1)/(y+1)))
count = 0;
end
if(count == 10)
flag2 = 1;
break;
end
x = x*2;
end
最后在看一下flag1和flag2的值,如果为1,则说明收敛!(前者表示像正无穷方向收敛,后者像负无穷方向)
推荐
猜你喜欢
© 2025 79432.Com All Rights Reserved.
电脑版|手机版