ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 10 Dec 2014 14:50:15 +0100Mertens Function Errorhttps://ask.sagemath.org/question/25194/mertens-function-error/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
Wed, 10 Dec 2014 10:38:44 +0100https://ask.sagemath.org/question/25194/mertens-function-error/Comment by vdelecroix for <p>I am new to Sage, so I suppose the answer to this is ridiculously obvious, but please go easy on me! </p>
<p>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? </p>
<p>This is the input and output:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25197#post-id-25197Hello, 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.Wed, 10 Dec 2014 10:54:04 +0100https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25197#post-id-25197Comment by Kevin Smith for <p>I am new to Sage, so I suppose the answer to this is ridiculously obvious, but please go easy on me! </p>
<p>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? </p>
<p>This is the input and output:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25198#post-id-25198Thank you.Wed, 10 Dec 2014 10:56:45 +0100https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25198#post-id-25198Answer by FrédéricC for <p>I am new to Sage, so I suppose the answer to this is ridiculously obvious, but please go easy on me! </p>
<p>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? </p>
<p>This is the input and output:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/25194/mertens-function-error/?answer=25196#post-id-25196You 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
Wed, 10 Dec 2014 10:48:56 +0100https://ask.sagemath.org/question/25194/mertens-function-error/?answer=25196#post-id-25196Comment by kcrisman for <p>You cannot make sums with symbolic bounds, or at least it does not work very often.</p>
<p>Rather do something like that:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25204#post-id-25204You 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.Wed, 10 Dec 2014 14:50:15 +0100https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25204#post-id-25204Comment by Kevin Smith for <p>You cannot make sums with symbolic bounds, or at least it does not work very often.</p>
<p>Rather do something like that:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25199#post-id-25199Thank you! Is there an obvious reason why this only works sporadically? I would like to know.Wed, 10 Dec 2014 10:58:36 +0100https://ask.sagemath.org/question/25194/mertens-function-error/?comment=25199#post-id-25199