[sympy] Re: Unexpanded coefficients of a polynomial
BTW : >>> x, y = symbols("x, y") >>> P = 360*x*y**71*(y**72 - 1)**4 + 360*x**4 *(x**5 - 1)**7 >>> P.args (360*x**4*(x**5 - 1)**7, 360*x*y**71*(y**72 - 1)** 4) >>> P.func.make_args(P) (360*x**4*(x**5 - 1)**7, 360*x*y**71*(y**72 - 1 )**4) >>> P.func.make_args(P)==P.args True HTH, Le vendredi 28 avril 2023 à 04:05:54 UTC+2, smi...@gmail.com a écrit : > The things you call "coefficients" are called "terms" of the sum. If you > know you have a sum then `eq.args` will give you the terms. If the equation > might have a single term then `Add.make_args(eq)` will give you 1 or more > terms. > > /c > > On Thursday, April 27, 2023 at 12:02:33 PM UTC-5 distan...@gmail.com > wrote: > >> Hello. >> >> How can I get all unexpanded coeffs of a polynomial? >> >> For example, Poly(360*x*y**71*(y**72 - 1)**4 + 360*x**4*(x**5 - 1)**71, >> x).all_coeffs() should return [360*y**71*(y**72 - 1)**4, 360*x**4*(x**5 - >> 1)**71], but, instead, it returns expanded long expression. >> >> How to avoid this and return untouched coeffs? >> >> Thank you. >> > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/92a9d330-1d71-4366-95e7-bedd4ca48171n%40googlegroups.com.
[sympy] Re: Unexpanded coefficients of a polynomial
The things you call "coefficients" are called "terms" of the sum. If you know you have a sum then `eq.args` will give you the terms. If the equation might have a single term then `Add.make_args(eq)` will give you 1 or more terms. /c On Thursday, April 27, 2023 at 12:02:33 PM UTC-5 distan...@gmail.com wrote: > Hello. > > How can I get all unexpanded coeffs of a polynomial? > > For example, Poly(360*x*y**71*(y**72 - 1)**4 + 360*x**4*(x**5 - 1)**71, > x).all_coeffs() should return [360*y**71*(y**72 - 1)**4, 360*x**4*(x**5 - > 1)**71], but, instead, it returns expanded long expression. > > How to avoid this and return untouched coeffs? > > Thank you. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/6cd077a4-91f9-48e1-9d66-86c2c451f984n%40googlegroups.com.
Re: [sympy] Unexpanded coefficients of a polynomial
Poly is designed to expand all polynomials out. If you just want the terms of an expression as you've written it you can use Add.make_args(). I wouldn't really call these the "coefficients" of the expression though. Aaron Meurer On Thu, Apr 27, 2023 at 11:02 AM Paul Royik wrote: > > Hello. > > How can I get all unexpanded coeffs of a polynomial? > > For example, Poly(360*x*y**71*(y**72 - 1)**4 + 360*x**4*(x**5 - 1)**71, > x).all_coeffs() should return [360*y**71*(y**72 - 1)**4, 360*x**4*(x**5 - > 1)**71], but, instead, it returns expanded long expression. > > How to avoid this and return untouched coeffs? > > Thank you. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sympy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/eda7343d-f557-48b2-85e0-d52162a12bb5n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6J9gJvbDpJzgcsLZ7X7U92F%2Bk1F54bC4QSF%2Bjueh%3DQBBA%40mail.gmail.com.
[sympy] Unexpanded coefficients of a polynomial
Hello. How can I get all unexpanded coeffs of a polynomial? For example, Poly(360*x*y**71*(y**72 - 1)**4 + 360*x**4*(x**5 - 1)**71, x).all_coeffs() should return [360*y**71*(y**72 - 1)**4, 360*x**4*(x**5 - 1)**71], but, instead, it returns expanded long expression. How to avoid this and return untouched coeffs? Thank you. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/eda7343d-f557-48b2-85e0-d52162a12bb5n%40googlegroups.com.