# Revision history [back]

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 60)]
e2 = sum(factor * qexponent * zexp2 for exponent,exp2, factor in d2)
<end>

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example type(p.coefficients()[1][1]) <end> yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 60)]
e2 = sum(factor * qexponent * zexp2 for exponent,exp2, factor in d2)
<end>

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example type(p.coefficients()[1][1]) <end> example
type(p.coefficients()[1][1])
yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!advance!
PS: If someone could give me a hint, how I format SAGE code in HTML, I could improve the visualization of my question :)

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 60)]
e2 = sum(factor * qq*exponent * zz*exp2 for exponent,exp2, factor in d2)

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example
type(p.coefficients()[1][1])
yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!
PS: If someone could give me a hint, how I format SAGE code in HTML, I could improve the visualization of my question :)

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 60)]
e2 = sum(factor * q*exponent q**exponent * z*exp2 z**exp2 for exponent,exp2, factor in d2)

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example
type(p.coefficients()[1][1])
yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!
PS: If someone could give me a hint, how I format SAGE code in HTML, I could improve the visualization of my question :)

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 60)]
e2 = sum(factor * q**exponent * z**exp2 for exponent,exp2, factor in d2)

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example
type(p.coefficients()[1][1])
yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!
PS: If someone could give me a hint, how I format SAGE code in HTML, I could improve the visualization of my question and also I am missing some * in my definition of d2, so an easy copy-and-paste into SAGE might not work. :)

### Type Conversion in coefficient method

I have the polynomials of a certain Eisenstein series. Those are given in the following way:

var('q','z');
QuadraticField(5); d2 = [(0, 0, 1), (1/10sqrt5 + 1/2, 0, 30), (1/10sqrt5 + 1/2, -1/5sqrt5 - 1, 1), (1/10sqrt5 + 1/2, 1/5sqrt5 + 1, 1), (1/10sqrt5 + 1/2, -3/10sqrt5 - 1/2, 12), (1/10sqrt5 + 1/2, 3/10sqrt5 + 1/2, 12), (1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 20), (1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 20), (1/10sqrt5 + 1/2, 1/5sqrt5, 12), (1/10sqrt5 + 1/2, -1/5sqrt5, 12), (-1/10sqrt5 + 1/2, 0, 30), (-1/10sqrt5 + 1/2, -1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 1/10sqrt5 - 1/2, 12), (-1/10sqrt5 + 1/2, -1/10sqrt5 + 1/2, 12), (-1/10sqrt5 + 1/2, 2/5sqrt5, 1), (-1/10sqrt5 + 1/2, -2/5sqrt5, 1), (-1/10sqrt5 + 1/2, 1/5sqrt5, 20), (-1/10sqrt5 + 1/2, -1/5sqrt5, 20), (-1/5sqrt5 + 1, 0, 60), (-1/5sqrt5 (1/10*sqrt5 + 1/2, 0, 30), (1/10*sqrt5 + 1/2, -1/5*sqrt5 - 1, 1), (1/10*sqrt5 + 1/2, 1/5*sqrt5 + 1, 1), (1/10*sqrt5 + 1/2, -3/10*sqrt5 - 1/2, 12), (1/10*sqrt5 + 1/2, 3/10*sqrt5 + 1/2, 12), (1/10*sqrt5 + 1/2, -1/10*sqrt5 - 1/2, 20), (1/10*sqrt5 + 1/2, 1/10*sqrt5 + 1/2, 20), (1/10*sqrt5 + 1/2, 1/5*sqrt5, 12), (1/10*sqrt5 + 1/2, -1/5*sqrt5, 12), (-1/10*sqrt5 + 1/2, 0, 30), (-1/10*sqrt5 + 1/2, -1/10*sqrt5 - 1/2, 12), (-1/10*sqrt5 + 1/2, 1/10*sqrt5 + 1/2, 12), (-1/10*sqrt5 + 1/2, 1/10*sqrt5 - 1/2, 12), (-1/10*sqrt5 + 1/2, -1/10*sqrt5 + 1/2, 12), (-1/10*sqrt5 + 1/2, 2/5*sqrt5, 1), (-1/10*sqrt5 + 1/2, -2/5*sqrt5, 1), (-1/10*sqrt5 + 1/2, 1/5*sqrt5, 20), (-1/10*sqrt5 + 1/2, -1/5*sqrt5, 20), (-1/5*sqrt5 + 1, 0, 60), (-1/5*sqrt5 + 1, -1, 20), (-1/5sqrt5 + 1, 1, 20), (-1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 60), (-1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 60), (-1/5sqrt5 + 1, 3/10sqrt5 - 1/2, 20), (-1/5sqrt5 + 1, -3/10sqrt5 + 1/2, 20), (-1/5sqrt5 + 1, 2/5sqrt5, 30), (-1/5sqrt5 + 1, -2/5sqrt5, 30), (-1/5sqrt5 + 1, 1/5sqrt5, 60), (-1/5sqrt5 + 1, -1/5sqrt5, 60), (1/5sqrt5 + 1, 0, 60), (1/5sqrt5 + 1, -2/5sqrt5 - 1, 20), (1/5sqrt5 + 1, 2/5sqrt5 + 1, 20), (1/5sqrt5 + 1, -1/5sqrt5 - 1, 30), (1/5sqrt5 + 1, 1/5sqrt5 + 1, 30), (1/5sqrt5 + 1, 1/2sqrt5 + 1/2, 20), (1/5sqrt5 + 1, -1/2sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -3/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 3/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, -1/10sqrt5 - 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 + 1/2, 60), (1/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (1/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (1/5sqrt5 + 1, 1/5sqrt5, 60), (1/5sqrt5 + 1, -1/5sqrt5, 60), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, 12), (-2/5sqrt5 + 1, 0, 30), (-2/5sqrt5 + 1, 1/5sqrt5 - 1, 1), (-2/5sqrt5 + 1, -1/5sqrt5 + 1, 1), (-2/5sqrt5 + 1, 1/10sqrt5 - 1/2, 20), (-2/5sqrt5 + 1, -1/10sqrt5 + 1/2, 20), (-2/5sqrt5 + 1, 3/10sqrt5 - 1/2, 12), (-2/5sqrt5 + 1, -3/10sqrt5 + 1/2, 12), (-2/5sqrt5 + 1, 1/5sqrt5, 12), (-2/5sqrt5 + 1, -1/5sqrt5, (-1/5*sqrt5 + 1, 1, 20), (-1/5*sqrt5 + 1, -3/10*sqrt5 - 1/2, 20), (-1/5*sqrt5 + 1, 3/10*sqrt5 + 1/2, 20), (-1/5*sqrt5 + 1, -1/10*sqrt5 - 1/2, 60), (-1/5*sqrt5 + 1, 1/10*sqrt5 + 1/2, 60), (-1/5*sqrt5 + 1, 1/10*sqrt5 - 1/2, 60), (-1/5*sqrt5 + 1, -1/10*sqrt5 + 1/2, 60), (-1/5*sqrt5 + 1, 3/10*sqrt5 - 1/2, 20), (-1/5*sqrt5 + 1, -3/10*sqrt5 + 1/2, 20), (-1/5*sqrt5 + 1, 2/5*sqrt5, 30), (-1/5*sqrt5 + 1, -2/5*sqrt5, 30), (-1/5*sqrt5 + 1, 1/5*sqrt5, 60), (-1/5*sqrt5 + 1, -1/5*sqrt5, 60), (1/5*sqrt5 + 1, 0, 60), (1/5*sqrt5 + 1, -2/5*sqrt5 - 1, 20), (1/5*sqrt5 + 1, 2/5*sqrt5 + 1, 20), (1/5*sqrt5 + 1, -1/5*sqrt5 - 1, 30), (1/5*sqrt5 + 1, 1/5*sqrt5 + 1, 30), (1/5*sqrt5 + 1, 1/2*sqrt5 + 1/2, 20), (1/5*sqrt5 + 1, -1/2*sqrt5 - 1/2, 20), (1/5*sqrt5 + 1, -3/10*sqrt5 - 1/2, 60), (1/5*sqrt5 + 1, 3/10*sqrt5 + 1/2, 60), (1/5*sqrt5 + 1, -1/10*sqrt5 - 1/2, 60), (1/5*sqrt5 + 1, 1/10*sqrt5 + 1/2, 60), (1/5*sqrt5 + 1, 1/10*sqrt5 - 1/2, 20), (1/5*sqrt5 + 1, -1/10*sqrt5 + 1/2, 20), (1/5*sqrt5 + 1, 1/5*sqrt5, 60), (1/5*sqrt5 + 1, -1/5*sqrt5, 60), (-2/5*sqrt5 + 1, 0, 30), (-2/5*sqrt5 + 1, 1/5*sqrt5 - 1, 1), (-2/5*sqrt5 + 1, -1/5*sqrt5 + 1, 1), (-2/5*sqrt5 + 1, 1/10*sqrt5 - 1/2, 20), (-2/5*sqrt5 + 1, -1/10*sqrt5 + 1/2, 20), (-2/5*sqrt5 + 1, 3/10*sqrt5 - 1/2, 12), (-2/5*sqrt5 + 1, -3/10*sqrt5 + 1/2, 12), (-2/5*sqrt5 + 1, 1/5*sqrt5, 12), (-2/5*sqrt5 + 1, -1/5*sqrt5, 12), (-2/5*sqrt5 + 1, 0, 30), (-2/5*sqrt5 + 1, 1/5*sqrt5 - 1, 1), (-2/5*sqrt5 + 1, -1/5*sqrt5 + 1, 1), (-2/5*sqrt5 + 1, 1/10*sqrt5 - 1/2, 20), (-2/5*sqrt5 + 1, -1/10*sqrt5 + 1/2, 20), (-2/5*sqrt5 + 1, 3/10*sqrt5 - 1/2, 12), (-2/5*sqrt5 + 1, -3/10*sqrt5 + 1/2, 12), (-2/5*sqrt5 + 1, 1/5*sqrt5, 12), (-2/5*sqrt5 + 1, -1/5*sqrt5, 12), (1, 0, 72), (1, -1/5sqrt5 - 1, 30), (1, 1/5sqrt5 -1/5*sqrt5 - 1, 30), (1, 1/5*sqrt5 + 1, 30), (1, -1, 12), (1, 1, 12), (1, 1/2sqrt5 + 1/2, 12), (1, -1/2sqrt5 - 1/2, 12), (1, -3/10sqrt5 - 1/2, 60), (1, 3/10sqrt5 + 1/2, 60), (1, -1/10sqrt5 - 1/2, 60), (1, 1/10sqrt5 + 1/2, 60), (1, 1/10sqrt5 - 1/2, 60), (1, -1/10sqrt5 + 1/2, 60), (1, 2/5sqrt5, 30), (1, -2/5sqrt5, 30), (1, 1/5sqrt5, 60), (1, -1/5sqrt5, 1/2*sqrt5 + 1/2, 12), (1, -1/2*sqrt5 - 1/2, 12), (1, -3/10*sqrt5 - 1/2, 60), (1, 3/10*sqrt5 + 1/2, 60), (1, -1/10*sqrt5 - 1/2, 60), (1, 1/10*sqrt5 + 1/2, 60), (1, 1/10*sqrt5 - 1/2, 60), (1, -1/10*sqrt5 + 1/2, 60), (1, 2/5*sqrt5, 30), (1, -2/5*sqrt5, 30), (1, 1/5*sqrt5, 60), (1, -1/5*sqrt5, 60)]
e2 = sum(factor * q**exponent * z**exp2 for exponent,exp2, factor in d2)

For example, the first entry in the list d2 would give me the entry 1q^0z^0 with the coefficient 1 and the index (0,0). Now I would like to filter these kind of polynomials to find the coefficients of a certain index.
My naive initial idea was to use the method (e2).coefficients() and then search via comparison.The problem that I am having is that I cannot "compare" the values of the index via "==" since the types are not compatible. So, this for example
type(p.coefficients()[1][1])
example

type(p.coefficients()[1][1])

yields "<class 'sage.symbolic.expression.expression'="">" and I cannot compare this to an expression like "-2*sqrt(1/5) + 1".

Where is my mistake and is there an easy fix to this? Thanks in advance!
PS: If someone could give me a hint, how I format SAGE code in HTML, I could improve the visualization of my question and also I am missing some * in my definition of d2, so an easy copy-and-paste into SAGE might not work. :)