Ask Your Question
0

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

asked 2021-04-27 13:27:50 +0100

lijr07 gravatar image

updated 2021-04-27 19:53:00 +0100

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

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-04-28 00:27:21 +0100

Max Alekseyev gravatar image

updated 2021-04-28 00:31:04 +0100

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-04-27 13:27:50 +0100

Seen: 583 times

Last updated: Apr 28 '21