On Thu, Aug 4, 2022 at 2:57 PM artur zanon <turcaturq...@gmail.com> wrote:
>
> Hi there! I have an issue and I found no solutions.
> After using expand(), i'd like to gather the individual terms of my resulting 
> equation.
> Example:
> Initial equation: x*(x + 2)
> After expand(): x**2 + 2*x
> I'd like a way to get the two resulting terms: x**2 and 2*x.
> Using split() works most of the time, but when i have fractions, it does not.

What do you mean by split()? There is no such SymPy function from what
I can see. Do you mean the string method str.split? You should not use
string functions to do symbolic manipulations on SymPy expressions.

The best way to get what you want is to use Add.make_args, like

>>> Add.make_args(x**2 + 2*x)
(x**2, 2*x)

Aaron Meurer

> Example: a/(a + 2) + b/(a + 2). Using split() here does not work.
>
> Thanks!
>
> --
> 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/c6e2c084-469b-435d-8a2c-6a19bdb22e88n%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%3D6%2BiJytqLK0TofQkXZCdm5CzO%2BiofD-g3Fd9SULbBi9e%3DQ%40mail.gmail.com.

Reply via email to