irregular summations in Home/CAS
|
10-20-2024, 02:56 PM
Post: #1
|
|||
|
|||
irregular summations in Home/CAS
I was recently working on a probability problem whose answer involved a summation. Depending the values given, it was possible that the start_index could be greater than the end_index. In other words:
Code: Σ(f(k),k,a,b) where a>b In this particular math problem, assuming that any such summation was zero resulted in the correct answer. When I tested my answer on the Prime, cases where a>b generate an error message in Home, or an incorrect answer (for this problem) in CAS, unless I surrounded the summation with an IFTE(). Code: IFTE(b>=a,Σ(f(k),k,a,b),0) This got me to wondering about the use of such "irregular" summations on various calculators and software. Here's a summary of what I have found using the following example. Code: Σ(K^2,K,5,1) This produces the following results: HP Prime Home, TI 84+, Casio fx-CG50/fx-9860G: error message HP Prime CAS/Xcas, TI 89/92/Voyage/Nspire: -(4^2 + 3^2 + 2^2) = -29 HP 48/49/50, Numworks, WolframAlpha, Maxima: 0 I can understand the rational behind the error message for safety sake with students. I can also understand returning 0 as this is often (usually?) the desired behavior in a formula. I'm very curious though about the thinking behind returning -29. Can someone come up with an example in which this is the desired behavior? Was Xcas simple trying to be compatible with TI calculators, or is there a mathematical reason for this result? And finally, setting calculators/software aside, is there standard interpretation of such a summation in mathematics? If you saw Σ(f(k),k,a,b) in a book or article, would you assume that a must be less than or equal to b? Or would you assume that if a>b the summation becomes zero? |
|||
10-20-2024, 03:27 PM
Post: #2
|
|||
|
|||
RE: irregular summations in Home/CAS
The rule is comply with Chasles relation:
sum(..,a,b)+sum(...,b+1,c)==sum(..,a,c) |
|||
10-20-2024, 06:16 PM
(This post was last modified: 10-20-2024 07:20 PM by Wes Loewer.)
Post: #3
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-20-2024 03:27 PM)parisse Wrote: The rule is comply with Chasles relation: Thank you for pointing me in the right direction. It still took me a little while to wrap my head around this. I kept getting off by 1 on one of the indices, but I think I've got it now, but my "proof" seems like circular reasoning. Proof that sum(...,a,b) = -sum(...,b+1,a-1) 0. Assume that sum(...,a,b) = -sum(...,b+1,a-1) 1. sum(...,a,b) + sum(...,b+1,a-1) = 0 2. sum(...,a,a-1) = 0 But how do we know that sum(...,a,a-1) = 0? Because if you apply the original assumption 3. sum(...,a,a-1) becomes -sum(...,(a-1)+1,(a)-1) 4. sum(...,a,a-1) = -sum(...,a,a-1) The only way for x=-x is if x=0 So sum(...,a,a-1) is indeed = 0 Since we have arrived at a true statement, the conclusion is that the assumption was true. So the assumption is internally consistent, but a it seems like circular logic because I used the assumption in step 3. Is there a non-circular proof, or is internal consistency the best we can hope for? For instance, assuming that if a<b then sum(...,b,a)=0 sum(...,a,b) + sum(...,b,a) = sum(...,a,b) + 0 sum(...,a,a) = sum(...,a,b) which doesn't make sense, so the assumption that sum(...,b,a)=0 is not consistent with Chasles relation. However, could it be argued that it is consistent with some other logical assumption? I guess the implications of Chasles relation makes sense if you use the analogy of vectors. But if you are thinking in terms of a for-loop, then sum(...,b,a)=0 makes sense, and might be more practical. Thank you for the enlightening mental exercise. Edit: Actually, my statement that sum(...,a,b) + sum(...,b,a) = sum(...,a,b) + 0 sum(...,a,a) = sum(...,a,b) is not quite true since sum(...,a,b) + sum(...,b,a) has a b in both sums, but the point is still true that this leads to an inconsistency with Chasles relation. |
|||
10-20-2024, 08:52 PM
Post: #4
|
|||
|
|||
RE: irregular summations in Home/CAS
Hi, Wes Loewer
I had the same question a while back, with possible reason for off-by-1 behavior https://www.hpmuseum.org/forum/thread-15...#pid135681 |
|||
10-20-2024, 10:44 PM
(This post was last modified: 10-23-2024 04:05 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-20-2024 06:16 PM)Wes Loewer Wrote: Proof that sum(...,a,b) = -sum(...,b+1,a-1) Yes, this is circular reasoning. Also, we cannot prove a sum definition For integrals, we have ∫(..., a, b) = -∫(..., b, a) If we have similar symmetry, Σ(..., a, b) = -Σ(..., c, d), what is {c,d} ? Σ(..., a, b) = Σ(..., -∞, b) - Σ(..., -∞, a-1) = -(Σ(..., -∞, a-1) - Σ(..., -∞, (b+1)-1)) = -Σ(..., b+1, a-1) Quote:sum(..., a, a-1) = 0 Another way to show this is to count number of elements. sum is closed-end, number of elements = (a-1) - a + 1 = 0 No elements to sum, we have Σ(..., a, a-1) = Σ(..., a, b) + Σ(..., b+1, a-1) = 0 |
|||
10-21-2024, 05:13 AM
Post: #6
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-20-2024 08:52 PM)Albert Chan Wrote: I had the same question a while back, with possible reason for off-by-1 behavior Thanks for the link. I thought someone had brought this up before but I couldn't find it when I searched for it. Quote:Yes, this is circular reasoning. Also, we cannot prove a sum definition And that's the crux of the matter. As a definition, there's no way (or need) to prove it. The best definitions are ones that are logical and consistent. In the case of summations, both definitions have logical reasoning. Personally, I prefer the result being zero, but at the same time I find other definition more mathematically "pure." |
|||
10-21-2024, 05:32 AM
(This post was last modified: 10-21-2024 08:19 AM by C.Ret.)
Post: #7
|
|||
|
|||
RE: irregular summations in Home/CAS
Bonjour à tous,
Sorry if my question seems a bit silly, but I am not a mathematician, only a biochemist. I thought that addition was associative and commutative, so I have trouble following your conversation. For me, \( \sum_{k=1}^{5} x_k = x_1 + x_2 + x_3 + x_4 + x_5 \) and \( \sum_{k=5}^{1} x_k = x_5 + x_4 + x_3 + x_2 + x_1 \). So I had always believed that \( \sum_{k=1}^{5} x_k = \sum_{k=1}^{5} x_k = \sum_{k\in \left\{ 1\cdots 5\right\}} x_k = x_1 + x_2 + x_3 + x_4 + x_5 \). In fact, if I count the number of bacterial colonies on the Petri dishes numbered from #1 to #10, I get the same count as if I count them from dish #10 to dish #1. If this is not the case, I have been making mistakes in my daily counts in the laboratory for 20 years now!! Thank you for clarifying this point. I am a bit perplexed. |
|||
10-21-2024, 10:01 AM
Post: #8
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-21-2024 05:32 AM)C.Ret Wrote: In fact, if I count the number of bacterial colonies on the Petri dishes numbered from #1 to #10, I get the same count as if I count them from dish #10 to dish #1. Wait, you mean you don't get a negative number of colonies? So, that makes 4 different logical definitions when a>b: \( \sum_{k=a}^{b} x_k = \sum_{k=b}^{a} x_k~~\): You get the same number whether you add them left to right or right to left. \( \sum_{k=a}^{b} x_k = -\sum_{k=b+1}^{a-1} x_k~~\): Consistent with \( \sum_{k=a}^{b} x_k + \sum_{k=b+1}^{c} x_k = \sum_{k=a}^{c} x_k \) for all values of \(a\), \(b\), and \(c\). \( \sum_{k=a}^{b} x_k = 0 ~~\): If you're going from \(a\) up to \(b\), you are already past \(b\) before you even start. You haven't added anything, so the sum is zero. \( \sum_{k=a}^{b} x_k = \) undefined: Hey, you can't do that! And even if you could, the answer would be ambiguous. (Perhaps the safest definition of all.) Quote:Thank you for clarifying this point. I am a bit perplexed. Sorry, I can only make it worse! The corresponding rules for products are: \( \prod_{k=a}^{b} x_k = \prod_{k=b}^{a} x_k~~\): You still get the same number either direction. \( \prod_{k=a}^{b} x_k = \prod_{k=b+1}^{a-1} \frac{1}{x_k}~~\): Replace the additive inverse with the multiplicative inverse. \( \prod_{k=a}^{b} x_k = 1 ~~\): Replace the additive identity with the multiplicative identity. \( \prod_{k=a}^{b} x_k = \) undefined: Hey, you can't do that either! Obligatory quote: The nice thing about standards is that you have so many to choose from. |
|||
10-21-2024, 12:46 PM
(This post was last modified: 10-21-2024 04:06 PM by Albert Chan.)
Post: #9
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-21-2024 10:01 AM)Wes Loewer Wrote: \( \sum_{k=a}^{b} x_k = -\sum_{k=b+1}^{a-1} x_k~~\): Consistent with \( \sum_{k=a}^{b} x_k + \sum_{k=b+1}^{c} x_k = \sum_{k=a}^{c} x_k \) for all values of \(a\), \(b\), and \(c\). We can have an equivalent open-ended sum, S(..., a,b) = Σ(..., a, b-1) Above quote is simply S(xk, k,a,b+1) = -S(xk, k,b+1,a) This also make many sum formulas nicer, without the off-by-1 adjustment. ∫(t^n,t,0,x) = x^(n+1) / (n+1) ; n ≠ -1 S(t^n,t,0,x) = x^(n+1) / (n+1) ; falling factorial, n ≠ -1 Euler–Maclaurin formula With open-ended sum, this is very compact. Integral is anti-derivative. We can start from k=0, eliminate integral term too! Swap limits {a,b} only flip the sign, consistent with open-ended sum definition. Quote:\( \prod_{k=a}^{b} x_k = \prod_{k=b+1}^{a-1} \frac{1}{x_k}~~\): Replace the additive inverse with the multiplicative inverse. Yes, this is consistent with open-ended sum definition Again, we define open-ended product, P(..., a, b) = Π(..., a, b-1) P(xk, k,a,b+1) = e ^ S(ln(xk), k,a,b+1) = e ^ -S(ln(xk), k,b+1,a) = 1 / P(xk, k,b+1,a) |
|||
10-21-2024, 06:05 PM
Post: #10
|
|||
|
|||
RE: irregular summations in Home/CAS
There is a good reason to choose the definition compatible with Chasles inside a CAS : the fact that boundaries can be symbolic.
For example factor(sum(k^2,k,0,n)) will return the well-known formula n*(n+1)*(2*n+1)/6. That would not work for n<0 with other definitions. |
|||
10-21-2024, 06:43 PM
Post: #11
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-21-2024 06:05 PM)parisse Wrote: There is a good reason to choose the definition compatible with Chasles inside a CAS : the fact that boundaries can be symbolic. That's a nice example. And that's a good point about the use of that definition with symbolic math. I guess I've always mentally thought of Σ and Π in terms of for-loops for numerical calculations. Since a for-loop that doesn't loop at all would result in the sum being 0 and the product being 1, these values made sense to me. But looking at these in a symbolic environment requires taking into consideration aspects that don't typically exist with numerical calculations. |
|||
10-26-2024, 05:59 AM
Post: #12
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-20-2024 10:44 PM)Albert Chan Wrote: If we have similar symmetry, Σ(..., a, b) = -Σ(..., c, d), what is {c,d} ? That's good. The use of -∞ kind of hides the "off by one" issues that we might run into. I had some time yesterday to play with this a little more and came up with something that does not involve infinity, and is not circular like my previous attempt. Starting with 0. Σ(..., a, b) + Σ(..., b+1, c) = Σ(..., a, c) Since this should work for all a, b, and, c, we can let c = a-1 1 Σ(..., a, b) + Σ(..., b+1, a-1) = Σ(..., a, a-1) Likewise, we can let b = a-1 2. Σ(..., a, a-1) + Σ(..., (a-1)+1, a-1) = Σ(..., a, a-1) Σ(..., a, a-1) + Σ(..., a, a-1) = Σ(..., a, a-1) subtracting 3. Σ(..., a, a-1) = 0 Now that we have established line 3, we can substitute into line 1 4. Σ(..., a, b) + Σ(..., b+1, a-1) = 0 So 5. Σ(..., a, b) = -Σ(..., b+1, a-1) |
|||
10-26-2024, 06:05 AM
Post: #13
|
|||
|
|||
RE: irregular summations in Home/CAS
I first saw this idea that Σ(..., a, b) = -Σ(..., b+1, a-1) some 20 years ago on the TI-89. It was documented in the TI-89 manual, but it gave no indication as to why. There was an old manual on the shelf at school for its predecessor, Derive (for DOS), which also documented the behavior without explanation.
I had always figured it was the result of some some weird programming artifact. As a result of this thread, I now feel "enlightened" by the mathematical logic. Thank you and merci beaucoup |
|||
10-26-2024, 12:20 PM
(This post was last modified: 10-26-2024 12:44 PM by Albert Chan.)
Post: #14
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-26-2024 05:59 AM)Wes Loewer Wrote: Starting with FYI, there is an implicit increment parameter (= 1). Above is true only if LHS terms have non-negative elements. We are ignoring that fact for the 'proof' to continue. (it is not really a proof, only to make result consistent) n = b - a + 1 -n = a - b - 1 = (a-1) - (b+1) + 1 n + (-n) = 0 ; elements count Σ(..., a, b) + Σ(..., b+1, a-1) = 0 Again, above is a sum definition with negative elements count, not a prove. |
|||
10-26-2024, 01:28 PM
Post: #15
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-26-2024 12:20 PM)Albert Chan Wrote:(10-26-2024 05:59 AM)Wes Loewer Wrote: Starting withFYI, there is an implicit increment parameter (= 1). I must be missing something. How is this true only with non-negative elements? I thought the whole point of this definition was that this works with any values, even negatives. Please give an example in which this would not be true. Quote:(it is not really a proof, only to make result consistent)Right. Perhaps I should have started with: "Assuming the following property is true." |
|||
10-26-2024, 02:14 PM
Post: #16
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-26-2024 01:28 PM)Wes Loewer Wrote: I thought the whole point of this definition was that this works with any values, even negatives. sum with negative elements is undefined. OP already give an example, Σ(K^2,K,5,1), element counts = 1 - 5 + 1 = -3 If we say negative count is forbidden, we get ERROR If we say elements based from 5 ≤ K ≤ 1, we get 0 If we are allowed to flip the limits a certain way, so that element count is positive, we get this Σ(K^2,K,5,1) = -Σ(K^2,K,2,4) = -(2^2 + 3^2 + 4^2) = -29 We are not saying sum is correct. We simply ASSIGN a [logically consistent] value for the sum. Example, zeta(-1) = 1 + 2 + 3 + ... = -1/12 |
|||
10-26-2024, 06:58 PM
Post: #17
|
|||
|
|||
RE: irregular summations in Home/CAS
(10-21-2024 12:46 PM)Albert Chan Wrote: ⋮ Yes, this is what came to mind for me as well. If one is cutting up Z^1 (e.g., splitting sums, joining sums), a semi-open interval can be more convenient. The inclination (for practicality / convenience) away from the uniformly inclusive boundary becomes even stronger if one is cutting up Z^2 into "triangles" (as happens when rendering triangular meshes). |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)