Re: Question on Rescale[]
- To: mathgroup at smc.vnet.net
- Subject: [mg103329] Re: Question on Rescale[]
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Tue, 15 Sep 2009 06:54:19 -0400 (EDT)
- References: <200909141110.HAA08833@smc.vnet.net> <h8nj13$cej$1@smc.vnet.net>
Well, probably either Indeterminate or an error message. :-)
It does seem curious that the system comes up with such an irrational
number, doesn't it? I looked at the available part of the source code
by removing the ReadProtected attribute, but it doesn't contain the code
responsible for this result.
However, I found it quite shocking that the code is written with bad
practices and I immediately noticed a bug. Among others, it contains
the following definition:
Rescale[
System`Dump`x_,
{DirectedInfinity[System`Dump`d_], System`Dump`a_},
{DirectedInfinity[D], System`Dump`A_}
] :=
Rescale[
System`Dump`x,
{System`Dump`a, DirectedInfinity[System`Dump`d]},
{System`Dump`A, DirectedInfinity[D]}
]
It has been noted several times on this list that it is a bad practice
to use private symbols starting with capital letters, because it may
lead to accidental collisions with built-in symbols. The capital D
(which also happens to be the function computing the derivative) is used
throughout the code, and since D is in System`, of course it did not
become part of the private context System`Dump` (as can be seen in the
code above).
Furthermore, in this paricular defintion, D is used instead of the
pattern D_, which is simply a bug.
Now, it is true that I don't see how this (most likely accidental)
re-use of System`D as a private symbol could cause any problems *in this
specific code*, but nevertheless I find it discomforting.
On 2009.09.15. 10:25, DrMajorBob wrote:
> What did you expect?
>
> Bobby
>
> On Mon, 14 Sep 2009 06:10:05 -0500, Alexey<lehin.p at gmail.com> wrote:
>
>> Hello,
>> Consider the following:
>>
>> In[1]:= r=Rescale[x,{min,max}]
>> Rescale[2,{-Infinity,Infinity}]
>> r/.{x->2,min->-Infinity,max->Infinity}
>> Out[1]= -(min/(max-min))+x/(max-min)
>> Out[2]= 1/Sqrt[2]
>> During evaluation of In[1]:= \[Infinity]::indet: Indeterminate
>> expression 0 (-\[Infinity]) encountered.>>
>> Out[3]= Indeterminate
>>
>> At this moment I can not imagine why Rescale[2,{-Infinity,Infinity}]
>> gives 1/Sqrt[2]. Is this behavior correct?
>>
- References:
- Question on Rescale[]
- From: Alexey <lehin.p@gmail.com>
- Question on Rescale[]