早教吧 育儿知识 作业答案 考试题库 百科 知识分享

mathlab数学实验题编程判断函数f(x)=(x-1)/(x+1)的迭代序列是否收敛.

题目详情
mathlab数学实验题编程判断函数f(x)=(x-1)/(x+1) 的迭代序列是否收敛.
▼优质解答
答案和解析
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,则说明收敛!(前者表示像正无穷方向收敛,后者像负无穷方向)