Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Fw: A Level 2 query - X-X



Of course there are also special cases for X*X   vs X^2,   X+X  vs 2*X  etc..

More particularly...

On 7/3/2013 4:07 PM, Ian McIntosh wrote:

I would count writing Y = X when you don't mean they are identical, just possibly different values in the same range, as a programming bug.  It's up to this standard or the language standard though.

If X is a compound structure, most languages distinguish between
Y:= copy(X)
  and
Y:=X     { which would mean that X is the address of a structure and Y is the address of the same structure}

For a language in which  two structures with the same values are hashed to the same location, there would
be only one copy of the interval [5,10] , regardless of how it was computed,
unless some effort were made to change this "unique data" behavior.

 One way is to attach to each interval a timestamp or some other index,
so that two structures X with the same index can be treated as totally correlated and X-X is zero,  if X is finite.

I think one could handle this either way -- checking for "same address" subtraction or just assuming the
two data are independent.   I think it is slightly more utilitarian
that the interval library should assume independence of inputs, but a clever programmer
might use some extra checks.   e.g.  mymult(X,Y) :=  if sameaddress(X,Y) then intervalsquare(X) else intervalmult(X,Y)

RJF