First time here? Check out the FAQ!

Ask Your Question
0

Simple question on displaying summation

asked 5 years ago

erikblue gravatar image

Hi,

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:

var('i,n')
f(n)=sum(i for i in (0..n))
show(f)

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?

Erik

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

dazedANDconfused gravatar image

updated 5 years ago

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)
f.show()

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
var('i,n')
f=symbolic_sum(i, i, 0, n)
f.show()

The output is: image description

Preview: (hide)
link

Comments

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 ( 5 years ago )

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 ( 5 years ago )

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

Stats

Asked: 5 years ago

Seen: 520 times

Last updated: Jan 31 '20