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?
nis a natural number, then why not define it specify it as such via:syms n positive integer? You'll get exactly the same answer due to the reasons mentioned by @Joako. – horchler Apr 10 '23 at 17:41