Ask Your Question
1

Can I display a polynomial with higher order than 20?

asked 2023-07-16 14:34:40 +0100

aleph gravatar image

updated 2023-07-21 15:47:42 +0100

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

edit retag flag offensive close merge delete

Comments

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

John Palmieri gravatar imageJohn Palmieri ( 2023-07-17 05:08:12 +0100 )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?

aleph gravatar imagealeph ( 2023-07-18 23:02:09 +0100 )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.

John Palmieri gravatar imageJohn Palmieri ( 2023-07-18 23:39:39 +0100 )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

aleph gravatar imagealeph ( 2023-07-19 02:31:51 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-19 05:33:06 +0100

updated 2023-07-19 18:52:11 +0100

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

edit flag offensive delete link more

Comments

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

aleph gravatar imagealeph ( 2023-07-19 13:27:37 +0100 )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.

slelievre gravatar imageslelievre ( 2023-07-21 15:47:03 +0100 )edit

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: 2023-07-16 14:34:40 +0100

Seen: 162 times

Last updated: Jul 19 '23