16

I want to evaluate $$\displaystyle\lim_{n\to\infty}\left(n-\sqrt{\sin(n)+10n+n^2}\right)^2$$

I used this code

Limit[(n - Sqrt[Sin[n] + 10 n + n^2])^2, n -> \[Infinity]]

It returns unevaluated. This limit is not hard to calculate by hand so I'm a bit surprised. Why doesn't Mathematica evaluate it?

Cristopher
  • 387
  • 2
  • 11
  • 9
    Limit code is not dealing well with that Sin[n] term. It uses Series which really has no "nice" representation for sine at infinity. Would be good to replace it with Interval[{-1,1}] maybe (I mean in the Limit code, not at the user end). – Daniel Lichtblau Jul 24 '15 at 20:52
  • The result from Maple 2015 limit((n-sqrt(sin(n)+10*n+n^2))^2, n = infinity) is 25, but Maple 16 give incorrect result: infinity! – Vaclav Kotesovec Jul 24 '15 at 21:09
  • @DanielLichtblau I see that's the core of the problem. Thanks for your comment (+1) – Cristopher Jul 24 '15 at 22:12
  • Mathematica also gives some interesting numerical answers. Take n->10^7 and //N; you get 25. Take n -> 10^10 and you get 0. – Calchas Jul 25 '15 at 01:47
  • 2
    @Calchas I just checked it and you are right. Weird... – Cristopher Jul 25 '15 at 03:18
  • 7
    Interestingly, Limit[(n - Sqrt[10 n + n^2 + Sin[x]])^2, n -> ∞, Assumptions -> -1 <= Sin[x] <= 1] quickly produces 25 – m_goldberg Jul 26 '15 at 05:21
  • @Calchas That numeric behavior is a straightforward consequence of machine arithmetic cancellation error. – Daniel Lichtblau Jul 27 '15 at 22:41
  • @DanielLichtblau Are you saying it's working as intended and expected? ;) – Calchas Jul 27 '15 at 22:47
  • @Calchas The numeric evaluation, yes. I am assuming you did something equivalent to this: N[(n - Sqrt[Sin[n] + 10 n + n^2])^2 /. n -> 10^18]. Also note that if you use 10^10 in the replacement it actually gives 25. If you did something else then I may have misunderstood the comment re "interesting numerical answers". – Daniel Lichtblau Jul 27 '15 at 23:48
  • @DanielLichtblau Nope 10^10 gives me 0. 10^9 gives me 0.5ish. Is variation across systems also a feature? ;) – Calchas Jul 28 '15 at 08:29
  • @Calchas It certainly could be, although I'm surprised to see that large a difference. Might have to do with usage, or not, or extended precision registers (which is certainly platform dependent). Look up "cancellation error" and you might get an idea of what is happening. – Daniel Lichtblau Jul 28 '15 at 17:37
  • 2
    @ m_goldberg: 1) very convincing, and probably the least help effort to MMA, and, what's more, a completely justified one. Could even overwrite my recent answer. Sorry for having noticed your comment so late. 2) Unfortunately, it does not work for a general bounded function: Limit[f[n]/n, n -> [Infinity], Assumptions -> -1 <= f[n] <= 1] is returned unevaluated instead of giving 0. – Dr. Wolfgang Hintze Aug 07 '15 at 08:17

3 Answers3

16

On a different occasion (Dirichlet coefficients as limits: wrong) I have shown that the sometimes limited capabilities of the function Limit[] can be improved by using an intermediate Series[].

Following this idea we can write for the limit in question

Limit[Expand[
  Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 2}]] /. 
   x -> 10/ n + Sin[n]/n^2], n -> \[Infinity]]

(* 25 *)

In this manner we can even calculate the limit with a symbolic parameter "a"

Limit[Expand[
  Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 2}]] /. x -> a/ n + Sin[n]/n^2],
  n -> \[Infinity]]

(* a^2/4 *)

Also, a general function is permissible (provided Limit[f[n]/n,n -> \[Infinity]] == 0)

Limit[
 Expand[Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 2}]] /. 
   x -> a/ n + f[n]/n], n -> \[Infinity]]

(* Limit[a^2/4 + 1/2 a f[n] + f[n]^2/4, n -> \[Infinity]] *)

Where the final Limit can only be assessed once f[n] is given explicitly.

Modification of the OP.

Taking f[n] = Sin[n] (instead of f[n] = Sin[n]/n as in the OP) we find

Limit[Expand[
  Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 2}]] /. x -> a/ n + Sin[n]/n], 
 n -> \[Infinity]]

(* Limit[a^2/4 + 1/2 a Sin[n] + Sin[n]^2/4, n -> \[Infinity]] *)

Taking the x-expansion beyond x^2 we get for all higher powers

Limit[Expand[
  Normal[Series[(n - n Sqrt[1 + x])^2, {x, 0, 3}]] /. x -> a/ n + Sin[n]/n], 
 n -> \[Infinity]]

(* 1/4 (a + Interval[{-1, 1}])^2 *)
Dr. Wolfgang Hintze
  • 13,039
  • 17
  • 47
12

The problem here is the Sin[n] which has no limit since it is an oscillating function, but it is always bounded by $\pm 1$: if you change you code with the following:

Limit[(n - Sqrt[1 + 10 n + n^2])^2, n -> Infinity]

with 1 in place of Sin (or -1 if you want), you get the result:

(*25*)
mattiav27
  • 6,677
  • 3
  • 28
  • 64
  • 2
    Like in Limit[n - Sqrt[10 n + n^2 + a], n -> \[Infinity], Assumptions -> -1 < a < 1] – Dr. belisarius Jul 24 '15 at 21:12
  • 1
    Thanks. So it appears Sin[n] is the problem... Changing the code in that way indeed gives the correct answer, but you shouldn't have to do that :/. As a side note and as it's been mentioned in the comments, Maple 2015 evaluates the limit with no problem. Mathematica has some "catching up" to do... – Cristopher Jul 24 '15 at 22:14
  • Should be reported as a bug – Calchas Jul 25 '15 at 11:45
  • Limit[(n - Sqrt[1 + 10 n + n^2])^2, n -> \[Infinity], Assumptions -> -1 <= a <= 1] @Dr. belisarius – lotus2019 Apr 13 '23 at 07:25
5

Since the functionality of Limit[] has been improved in version 11.2, the limit is now evaluated rather easily:

Limit[(n - Sqrt[Sin[n] + 10 n + n^2])^2, n -> ∞]
   25
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574