Ask Your Question
1

Can I display a polynomial with higher order than 20?

asked 1 year ago

aleph gravatar image

updated 1 year ago

slelievre gravatar image

I have a large polynomial product that I know has at least 100 terms but when I try to display it with the command mypoly.O(101) I only see an answer of the form lower_degree_stuff + + 6x^18 + 6x^19 + O(x^20)

Is there a way to tell SageMath that I really, really do want the whole thing up to the 100th degree?

Thanks for any help, especially if this question is basic (I have looked and been unable to turn up an answer, though).

Preview: (hide)

Comments

What happens if you just use mypoly, rather than mypoly.O(101)? Also, what does type(mypoly) return?

John Palmieri gravatar imageJohn Palmieri ( 1 year ago )

mypoly doesn't return anything; type(mypoly) returns <class 'sage.rings.power_series_poly.powerseries_poly'="">

Does it help to know that I am running SageMath through CoCalc?

aleph gravatar imagealeph ( 1 year ago )

What does print(mpoly) do? It may be helpful to provide more details or (even better, if it's possible) a minimal example displaying the behavior you're describing.

John Palmieri gravatar imageJohn Palmieri ( 1 year ago )

I appreciate your looking into this a bit! Here's the code I have:

R.<x>=PowerSeriesRing(ZZ)

f1=1/(1-x)

f5=1/(1-x^5)

f10=1/(1-x^10)

f25=1/(1-x^25)

partition_poly=f1*f5*f10*f25

partition_poly.O(11) prints out the polynomial up to the 10th degree, as expected

partition_poly.O(101) prints out up to the 19th power as noted in original post

print(partition_poly) does exactly the same as previous line

aleph gravatar imagealeph ( 1 year ago )

1 Answer

Sort by » oldest newest most voted
3

answered 1 year ago

updated 1 year ago

The issue is in the definition of R. From the documentation for PowerSeriesRing, one of the arguments is

  • "default_prec" -- the default precision used if an exact object must be changed to an approximate object in order to do an arithmetic operation. If left as "None", it will be set to the global default (20) in the univariate case, and 12 in the multivariate case.

So if you want higher precision than degree 20, you have to specify that when you define the ring:

R.<x> = PowerSeriesRing(ZZ, 51)
f25 = 1/(1-x^25)
print(f25)

gives 1 + x^25 + x^50 + O(x^51) while

R.<x> = PowerSeriesRing(ZZ, 200)
f25 = 1/(1-x^25)
print(f25)

gives 1 + x^25 + x^50 + x^75 + x^100 + x^125 + x^150 + x^175 + O(x^200).

Preview: (hide)
link

Comments

I am so grateful to you for pointing this out. THANK YOU!

aleph gravatar imagealeph ( 1 year ago )

@aleph: you can accept the answer by clicking the check mark icon at the top left of the answer, below the answer's score and the upvote and downvote buttons. This will mark the question as answered.

slelievre gravatar imageslelievre ( 1 year ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 1 year ago

Seen: 222 times

Last updated: Jul 19 '23