Ask Your Question
1

How to reorder terms in a polynomial to follow a specific order.

asked 2021-04-09 00:44:31 +0200

eli_is_strong gravatar image

Hi everyone,

I have code in Sagemath that will give me various polynomials. However, I need these polynomials to be ordered in a specific way. For example, my code will output a polynomial that looks like this:

t^2-t+1

but I need it to be outputted like this:

1-t+t^2.

Is there any way to do this? Thanks, I appreciate the help.

edit retag flag offensive close merge delete

Comments

Max Alekseyev gravatar imageMax Alekseyev ( 2021-04-09 01:08:27 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-04-09 22:27:43 +0200

mwageringel gravatar image

For displaying the polynomial, you could convert it to a power series, which are ordered the other way around:

sage: var('t');
sage: f = t^2 - t + 1
sage: R = PowerSeriesRing(QQ, 't')
sage: print(R(f))
1 - t + t^2
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-04-09 00:44:31 +0200

Seen: 221 times

Last updated: Apr 09 '21