On Wed, 7 Apr 2021 at 12:24, David Bailey <[email protected]> wrote:
>
> On 07/04/2021 11:59, Oscar Benjamin wrote:
> > On Wed, 7 Apr 2021 at 10:28, 'Bruce Allen' via sympy
> > <[email protected]> wrote:
> >>
> >> Why does subs() work in one case, and not in the other?
> > I'm not sure. I can't reproduce this without u though. I tried making
> > u=(the srepr output) but then the substitution worked fine.
>
> That question made me wonder if
>
> Symbol('a', real=True, positive=True) and Symbol('a')
>
> Are the same objects. Logically I imagine they can't be - either one symbol 
> is mutated or they remain distinct.

They are distinct:

In [25]: Symbol('a', positive=True) == Symbol('a', positive=True)
Out[25]: True

In [26]: Symbol('a', positive=True) == Symbol('a')
Out[26]: False

Symbols are immutable so they can not be mutated. Symbols created with
the same name and assumptions are considered equivalent. What is less
obvious is that this also applies where the assumptions can be
inferred as equivalent. For example there is no need to specify
real=True at the same time as positive=True because positive implies
real:

In [27]: Symbol('a', positive=True) == Symbol('a', positive=True, real=True)
Out[27]: True

In Bruce's example both symbols seem to have the same assumptions so
this shouldn't be the issue.


Oscar

-- 
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/CAHVvXxSSh%3DWHMTvxuF4QyFvswnAGvXdc3TJTsRgTa%2BwZZfC56g%40mail.gmail.com.

Reply via email to