# AttributeError: '...FunctionFieldElement_rational' object has no attribute 'series'

Using t2.series(z, 23) to compute the Taylor series of a rational function, I obtain the following error:

AttributeError: 'sage.rings.function_field.function_field_element.FunctionFieldElement_rational' object has no attribute 'series'


In the following codes, diCartan, CartanMatrix are some number and integer matrix respectively.

Thank you very much.

def diCartan(i, typ, rank):
n=rank
r=1
if typ=='B' and i<rank:
r=2
elif typ=='C' and i==rank:
r=2
elif typ=='F' and i<3:
r=2
elif typ=='G' and i==1:
r=3

return r

def CartanMatrix(typ, rank):
r = Matrix(rank, rank)
n = rank
for i in range(n):
if i + 1 <= n-1:
r[i, i + 1] = -1
if 0 <= i - 1:
r[i, i - 1] = -1
r[i, i] = 2

if typ == 'C' or typ == 2:
r[n-1, n - 2] = -2
elif typ == 'B' or typ == 3:
r[n - 2, n-1] = -2
elif typ == 'D' or typ == 4:
if n == 2:
r[0, 1] = 0
r[1, 0] = 0
elif 3 <= n:
r[n - 3, n - 2] = -1
r[n - 3, n-1] = -1
r[n - 2, n - 3] = -1
r[n-1, n - 3] = -1
r[n - 2, n-1] = 0
r[n-1, n - 2] = 0
elif typ == 'E' or typ == 5:
for k in [[2, 4], [4, 2]]:
r[k[0], k[1]] = -1
for k in [[3, 4], [4, 3]]:
r[k[0], k[1]] = 0
elif typ == 'F' or typ == 6:
r[1, 2] = -2
elif typ == 'G' or typ == 7:
r[1, 0] = -3

return r

def QuantumCartanMatrixIJ(i, j, z, typ, rank):
di = diCartan(i, typ, rank)
cij = CartanMatrix(typ, rank)[i - 1, j - 1]
if i == j:
r = z^di + z^-di
elif i != j:
r = (z^(cij) - z^-cij)/(z - 1/z)
r = simplify(r)
return r

def QuantumCartanMatrix(z, typ, rank):
K.<z> = FunctionField(QQ)
r = matrix(K, rank, rank)
for i in range(1, rank + 1):
for j in range(1, rank + 1):
r[i - 1, j - 1] = QuantumCartanMatrixIJ(i, j, z, typ, rank)
return r

typ = 'G'
rank = 2
tau = [1,2]
var('z')

print(CartanMatrix(typ, rank))
qm = QuantumCartanMatrix(z, typ, rank)
qm

t1 = qm.inverse()
print(t1)
i = 1
j = 2
t2 = t1[i - 1, j - 1]
print(t2)
t2.series(z, 23)

edit retag close merge delete

Sort by ยป oldest newest most voted

Besides the reported problem of series not being defined, there is one more: z is declared in multiple places as var('z') and K.<z> = FunctionField(QQ). Correspondingly, you try to expand t2 over the powers of wrong z.

Workaround: replace t2.series(z, 23) with

z = t2.parent().gen()
SR(t2).taylor(z, 0, 23)


Also, while QuantumCartanMatrix gets z as an argument, it does not use but rather re-declares it. Correpondingly, the declaration var('z') and submitting z and an argument to QuantumCartanMatrix are redundant and can be removed.

more