Understood. Thank you for your explanation.

On Friday, April 29, 2022 at 3:50:43 PM UTC-4 [email protected] wrote:

> atoms() works at the expression tree level, meaning it will only
> return something if it exactly appears in the expression. In the
> example x - 1, the expression is Add(x, -1), which doesn't contain 1.
> It instead contains -1. Note that SymPy doesn't have a subtraction
> class. Subtraction is represented as addition of a negative, where the
> negative is represented as multiplication by -1 (or in the case of
> number, just the negative number).
>
> Aaron Meurer
>
> On Fri, Apr 29, 2022 at 12:15 PM Audrius-St <[email protected]> wrote:
> >
> > Hello,
> >
> > import sympy as sp
> >
> > In the following example code, it is not clear to me why the first 
> expression returns
> > expr.atoms(sp.S(1)) {1}
> >
> > whereas the second expression returns
> > expr.atoms(sp.S(1)) set()
> >
> > def main():
> >
> > x = sp.symbols('x')
> >
> > expr = x + 1
> > print(f'expr.atoms(sp.S(1)) {expr.atoms(sp.S(1))}')
> >
> > expr = x - 1
> > print(f'expr.atoms(sp.S(1)) {expr.atoms(sp.S(1))}')
> >
> >
> > if __name__ == "__main__":
> > main()
> >
> >
> > --
> > 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 [email protected].
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/bcd40bf3-44aa-4297-a218-2c71aadd3682n%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/98002b01-018f-4ed2-a814-153fba0cfbe4n%40googlegroups.com.

Reply via email to