On Sep 3, 1:42 pm, andrew ewart <[email protected]> wrote:
> ...
> this is very close all i want to do is now join each collection of lists
> together
> so get outputs
> [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
> and
> [0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0]
> thoughts?

This was answered above both by John and myself: You can add lists.

So, if poly_L is a list of univariate polynomials, and you want the
padded coefficient lists out to degree d, then
   [p.padded_list(d) for p in poly_L]
is the list of coefficient lists. To compile all these coefficient
lists into one, you can do
   add([p.padded_list(d) for p in poly_L], [])

Example:
sage: C.<a,b,c,d,e,f> = QQ[]
sage: R.<x> = C[]
sage: C.<a,b,c,d,e,f> = QQ[]
sage: R.<x> = C[]
sage: R.random_element?
sage: poly_L = [R.random_element(degree=(0,4)) for _ in range(4)]
sage: poly_L
[(c^2 + b*d - 3*c)*x^2 + (-1/17*b^2 + 20*b*c + 2/3*d*f - c)*x -
1/2*a*b - b*c - 10*e, (-2*b*c - 1/2*a*d - 3*d*e - a*f + 5*d*f)*x - b +
3/7*c - 4, (-a*d + 1/2*f^2 - 2*b - 2*f)*x + 1/2*b*d + 1/2*d^2 +
15/2*c*e - 1/18*d*f - 3/5*c, 1/3*b^2 + 1/6*a*c - 2*b*e - 1/3*d*f - e]
sage: for p in poly_L: print p.padded_list(4)
....:
[-1/2*a*b - b*c - 10*e, -1/17*b^2 + 20*b*c + 2/3*d*f - c, c^2 + b*d -
3*c, 0]
[-b + 3/7*c - 4, -2*b*c - 1/2*a*d - 3*d*e - a*f + 5*d*f, 0, 0]
[1/2*b*d + 1/2*d^2 + 15/2*c*e - 1/18*d*f - 3/5*c, -a*d + 1/2*f^2 - 2*b
- 2*f, 0, 0]
[1/3*b^2 + 1/6*a*c - 2*b*e - 1/3*d*f - e, 0, 0, 0]
sage: add([p.padded_list(4) for p in poly_L],[])
[-1/2*a*b - b*c - 10*e, -1/17*b^2 + 20*b*c + 2/3*d*f - c, c^2 + b*d -
3*c, 0, -b + 3/7*c - 4, -2*b*c - 1/2*a*d - 3*d*e - a*f + 5*d*f, 0, 0,
1/2*b*d + 1/2*d^2 + 15/2*c*e - 1/18*d*f - 3/5*c, -a*d + 1/2*f^2 - 2*b
- 2*f, 0, 0, 1/3*b^2 + 1/6*a*c - 2*b*e - 1/3*d*f - e, 0, 0, 0]

Cheers,
Simon

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to