Using MATLAB I want to calculate the limit of the sequence below. $$ a(n)=\frac{n^2+1}{3n^2+1} $$ $$ \lim_{(n\to\infty)}a(n)=? $$ At first I thought \
syms n
a(n)=(n^2+1)/(3*n^2+1);
limit(a(n),'n',inf)
would solve the problem.
However, this couldn't be the answer because the limit is calculated where n is a real number here, while n should be only the natural numbers. So I think I should use 'while' loop, but I can't figure out how I should use it. Any suggestions please?
If you want to use the while loop, try to reduce the limit value to a tolerance range using $a(n)>a(n+1)$ for any $n\geq1$. Here is an example: