Quasi
Quasi

Reputation: 1

How to fix TypeError: 'sage.symbolic.expression.Expression' object is not iterable error with Moebius Function

I've developed this code

from sage.arith.misc import Moebius
x_value = 6
f(k) = sum(moebius(k) * k * x_value**(2*k) / ((1 - x_value**k) * (1 - x_value**(2*k))**2), k, 1, infinity)
function = x_value*euler_phi(x_value)/8 + f(x_value)
function.numerical_approx()

to test a summation that I had discovered for a certain problem my professor gave me. Although I can find no problem with this code, logic wise, I am getting an error pasted below

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[478], line 3
      1 from sage.arith.misc import Moebius
      2 x_value = Integer(6)
----> 3 __tmp__=var("k"); O = symbolic_expression(sum(moebius(k) * k * x_value**(Integer(2)*k) / ((Integer(1) - x_value**k) * (Integer(1) - x_value**(Integer(2)*k))**Integer(2)), k, Integer(1), infinity)).function(k)
      4 function = x_value*euler_phi(x_value)/Integer(8) + O(x_value)
      5 function.numerical_approx()

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.8/lib/python3.11/site-packages/sage/arith/misc.py:4585, in Moebius.__call__(self, n)
   4583     n = -n
   4584 F = factor(n)
-> 4585 for _, e in F:
   4586     if e >= 2:
   4587         return 0

TypeError: 'sage.symbolic.expression.Expression' object is not iterable

Now i'm unable to fix this, can anyone help?

Upvotes: 0

Views: 29

Answers (0)

Related Questions