12.04.2011 03:19, Aaron S. Meurer пишет:
> 
> On Apr 11, 2011, at 4:28 PM, Alexey U. Gudchenko wrote:
> 
>> 12.04.2011 02:20, Aaron S. Meurer пишет:
>>> On Apr 11, 2011, at 4:12 PM, Alexey U. Gudchenko wrote:
>>> 
>>>> 12.04.2011 01:56, Ronan Lamy пишет:
>>>>> Le lundi 11 avril 2011 à 15:42 -0600, Aaron S. Meurer a écrit
>>>>> :
>>>>>> On Apr 11, 2011, at 2:25 AM, smichr wrote:
>>>>>> 
>>>>>>> Should `Integral(x, (x, 1, 2)) == Integral(y, (y, 1, 2))`
>>>>>>> be True? If so, smichr branch 2068b has a commit that
>>>>>>> makes this testing possible.
>>>>>>> 
>>>>>> This is a good question.  For one thing, == is not
>>>>>> mathematical equality but exact equality, so there is no
>>>>>> reason why it should have to be True.  So my initial
>>>>>> response is that no, it should not.
>>>>>> 
>>>>> I think it should. x and y are bound symbols that have no
>>>>> meaning outside the integrals, so their identity should be
>>>>> completely irrelevant. In fact, they should probably be
>>>>> replaced with dummies upon instantiation of the Integral.
>>>>> 
>>>>> 
>>>> 
>>>> Mathematically equal. (especially when assumptions for symbols
>>>> are equal too).
>>>> 
>>>> Another question what means "==" in SymPy: mathematical or not
>>>> (pythonic?).
>>>> 
>>>> Aaron, what do you mean by "exact equality"? E.g Does the
>>>> "Max(1, 2, x)" exact equal to the "Max(2, x)" or not?
>>>> 
>>>> 
>>>> -- Alexey U.
>>> 
>>> "Exact" meaning it checks if the objects are equal.  The usual
>>> example is that we have
>>> 
>>>>>> (x + 1)**2 == x**2 + 2*x + 1
>>> False
>>> 
>>> I thought Max(1, 2, x) automatically reduced to Max(2, x).  In
>>> that case, then, obviously they would be equal with ==.  Also you
>>> would have Max(2, x) == Max(x, 2) because it internally uses a
>>> data structure that does not care about order (set or frozenset).
>>> 
>> 
>>> Whenever you see == in SymPy, it is specifically assuming this
>>> exact/object equality.
>>> 
>>> Another thing to consider is:
>>> 
>>> In [190]: hash(Integral(x, (x, 0, 1))) Out[190]:
>>> -9173880960074697984
>>> 
>>> In [191]: hash(Integral(y, (y, 0, 1))) Out[191]:
>>> −299967655319032172
>>> 
>>> A == B should imply hash(A) == hash(B).
>>> 
>>> Aaron Meurer
>>> 
>> 
>> About Max, you are right exactly.
>> 
>> But why not to use data structure in Integrals too (do not care
>> about dummy variable) ?
>> 
>> -- Alexey U.
> 
> Well, I guess it comes down to whether or not we should do that.  By
> the way, for my hypothetical above, they should *not* compare equal
> (because even though the order of integration doesn't matter
> mathematically, it actually makes a difference computationally).


If we talk about the order of integration (two integrals by x, y) then
the order of integration doesn't matter mathematically, but only for
continues functions. So it is not autamatically equal.

If we talk about order of Max(2, x) == Max(x, 2) or not...

Yes, it is pity that there is no operator "===" in Python.

While I have concerned the Max's code, I have observed that it was very
unconvinient to use ">" which implemented as relational operation with
SymPy expression, and "==" in pythonic way at the same time.

I am afraid (I have not examine this exactly yet) that special procedure
is needed to separate aims (and therefore implementations) comparing
hashes and so on (aims of hashes are caching?).


-- 
Alexey U.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to