MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Interval[{a,b}]-Interval[{a,b}] = 0?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66691] Re: Interval[{a,b}]-Interval[{a,b}] = 0?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 27 May 2006 03:51:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 27 May 2006, at 07:27, David W. Cantrell wrote:


> Concerning the fact that Interval[{a,b}]-Interval[{a,b}]=0 in  
> Mathematica,
> Andrzej Kozlowski wrote:
>
>> Note that in Mathematica you will get things like:
>>
>> In[8]:=
>> "a dog" - "a dog"
>>
>> Out[8]=
>> 0
>>
>> Now, one could also argue that this is a bug, since first of all
>> subtraction of strings (or animals) is not defined
>>
>
> No animal was obliterated in producing that example! We're obviously
> dealing merely with strings, not dogs. Use-mention distinction.
>

Well, actually things are not as simple as that. For example, what we  
call the number 1 is not actually a number but, depending on context,  
a letter that represents it, a few pixels on the monitor, and so  
on... I dare say, it would be possible to implement dogs as strings  
in Mathematica just as one implements integers, circles, real numbers  
etc... Philosophically there need not be any essential difference  
between dog and numbers, cf. Quine "On What There Is." etc.


>
> Apparently, Mathematica does have some "arithmetic" which it applies
> to strings. As further examples:
>
> In[4]:= "hgf" - "abcd"
> Out[4]= -"abcd" + "hgf"
>
> In[5]:= "hgf" + "hgf"
> Out[5]= 2*"hgf"
>
> In[6]:= 0*"DWC"
> Out[6]= 0
>
> That doesn't disturb me. I might even applaud it if I knew of a use  
> for it.
>

There is no "arithmetic of strings" involved here at all. What you  
are seeing is only a consequence of the Orderless attribute of Plus,  
the canonical ordering of all Mathematica objects, and a few other  
facts. To see what I mean :


1 + "cat" + DisplayFunction


"cat" + DisplayFunction + 1


0*HoldAll


0



Expand[(Sin[x] + dog + DisplayFunction)*(1 + "cat")]


"cat"*DisplayFunction + DisplayFunction + "cat"*dog + dog + "cat"*Sin 
[x] + Sin[x]


It is probably possible to view Mathematica as something like a  
commutative algebra generated by all well formed expressions,  
including symbols, strings, names of functions, and so on, with  
certain relations. But certainly there is no kind of arithmetic of  
strings.



>
>
>> and besides there is no reason to assume that the second dog is the
>> same as the first one.
>>
>
> As I said, no dogs are involved. And the first string is clearly the
> same as the second.
>

Hmm.. you seem to be in a rather unhumorous mood today... Do we  
really need these silly smileys ;-) ? Anyway, it is nothing to do  
with it being a string. You will get the same thing if you subtract  
any two symbols in Mathematica, which do not have any UpValues  
involving Plus defined.



>
>
>> Unfortunately Mathematica is very simple minded and when it has
>> no rules for dealing with some object you can always subtract it
>> from itself and get 0
>>
>
> I don't really mind that, when Mathematica has no rules for dealing  
> with
> some object, you can always subtract it from itself and get 0. What  
> I mind
> is that, since Mathematica implements interval arithmetic, it has no
> correct rule for dealing with something as trivial as
> Interval[{a,b}]-Interval[{a,b}]. After all, if one is going to  
> claim to
> have implemented an arithmetic specialized for a certain type of  
> object,
> then one should have already had the appropriate rules implemented!
>

Mathematica does not implement interval arithmetic for symbolic  
endpoints. In the same way Complex[a,b] is not a complex number in  
Mathematica, unless a and b are real numbers, nor is Rational[a,b], a  
rational number unless both a and be are integters. Mathematica is  
quite consistent in this respect.

I do not think  this kind of implementation of symbolic Interval  
arithmetic would alone be of any value. For example, it would in no  
way help to prevent the problem with Limit described by Daniel in his  
post (which RJF quite falsely claimed was do to the supposed "bug" he  
discovered). Even if Mathematica always converted Interval[{a,b}] -  
Interval[{a,b}] to Interval[{a-d, b-c}], it would still turn f 
[Interval[{a,b}]]-f[Interval[{a,b}]] to 0, whenever f was a function  
for which Mathematica could not convert f[Interval[a,b]] to Interval 
[something]. To prevent this kind of problems a much more  
sophisticated approach would be needed, which probably must involve  
leaving all expressions involving Interval unevaluated unless they  
can be reduced to explicit Intervals. Even if this sort of thing were  
to be implemented, it will almost certainly apply only to numeric  
expressions (as in the "Limit bug" example).  Implementing purely  
symbolic interval arithmetic would be, in my opinion, useless and  
contrary to the way Mathematica normally deals with such matters ( as  
in the already mentioned examples of Complex and Rational).

Andrzej Kozlowski

Tokyo, Japan






>
> As examples of rules which I think should be implemented, let's  
> consider
> negation, addition and subtraction. (Rather than using Mathematica's
> Interval[{a,b}] notation, I'll just use [a,b].) I presume these three
> can be found in any good text on interval analysis:
>
> For extended real a, b, c and d,
>
> -[a, b] = [-b, -a]
>
> [a, b] + [c, d] = [a+c, b+d]
>
> [a, b] - [c, d] = [a-d, b-c]
> which follows from the two previous, via x - y = x + (-y).
>
> One might think that trouble occurs if we get Infinity - Infinity
> someplace. Mathematica says that is Indeterminate, and so we might say
> that, if we get [Indeterminate, _ ] or [ _, Indeterminate], then  
> the result
> should just be Indeterminate. I suggest, however, that, since we're  
> dealing
> with interval arithmetic, the result [-Infinity, Infinity] would be
> somewhat more appropriate. In any event, there is not actually any  
> trouble.
>
> Regards,
> David W. Cantrell
>



  • Prev by Date: Re: How to make results from Integrate and NIntegrate agree
  • Next by Date: parenthesis in reactions...
  • Previous by thread: Re: Interval[{a,b}]-Interval[{a,b}] = 0?
  • Next by thread: Re: Re: Interval[{a,b}]-Interval[{a,b}] = 0?