My program is never done running and I can't quite figure out why.

Here's the question:

for every n = 2, 3, 4, 5, ....100 compute a value of arcsin(1/n) by applying Newton-Raphson Method to the function f(x)=sin(x)-(1/n) with tolerance set to e = 10^-5 and an initial guess x = . Let s be the converged value for arcsin(1/n), and i be the number of iterations used.

And here's what I've got:

function [snvec, invec] = newton(maxn)

n = 2;

snvec = zeros(1, maxn-1);

invec = zeros(1, maxn-1);

while n < maxn+1

sn = 0;

in = 0;

while abs(asin(1/n) - (sin(sn)-1/n)) > 10^-5

sn = sn - (sin(sn)-1/n)/cos(sn);

in = in + 1;

end

snvec(n-1) = sn;

invec(n-1) = in;

n = n+1

end

end

and then the function is called:

newton(100)