First time here? Check out the FAQ!

Ask Your Question
1

Mertens Function Error

asked 10 years ago

Kevin Smith gravatar image

updated 10 years ago

FrédéricC gravatar image

I am new to Sage, so I suppose the answer to this is ridiculously obvious, but please go easy on me!

I have an error when I try to get Mertens function as an output yet: I know the summation works for other functions; and I know the Moebius function is defined on the range. So what's going on?

This is the input and output:

sage: var('j')
sage: f = moebius(j) 
TypeError                                 Traceback (most recent call last)
....
----> f=moebius(j)
...
TypeError: 'sage.symbolic.expression.Expression' object is not iterable
Preview: (hide)

Comments

Hello, I rewrote your example with identation (if you indent with four spaces you get a nice presentation of the code) and keeping only the relevant part of the traceback.

vdelecroix gravatar imagevdelecroix ( 10 years ago )

Thank you.

Kevin Smith gravatar imageKevin Smith ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

FrédéricC gravatar image

You cannot make sums with symbolic bounds, or at least it does not work very often.

Rather do something like that:

sage: def mertens(n):
....:     return sum(moebius(i) for i in range(1, n+1))
sage: mertens(6)
-1
sage: mertens(66)
-1
sage: mertens(691)
-9
Preview: (hide)
link

Comments

Thank you! Is there an obvious reason why this only works sporadically? I would like to know.

Kevin Smith gravatar imageKevin Smith ( 10 years ago )

You have to have a symbolic function, and then you have to have a symbolic function that Maxima would be able to do summation on, I guess. See http://trac.sagemath.org/ticket/8383 for a step in that direction - this would indeed be useful.

kcrisman gravatar imagekcrisman ( 10 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: 10 years ago

Seen: 987 times

Last updated: Dec 10 '14