Search code examples
pythonmathsympy

Identity in sympy


I want this to become this

I searched a lot, but I couldn't find it. Just tell me the name of the function. It's enough

1

(5y-3x)**2

to:

25y-30xy+9x*2 How?

please help me!

I tested with factor() and it didn't work !


Solution

  • expand()

    >>> expand((x + 1)**2)
     2
    x  + 2⋅x + 1
    
    >>> expand((x + 2)*(x - 3))
     2
    x  - x - 6
    

    from https://docs.sympy.org/latest/tutorials/intro-tutorial/simplification.html#expand