Wolfram Alpha != HP Prime CAS result: who is wrong?
|
06-04-2024, 01:08 AM
(This post was last modified: 06-04-2024 01:56 AM by robve.)
Post: #1
|
|||
|
|||
Wolfram Alpha != HP Prime CAS result: who is wrong?
On Wolfram Alpha:
\( \sum_{k=0}^n k=\frac12n(n+1) \) but it also says that: \( \sum_{k=0}^{-10} k=0 \) which surprised me, because the sign of \( n \) should not matter. What am I doing wrong here? HP Prime CAS: \( \sum_{k=0}^{-10}k=45 \) which checks out \( \frac12(-10)(-10+1)=45 \) So Wolfram Alpha thinks that \( \sum_{k=0}^{-10}k=0 \) is a so-called zero-trip loop? s=0; for (k=0; k<-10; ++k) s += k; A couple of years ago, I spoke with a founder of Maple at a conference about similar problems and differences with program code as we were translating algebraic formulas in Prolog notation to FORTRAN to implement and run numerical solutions, and we knew these things can bite you. Their explanations of algebraic identities made sense back then and still do. - Rob "I count on old friends to remain rational" |
|||
06-04-2024, 01:45 AM
Post: #2
|
|||
|
|||
RE: Wolfram Alpha != HP Prime CAS result: who is wrong? | |||
06-04-2024, 01:56 AM
Post: #3
|
|||
|
|||
RE: Wolfram Alpha != HP Prime CAS result: who is wrong?
(06-04-2024 01:45 AM)Thomas Klemm Wrote: You missed the \(k\) in your sums: Fixed in the post. I need glasses... - Rob "I count on old friends to remain rational" |
|||
06-04-2024, 11:48 AM
Post: #4
|
|||
|
|||
RE: Wolfram Alpha != HP Prime CAS result: who is wrong?
(06-04-2024 01:08 AM)robve Wrote: On Wolfram Alpha: It return 0 because there is no elements to sum (08-26-2020 09:58 PM)Albert Chan Wrote: Mathematica also does closed end limit, but generated a list. (conceptually) (06-04-2024 01:08 AM)robve Wrote: HP Prime CAS: Actually, limits get changed. sum(k, k= 0 .. -10) = - sum(k, k=-9 .. -1) = sum(k, k = 1 .. 9) = 9*10/2 = 45 The reason may be due to symmetry (08-26-2020 09:58 PM)Albert Chan Wrote: This may explain the reason for (a,b) → (b+1,a-1), if a>b+1 |
|||
06-04-2024, 02:39 PM
(This post was last modified: 06-04-2024 04:50 PM by robve.)
Post: #5
|
|||
|
|||
RE: Wolfram Alpha != HP Prime CAS result: who is wrong?
(06-04-2024 11:48 AM)Albert Chan Wrote: It return 0 because there is no elements to sum But then: Albert Chan Wrote:(06-04-2024 01:08 AM)robve Wrote: HP Prime CAS: which is contradictory to the former sum, i.e. the point I was trying to make. If we accept the semantics of the former sum then we ought to define: \( \displaystyle \sum_{k=0}^n k = \cases{0 & if $n<0$ \cr \frac12n(n+1) & otherwise} \) whereas the latter places no constraints on the limits (at least in this case) nor restricts \( n \) to be integer for that matter. So what's the problem? Or why do we care? Say we define \( s(n) := \sum_{k=0}^n k \) and apply \( s(-10) \). Now, if we pre-simplify \( s(n) := \frac12n(n+1) \) then we get \( s(-10) \Rightarrow 45 \). On the other hand, if we don't simplify our definition then a CAS could potentially evaluate \( s(-10) \Rightarrow 0 \). Like a "mechanical device" we write it out as \( \sum_{k=0}^n f(k) = f(0)+f(1)+\cdots+f(n) \) with sum identity zero if \( n<0 \). By the way, the triangle number of inverted bounds completes the triangle number to a square number: \( \displaystyle \sum_{k=0}^n k + \sum_{k=0}^{-n} k = \frac12(n^2+n) + \frac12(n^2-n) = n^2 \) That's neat. And also \( \displaystyle \sum_{k=0}^{-n} k = \frac12(-n)(-n+1) = \frac12n(n-1) = \frac12(n-1)(n-1+1) = \sum_{k=0}^{n-1} k \) It's not deep, a bit entertaining perhaps. - Rob "I count on old friends to remain rational" |
|||
06-04-2024, 04:39 PM
Post: #6
|
|||
|
|||
RE: Wolfram Alpha != HP Prime CAS result: who is wrong?
HP Prime behavior Wrote:\( \displaystyle \sum_{k=0}^{-n} k = \frac12(-n)(-n+1) = \frac12n(n-1) = \frac12(n-1)(n-1+1) = \sum_{k=0}^{n-1} k \) With limit = 0 .. n-1, many sum formulas are simpler. Off by 1 is a result of forward difference operator. Δf(x) = f(x+1) - f(x) Σ(Δf(x), x=0 .. n-1) = f(x+n) - f(x) Example, in falling factorial form, sum is just like integration. \( \displaystyle \sum_{k=0}^{n-1} k^{\underline n} = \left. \frac{k^{\underline {n+1}}}{n+1} \right| _0 ^n \) Perhaps this is why HP Prime internally work with open-ended sum formula. Note: sign of n does not matter. \( \displaystyle \sum_{k=0}^{-n} k = \left. \frac{k^{\underline {2}}}{2} \right| _0 ^{-n+1} = \left. \frac{k^{\underline {2}}}{2} \right| _0 ^{n} = \sum_{k=0}^{n-1} k \) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)