Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

substituting vars for a poly quotient in a list comprehension blows up

If I run this but don't substitute the a and b for the polynomials:

a = 3*x^2 + 2*x + 1
b = 5*x^3 - 2*x^2 + 3
c = [((3*x^2 + 2*x + 1)/(5*x^3 - 2*x^2 + 3)).n() for x in [100..30000,step=100]]
for num in c:
    print(num)

I get a numeric list, as expected.

If I use f = [(a/b) for x in [100..30000,step=100]] however, I only get variables in x, all the same: (3.00000000000000x^2 + 2.00000000000000x + 1.00000000000000)/(5.00000000000000x^3 - 2.00000000000000x^2 + 3.00000000000000)

And if I try (a/b).n(), I get an error: TypeError: unable to coerce to a ComplexNumber: <class 'sage.rings.fraction_field_element.fractionfieldelement_1poly_field'="">

What's going wrong?