Hi Oliver,

On 2 Feb., 14:42, William Stein <[email protected]> wrote:
> On Thu, Feb 2, 2012 at 2:03 AM, Oliver Block <[email protected]> wrote:
> > Is there a way to print it using ascending order of the degrees, i.e as
> > follows?
>
> > 1 + 2*X + X^2
>
> > And is the same possible using the latex output function?
>
> I don't think so.

I don't think that there is a switch changing the way of how the
polynomials are shown.

> It is perhaps potentially helpful that power series do print in the other 
> order.

Another work around: You could define your univariate polynomial ring
as a "multivariate polynomial ring with one variable". The benefit is
that you could then define a negative monomial order on it - and this
is used to determine the string representation of a polynomial.

sage: P.<x> = PolynomialRing(QQ, 1, order='neglex')
sage: P
Multivariate Polynomial Ring in x over Rational Field
sage: x^2 + 2*x + 1
1 + 2*x + x^2

Of course, this approach has a disadvantage if you do something where
the monomial order matters. However, arithmetic for multivariate rings
with one variable is not bad, compared with "proper" univariate rings:

sage: %timeit p = (3*x^2+2*x+2)^7
625 loops, best of 3: 41.5 µs per loop
sage: Q.<x> = QQ[]
sage: Q
Univariate Polynomial Ring in y over Rational Field
sage: %timeit p = (3*x^2+2*x+2)^7
625 loops, best of 3: 51.6 µs per loop

If the univariate ring Q is better for your computations, then you
could work there, and switch to the multivariate ring only in the very
end, when you determine the string representation:

sage: p = x^2+x+1
sage: p
x^2 + x + 1
sage: p.parent() is Q
True
sage: P(p)
1 + x + x^2

The same should hold for the LaTeX representation:

sage: latex(p)
x^{2} + x + 1
sage: latex(P(p))
1 + x + x^{2}

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