3
$\begingroup$

Update: From the following notebook files, one can check that this discrepancy is not there in mathematica 13.1, while it is there in 14.0.0. Bug in 14.0? Did it get resolved in the more recent versions?

Original Question:

I'm observing a discrepancy in Mathematica 14.0.0 (Linux) where Limit applied to a sum gives a different result than summing the limits of the terms.

Given a large symbolic expression $T(t)$ (defined in the linked notebook) which is a sum of terms.

Calculating the limit as $t \to \infty$ in two ways yields different results:

(* Method 1: Limit of the sum *) limitOfSum = Limit[T, {t -> Infinity}]; (* Method 2: Sum of limits of terms *) TList = Apply[List, T]; (* Verified T == Total[TList] *) sumOfLimits = Total[Map[Limit[#, {t -> Infinity}] &, TList]]; (* The difference is non-zero *) difference = Simplify[limitOfSum - sumOfLimits]; 

The calculated difference is finite.

The limit of the sum part of the calculation takes 50 minutes (i7 12th gen processor), although all the output generated is also available in the notebook for quick verification. Rest of the calculation is quick. The full notebook with the definition of T and the code is available here:

Questions:

  1. Why does this discrepancy occur?
  2. Is this expected behavior or a potential bug in Limit?
  3. Which result is likely correct?

Some quick clarifications. You can verify from the code:

  • The sum of limit is convergent for each term and so is the Limit of the sum.
  • The expression has simple trigonometric, hyperbolic and exponential functions only.
  • There are total 114 terms. I have ran some obvious bug tests before posting here. See my answer for more details.
$\endgroup$
17
  • 3
    $\begingroup$ Is there really no way you can cut down your example to a smaller one which also shows the discrepancy? I am sure you can find a smaller set of terms, perhaps try randomly choosing small sets of terms ... $\endgroup$ Commented Apr 30 at 13:33
  • 2
    $\begingroup$ @Domen I will try running a loop that will repeat this calc for half the number of terms, and if there is discrepancy, half still, and so on, till the smallest T with discrepancy is found. I will update here. $\endgroup$ Commented Apr 30 at 13:37
  • 2
    $\begingroup$ Are you sure that you can interchange the limit and sum operations in this case? $\endgroup$ Commented Apr 30 at 15:34
  • 1
    $\begingroup$ @march yes. The each term is well behaved without singularities and there are finite number of terms. No reason why interchange will cause an issue. $\endgroup$ Commented Apr 30 at 16:21
  • 1
    $\begingroup$ @Domen the file named findingShortestT.wl on github was my attempt to find smaller expression for T that has this discrepancy. The code iteratively looks for discrepancy in the first 1, 2, 4, 8, 16, 32, 64 and 114 terms. Sadly, after running or long, only the 114 loop gave discrepancy. $\endgroup$ Commented Apr 30 at 19:32

2 Answers 2

1
+100
$\begingroup$

I was able to determine numerically which is the correct result. I am using the same notations as in your notebook.

Block[{p1= 1, p2= 5, p3= 2, m= 1, \[Mu]0= 3,t=10000,\[CapitalOmega]= 1,n=2/5,\[CapitalLambda]= 1/6,\[Kappa]= 1/2},{N[T,1000],N[Total[TList],1000]}]//Chop//N (*{-3.28239, -3.28239}*) 

Remember to take some large value of t (such that the result do not change anymore) because we are interested in the result for $t \rightarrow \infty$. Also, I did it using large precision to avoid some warnings (maybe they can be safely ignored).

We now take the results obtained after taking the limit $t \rightarrow \infty$. (They are TList and TMathIndividual in your notation)

Block[{p1= 1, p2= 5, p3= 2, m= 1, \[Mu]0= 3,\[CapitalOmega]= 1,n=2/5,\[CapitalLambda]= 1/6,\[Kappa]= 1/2},{N[TMathCalcStored,1000],N[TMathIndividual,1000]}]//N (*{-3.22386 + 0.0942997 I, -3.28239}*) 

This at least tells us that TMathCalcStored is incorrect. I did not calculate anything extra (given that it is taking 50 minutes, that is too long for me to run) and just used whatever is given in your notebook. Hope this helps at least to identify the correct result. As to why limitOfSum is not giving the correct result, I do not know.

Bonus: In my experience, if not every time, but most of the time, it is always possible to verify the things numerically (sometimes with a clever trick).

$\endgroup$
2
  • $\begingroup$ Nice. What I was missing was the knowledge that one could increase the numerical precision of an expression till nth decimal place by using N[expr,n]. Now, if only someone could explain why the limitOfSum is wrong. A bug? $\endgroup$ Commented May 5 at 10:29
  • $\begingroup$ Remember to give exact numbers for this to work (No decimals or inexact numbers because you will end up with roundoff errors otherwise. Rationalise them in such case.). Maybe other experts will tell if it is a bug or not ( the roadblock is that it is too time taking so it is difficult to verify it properly). But at least numerics tell that T is correct ( with large t). $\endgroup$ Commented May 5 at 10:47
4
$\begingroup$

I'm not a mathematician but have doubt that the interchange of sum and limit makes sense:

Counterexample

Limit[Sum[1/( t k) , {k, 1, Infinity}], t -> Infinity] (*sum does not converge*) Sum[Limit[1/( t k) , t -> Infinity], {k, 1, Infinity}] (* 0 *) 
$\endgroup$
2
  • 2
    $\begingroup$ It is indeed true that in general, it is not valid to replace the order of limit and integrals when infinities or singularities are involved. But, it is not the case here. The function here comes from physics, where each term is very well behaved without singularities and there are finite number of terms. In fact, there are exponentially decaying functions throughout if we simplify the expression a little. Here is a plot as a function of t. github.com/prem314/projects/blob/main/mathematica/PlotOfT.pdf $\endgroup$ Commented Apr 30 at 16:20
  • $\begingroup$ Please also note that the fact that large t limit of T and TTransForm[T] does not match (see my answer for the definition of TTransForm), suggests that this issue is not about Limit and Plus operations not commuting. Also note that the limit of TTransForm[T] does match with the sum of limits of T. $\endgroup$ Commented May 2 at 16:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.