# How to build a generating series

Hello. Forgive me, I'm still a bit new to coding. I want to create a generating q-series for functions I've already defined, which have complex number outputs. These functions are denoted g(k, n, z), where k, n are integers and z in a complex input. I'd like the series sum([g(k, n, z)*q^n for n in range(1, 100)]) or something along those lines. The error code is:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-5dc58c06413b> in <module>
5     return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))])
6
----> 7 G(Integer(2), Integer(1)+i)

<ipython-input-35-5dc58c06413b> in G(k, z)
3 def G(k, z):
4     var('q')
----> 5     return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))])
6
7 G(Integer(2), Integer(1)+i)
<ipython-input-35-5dc58c06413b> in <listcomp>(.0)
3 def G(k, z):
4     var('q')
----> 5     return sum([g(k, n, z)*q**n for n in range(Integer(1), Integer(100))])
6
7 G(Integer(2), Integer(1)+i)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'sage.symbolic.expression.Expression


I apologize I cannot make the above formatting more clear. Perhaps someone could help me! Edit: Thank you for editing above error code!

edit retag close merge delete

Sort by » oldest newest most voted

Did you forget return in the definition of g(k, n, z)?

more

I added var('q') in the def of G and also used your advice about return. This seemed to work! Thank you!