MATLAB: How to write a code for a variant of Newton’s method in calculating square root of a matrix

indexingnewtonnewton's methodsubscript

Hello there, I have a question regarding a variant of Newton's method in calculating square root of a matrix. here is how the method works:
X_0=A+I,
X_{k+1}=(1/2)*(x_{k}+(x_{k}^(-1)*(A+(I/(k+1)))))
and here is the code I wrote:
A = [1 5;2 3];
I=eye(2);
for k = 0:1:10;
x0= A+I;
x1=(1/2)*(x0+(x0^(-1)*(A+(I/(k+1)))))
end
the problem is my indexing, I do not know how to write the code in a way that the calculation will continue with each time substituting the new X_{k} in the pervious formula.
Thank you for your time and attention,
Ha

Best Answer

A = [1 5;2 3];
I=eye(2);
x0= A+I;
for k = 0:10
x1=(1/2)*(x0+(inv(x0)*(A+(I/(k+1)))));
x0 = x1;
end
Best wishes
Torsten.