ans = 
Matlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Matlab says it's exp(2), which is wrong. Pls confirm.
Show older comments
Matlab got this wrong: Limit as n goes to infinity: (1+(i/n))^(n^2). Matlab says it's exp(2), which is wrong.
13 Comments
John D'Errico
on 22 May 2024
Edited: John D'Errico
on 22 May 2024
I'm sorry. But we don't send you e-mail. That is not how Answers works. You will need to look to see if an answer is posted. And it is MATLAB, not Mathlab.
Anyway, are you saying the SUM over i? What are the limits of that sum? Where does i start? At 0?
Moses
on 22 May 2024
James Tursa
on 22 May 2024
Edited: James Tursa
on 22 May 2024
We are still unsure what i is. Can you post how you calculated this in MATLAB?
Moses
on 22 May 2024
@Moses, I'm not sure what were deleted. But I can help you to recreate what you observed.
syms n
limit((1 + (1i)/n)^(n^2), n, inf)
@Moses, do you think this should be correct in your view ?
syms n
limit(((1 + (1i)/n)^(n).^2), n, inf)
Image Analyst
on 22 May 2024
You've made so many edits, but I'm still not sure what you're summing over i or n. Is it summing over n and i is just the imaginary constant sqrt(-1)?
syms n
expr1 = (1 + (1i)/n)^(n^2)
expr2 = (1 + (1i)/n)^(n).^2
Moses
on 22 May 2024
Moses
on 22 May 2024
Accepted Answer
More Answers (2)
David Goodmanson
on 22 May 2024
Edited: David Goodmanson
on 22 May 2024
Hi Moses,
not every expression has a limit, or should. That's the case here, as anyone can check. For large n the function zips around (nearly) a circle, and it's interesting that the circle is not the unit circle but has, for large n, radius e^(1/2) = 1.6487 as a limit.
The plot below brings up a question: why do the lines connecting the points stay near the perimeter of the circle? It seems like the line connecting point n to point n+1 could cut across the circle, but it doesn't happen. This suggests a large-n limit for the angle between point n and point n+1 and that is correct, with a value of 1 radian.
The finite limit e^2 is an error as you said.
n = 1:100;
y = (1+i./n).^(n.^2);
plot(y) % complex plane

3 Comments
Moses
on 22 May 2024
Torsten
on 22 May 2024
WolframAlpha returns the expression without modifications. This could either indicate that the software was not able to compute it or (what would be the correct answer) that the limit does not exist.
David Goodmanson
on 23 May 2024
Hi Moses,
the function does move around a circle in the complex plane, but it is not the unit circle. See the direct numerical calculation in the answer above.
The absolute value of the function is
(abs(1+i/n))^(n^2)
= (sqrt(1+1/n^2))^(n^2)
= ((1+1/n^2)^(1/2))^(n^2)
= ((1+1/n^2)^(n/2))^(1^2) % since (x^a)^b = (x^b)^a = x^(ab)
and since
limit m-->inf (1+1/m)^m = e
the result, which is the radius of the circle, is e^(1/2) as stated in the answer.
James Tursa
on 22 May 2024
Edited: James Tursa
on 23 May 2024
I have been looking at this for a couple of days now and have finally convinced myself that this limit doesn't exist and MATLAB is in error. Since you are raising a complex number to a potentially fractional power in this limit expression, and such operations are multi-valued for complex numbers, I would question whether the limit should exist at all simply on that basis. But suppose we restrict ourselves to integer n to avoid that discussion. Start with this expression:
(1 + i/n) ^ (n^2)
Extract the magnitude of the inner part so we are left with the form ( r * u ) ^ (n^2) where u is a unit complex number:
[ sqrt(1 + 1/n^2) * (1 + i/n) / sqrt(1 + 1/n^2) ) ] ^ (n^2)
Separate the magnitude out:
sqrt(1 + 1/n^2) ^ (n^2) * [ (1 + i/n) / sqrt(1 + 1/n^2) ) ] ^ (n^2)
Rewrite the magnitude part using 1/2 exponent instead of sqrt():
[ (1 + 1/n^2) ^ (1/2) ] ^(n^2)
Rearrange:
[ (1 + 1/n^2) ^ (n^2) ] ^(1/2)
The limit of the inside part is clearly e, so we have the magnitude converging to:
e^(1/2)
Now for the unit complex number part, we have a point on the complex unit circle raised to a positive integer power, so the result will clearly also be on the complex unit circle. The question is, does this converge to a particular point or not? To examine that, consider the triangle where it came from and just examine the angle of this triangle:

The angle x associated with our unit complex number is the same as the original triangle it came from, so we have:
tan(x) = (1/n) / 1 = 1/n
So
x = atan(1/n)
The taylor series for atan() is:
syms y
taylor(atan(y))
So for small angles we can just use y, or in our case 1/n.
Since our complex unit vector is raised to the power n^2, we can just multiply that by our small angle to get the expected resulting angle:
(1/n) * n^2 = n
Thus, as n -> infinity, the angle grows without bound.
In conclusion, although the magnitude of the original expression converges to e^(1/2), the angle does not converge, hence the overall limit does not converge. For large n, with a magnitude of e^(1/2) and an angle of n, the original expression (1 + 1i/n)^(n^2) will be pretty close to:
exp(1/2) * (cos(n) + 1i * sin(n)) = exp(1/2 + 1i * n)
15 Comments
Moses
on 22 May 2024
@Moses A test of my conclusion that the result will be close to being on a circle of radius exp(1/2) with angle n for "large" n:
format longg
n = 1e2;
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
n = 1e4;
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
n = 1e6;
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
n = vpa(1e8);
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
n = vpa(1e10);
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
n = vpa(1e12);
[(1+1i/n)^(n^2)
exp(1/2 + 1i * n)]
Looks like a good match to me. What did you find wrong with my derivation? How did you determine the result should be on the unit circle?
James Tursa
on 22 May 2024
P.S. It may be of interest to readers for you to post other examples of MATLAB erroneous limit results. Maybe edit your original post and include them?
How did you determine the result should be on the unit circle?
Maybe like
(1+1i/n)^(n^2) = ((1+1i/n)^n)^n ~ exp(1i)^n = exp(1i*n) = cos(1i*n) + 1i*sin(1i*n)
(which is of course wrong).
Torsten
on 23 May 2024
Which line is wrong?
You cannot let the "inner n" approach infinity and leave the "outer n" unchanged here:
((1+1i/n)^n)^n ~ exp(1i)^n
Moses
on 24 May 2024
Torsten
on 24 May 2024
What do you expect ? The limit does not exist, thus even with a bug fix, MATLAB will most probably just return the limit expression unchanged.
No, we don't agree at all with this statement. The limit does not exist, period. That is the best way to say it. There are not many possible answers in this case that MATLAB can pick from and return one of them, because there are no possible answers. The limit of the magnitude of the expression exists and is exp(1/2), but the limit of the expression does not exist. You could say that there is a limiting asymptotic-like behavior to the sequence, but the limit itself does not exist. In order for a limit of a function or sequence to exist in general, the expression has to get arbitrarily close to the limit L for large enough n. For every ϵ > 0, there must exist an N > 0 such that |f(n)-L| < ϵ for all n > N (emphasis on the all). Clearly that cannot be satisfied in this case. E.g., you suggested exp(1/2) is one of the "possible answers" that MATLAB could return for this limit. For that to be true, the expression must remain arbitrarily close to exp(1/2) for all large enough n. But we know this is not the case. Suppose I pick ϵ = 1/2 and we managed to find a value of n such that the expression was very close to exp(1/2) for this n. Then we know that the expression for n+1 is going to be about 1 radian away from this in angle near a circle of radius exp(1/2), clearly violating our ϵ = 1/2. It doesn't matter how large n is, we know the distance to the next number in the sequence is going to be approximately the length of a chord of radius exp(1/2) and angle 1 radian away from it (much larger than our ϵ = 1/2):
exp(1/2) * 2 * sin(1/2)
A graph of the first million differences flatlines and never gets small:
n = 1:1e6;
z = (1 + 1i./n) .^ (n.^2);
plot(abs(diff(z)));
The expression just keeps spinning around the circle of radius exp(1/2) as n increases. The only correct thing for MATLAB to do is return something that indicates this, e.g., NaN if it can verify that the limit does not exist or just return the expression indicating that it doesn't know. Any tool that indicates a limit exists for this is just plain wrong.
Your cube root of 8 example where there are three possible answers is not a valid comparison to this limit problem. Even if you were to pick an example where there are an infinitely number of possible solutions and MATLAB returns one of them as the answer (e.g., not full rank linear algebra problem, complex number raised to fractional power, etc.), that still would not be a valid comparison to the limit problem above. The following is a valid comparison to the limit problem above:
What is the limit of the following sequence? +1, -1, +1, -1, +1, -1, ...
According to your reasoning, there are two possible valid answers, +1 and -1, and we can pick one for our answer. But this is clearly incorrect. There is no answer to this problem. The limit doesn't exist. The sequence never converges. The sequence never gets arbitrarily close to either +1 or -1 no matter how far in the sequence you go. MATLAB figures this out in this case:
syms n
limit( (-1)^n, n, inf )
And if we feed MATLAB our approximate expression, it figures that one out too:
limit( exp(1/2 + 1i * n), n, inf )
For those who are interested:
My conjecture for the case given is that each point on the circle with radius exp(1/2) is an accumulation point of the sequence
z_n = (1 + 1i/n)^(n^2)
which means that given a point z* = exp(1/2)*exp(i*phi) on the circle, there exists a subsequence z_n_k such that z_n_k -> z* for k -> Inf.
James Tursa
on 27 May 2024
Edited: James Tursa
on 27 May 2024
@Torsten Yes I did find that link interesting! And I suspect you are correct as it probably wouldn't be too hard to massage the proof in that link to fit our case (e.g., pick n large enough so that magnitude being close to exp(1/2) is sufficiently < ϵ and then copy the rest of the proof from there). As a consequence, it is also interesting that even though the original set (sequence of points) is countable (since they map to the positive integers), the set of all subsets must be uncountable since a portion of them map to a real dense set of points.
As a consequence, it is also interesting that even though the original set (sequence of points) is countable (since they map to the positive integers), the set of all subsets must be uncountable since a portion of them map to a real dense set of points.
Yes, like the rationals are dense in the reals. Each element of the uncountable set of reals can be approximated by the countable set of the rationals with arbitrary precision.
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



