Ask Your Question
0

Why am I getting a wrong answer for this sum?

asked 2017-07-13 14:39:00 +0200

simon gravatar image

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 flag offensive close merge delete

Comments

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).

mforets gravatar imagemforets ( 2017-07-13 17:46:07 +0200 )edit

Want to add that as an answer?

simon gravatar imagesimon ( 2017-07-14 09:20:18 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-07-14 11:45:02 +0200

mforets gravatar image

updated 2017-07-14 11:45:51 +0200

(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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2017-07-13 14:39:00 +0200

Seen: 278 times

Last updated: Jul 14 '17