sequence convergence of sqrt(2)

I am having some difficulties converging this sequence to sqrt(2).
the values are not computing properly and I am not sure why.
N=randi(100);
X1=1;
for k=[2:1:N]
Xk= 0.5.*(k-1)+(2/k-1);
end
terms=linspace(2,Xk,N)

답변 (1개)

Alan Stevens
Alan Stevens 2021년 4월 12일

0 개 추천

I think you probably want
X(k) = 0.5*X(k-1) + 1/(2*X(k-1));
with
X(1) = 1;

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

태그

질문:

2021년 4월 12일

답변:

2021년 4월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by