Ask Your Question

Simple question on displaying summation

asked 2020-01-31 02:01:14 +0200

erikblue gravatar image


I'm defining a few summation functions for displaying and evaluating later, but I don't understand how to do it.

So, I'm looking at the basic Sage Quick Reference and I see under Arithmetic: sum(f(i) for i in (k..n))

But when I try to make it symbolic to show, like something simple like this:

f(n)=sum(i for i in (0..n))

But then I get

TypeError: unable to simplify to float approximation

Which makes me think its trying to evaluate the sum rather than make it a symbolic expression. Then I ran across "symbolic_sum" somewhere, but I can't find any documentation about it now...

Any suggestions?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-31 03:25:28 +0200

dazedANDconfused gravatar image

updated 2020-01-31 03:40:01 +0200

If you want a symbolic sum you have 2 choices that I know of. First, using sum:

k, n = var('k,n')
f=sum(k, k, 0, n)

The output, running in a SageCellServer is shown below:

image description

You can find the documentation here.

If you use symbolic_sum, documented here, then you could try:

from sage.calculus.calculus import symbolic_sum
f=symbolic_sum(i, i, 0, n)

The output is: image description

edit flag offensive delete link more


Ok thanks for the answer. I guess if I want to display it in pretty summation notation I will need to use LaTeX. Glad I wasn't missing anything.

erikblue gravatar imageerikblue ( 2020-01-31 18:36:36 +0200 )edit

I don't think that can be done using just Sage. When I combine LaTeX and Sage, I do it as a document using the sagetex package in LaTeX. The CTAN documentation is here.

dazedANDconfused gravatar imagedazedANDconfused ( 2020-02-01 00:39:40 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2020-01-31 02:01:14 +0200

Seen: 337 times

Last updated: Jan 31 '20