# Why am I getting a wrong answer for this sum?

I'm trying to simplify a sum with some minima in it. I started with this.

sum(i, i, 0, min(k-1, la+lb))

1/2k^2 - 1/2k

Doesn't look good. What am I doing wrong?

edit retag close merge delete

probably you want to use min_symbolic: the top-level min function that you are calling refers to Python's built-in min (which is ok for numeric values).

( 2017-07-13 10:46:07 -0600 )edit

Want to add that as an answer?

( 2017-07-14 02:20:18 -0600 )edit

Sort by ยป oldest newest most voted

(extended comment)

probably you want to use min_symbolic: the top-level min function that you are calling refers to Python's built-in min (which is ok for numeric values).

in this case i get:

sage: var('i, k, la, lb')
(i, k, la, lb)
sage: sum(i, i, 0, min_symbolic(k-1, la+lb))
1/2*min(k - 1, la + lb)^2 + 1/2*min(k - 1, la + lb)

(of course you could have just substituted in $n(n+1)/2$ for $n=\text{min_symbolic}(k-1, la+lb)$).

PS: it's in the reference manual as Symbolic Maximum and Minimum, and there is some work on updating that section in ticket #11258.

more

Please start posting anonymously - your entry will be published after you log in or create a new account.

## Stats

Asked: 2017-07-13 07:39:00 -0600

Seen: 139 times

Last updated: Jul 14