Ask Your Question
0

How to build a generating series

asked 2021-03-30 17:26:09 +0100

FundamentalDomain gravatar image

updated 2021-03-30 17:57:56 +0100

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

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-03-30 19:03:46 +0100

slelievre gravatar image

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

edit flag offensive delete link more

Comments

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

FundamentalDomain gravatar imageFundamentalDomain ( 2021-03-30 19:32:51 +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: 2021-03-30 17:26:09 +0100

Seen: 608 times

Last updated: Mar 30 '21