-
Notifications
You must be signed in to change notification settings - Fork 172
Closed
Description
Hello,
Please find below a Sympy MWE that describes my question in the title:
import sympy as sp
def main():
x, y = sp.symbols('x, y')
a22, a21, a12, a11, a10, a01, a00 = sp.symbols('a22, a21, a12, a11, a10, a01, a00')
b60, b53, b32, b21, b10, b00 = sp.symbols('b60, a53, a32, b21, b10, b00')
expr_1 = a22*x**2*y**2 + a21*x**2*y + a12*x*y**2 + a11*x*y + a10*x + a01*y + a00
expr_2 = b60*x**6 + b53*x**5*y**3 + b32*x**3*y**2 + b21*x**2*y + b10*x + b00
expr = expr_1 + expr_2
poly_coeffs = sp.poly(expr, [x, y]).coeffs(order='grevlex')[::-1]
poly_monoms = sp.poly(expr, [x, y]).monoms(order='grevlex')[::-1]
print(f'expr = {expr} \n')
print(f'expr coefficients: {len(poly_coeffs)} {poly_coeffs} \n')
print(f'expr monomials: {len(poly_monoms)} {poly_monoms} \n')
if __name__ == "__main__":
main()
gives the results
expr = a00 + a01*y + a10*x + a11*x*y + a12*x*y**2 + a21*x**2*y + a22*x**2*y**2 + a32*x**3*y**2 + a53*x**5*y**3 + b00 + b10*x + b21*x**2*y + b60*x**6
expr coefficients: 10 [a00 + b00, a01, a10 + b10, a11, a12, a21 + b21, a22, a32, b60, a53]
expr monomial degrees: 10 [(0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 2), (6, 0), (5, 3)]
Are similar functions currently available in Symbolics.jl?
A search of Symbolics.jl issues did turn up the following discussion:
However, a search for "coefficient" in the Symbolics.jl documentation only gave a link to Gröbner bases.
Metadata
Metadata
Assignees
Labels
No labels