Skip to content

coefficients() function more consistent between Expressions and polynomial rings #17922

Open
@sagetrac-JoalHeagney

Description

@sagetrac-JoalHeagney

The different behaviour between the two rings consists of

  1. the coefficients(sparse=True) (which is default) method returns a list of pairs in SR, and a list in PolynomialRing,
  2. Expression.dict() does not exist.
    Example:
y = 3*x^3 + 2*x^2 - 4*x
print(y)
type(y)

Gives:

3*x^3 + 2*x^2 - 4*x
<type 'sage.symbolic.expression.Expression'>

And

M = matrix(SR,[[1,2],[0,-2]])
ch = M.charpoly()
print(ch)
type(ch)

gives

x^2 + x - 2
<class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>

But:

y.coeffs()

returns

[[−4,1],[2,2],[3,3]]

and

ch.coeffs()

returns

[−2,1,1]

I'd prefer if these two functions returned the same format, preferably the Expression format, as having access to the index allows list comprehension tastiness.

Component: algebra

Keywords: coeffs, rings, polynomials, expression, symbolic

Issue created by migration from https://trac.sagemath.org/ticket/17922

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions