Ask Your Question
1

Mertens Function Error

asked 2014-12-10 10:38:44 +0100

Kevin Smith gravatar image

updated 2015-01-14 12:19:54 +0100

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

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 ( 2014-12-10 10:54:04 +0100 )edit

Thank you.

Kevin Smith gravatar imageKevin Smith ( 2014-12-10 10:56:45 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-12-10 10:48:56 +0100

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
edit flag offensive delete link more

Comments

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

Kevin Smith gravatar imageKevin Smith ( 2014-12-10 10:58:36 +0100 )edit

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 ( 2014-12-10 14:50:15 +0100 )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

Stats

Asked: 2014-12-10 10:38:44 +0100

Seen: 824 times

Last updated: Dec 10 '14