# Can I display a polynomial with higher order than 20?

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).

edit retag close merge delete

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

( 2023-07-17 05:08:12 +0200 )edit

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?

( 2023-07-18 23:02:09 +0200 )edit

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.

( 2023-07-18 23:39:39 +0200 )edit

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

( 2023-07-19 02:31:51 +0200 )edit

Sort by ยป oldest newest most voted

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).

more

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

( 2023-07-19 13:27:37 +0200 )edit

@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.

( 2023-07-21 15:47:03 +0200 )edit