Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 2011-10-17 05:29:46 -0600

DSM gravatar image

I don't know that there's a command in particular to construct a polynomial with symbolic coefficients, but here's what I'd do:

sage: N = 20
sage: x = var("x")
sage: aa = list(var('a_%d' % i) for i in (0..N))
sage: p = sum(a*x**i for i,a in enumerate(aa))
sage: p
a_20*x^20 + a_19*x^19 + a_18*x^18 + a_17*x^17 + a_16*x^16 + a_15*x^15 + a_14*x^14 + a_13*x^13 + a_12*x^12 + a_11*x^11 + a_10*x^10 + a_9*x^9 + a_8*x^8 + a_7*x^7 + a_6*x^6 + a_5*x^5 + a_4*x^4 + a_3*x^3 + a_2*x^2 + a_1*x + a_0

It's easy enough to change where x and the coefficients a are living (right now they're in the Symbolic Ring) if needed.