Re: = ?

134 views
Skip to first unread message

Bill Rowe

unread,
Oct 8, 2011, 2:44:45 PM10/8/11
to
On 10/6/11 at 4:23 AM, w...@snafu.de (Dr. Wolfgang Hintze) wrote:

>What about setting up a regular column "esoteric of the week" naming
>functions that are rarely used ?

The difficulty is a determination of rarely used. Who decides?
And how?

>I would start with

>Clip[x]

>which I (shame on me) didn't know until this evening. Did you?

Yes, but for me Clip is not a rarely used function. It is not
that I use it as often as say /@. But, it is a function I use
often enough I don't need to look up the syntax. For me at
least, the operational definition of rarely used would be those
functions I have to look up syntax to use correctly.

Also, rarely used isn't really equivalent to esoteric. For
example, I rarely use DSolve and would have to look up syntax to
be sure I was correctly using it. But I wouldn't consider DSolve
as esoteric.


Oleksandr Rasputinov

unread,
Oct 9, 2011, 3:53:24 AM10/9/11
to
On Sat, 08 Oct 2011 20:15:13 +0100, Oleksandr Rasputinov
<oleksandr_...@hmamail.com> wrote:

> On Sat, 08 Oct 2011 19:44:45 +0100, Bill Rowe <read...@sbcglobal.net>
> wrote:
>
>> On 10/6/11 at 4:23 AM, w...@snafu.de (Dr. Wolfgang Hintze) wrote:
>>
>>> What about setting up a regular column "esoteric of the week" naming
>>> functions that are rarely used ?
>>
>> The difficulty is a determination of rarely used. Who decides?

>> And how? ... For me at least, the operational definition of rarely


>> used would be those functions I have to look up syntax to use correctly.
>>
>

> Along these lines, I would suggest a family of undocumented Internal`
> functions that can be quite useful:
>
> Internal`InheritedBlock:
> works just like Block, except that the definitions of the localized
> symbols are copied from the global environment (including Attributes,
> Options, etc.). Useful for temporarily overriding the properties of
> System` functions without going through the Unprotect/modify/Protect
> dance, for example.
>
> {Internal`Bag, Internal`StuffBag, Internal`BagPart}:
> described by Daniel Lichtblau here:
> <http://stackoverflow.com/questions/6691491/implementing-a-quadtree-in-mathematica>.
> Apart from being useful for building your own data structures, Bags are
> considered to be scalars by the Mathematica compiler and can be used to
> build up lists inside compiled code without AppendTo (and its associated
> CopyTensor). (Sow/Reap use Bags but at present don't work in compiled
> code because their ability to associate a tag with each expression
> relies on pattern matching.)
>
> Internal`Deflatten:
> Somewhat similar to Partition, but only works with 1-d Lists and
> operates based on a structural specification as given by Dimensions.
> Similar to the RESHAPE function from Fortran 90. Say we have a list
> (which must be a full-rank tensor) with some nested structure:
>
> lst = Partition[{{11, 12, 13}, {21, 22, 23}, {31, 32, 33}}, {2, 1}, 1];
> dims = Dimensions[lst]
>
> {2, 3, 2, 1}
>
> lst == Internal`Deflatten[Flatten[lst], dims]
>
> True
>
> an important point to note about Internal`Deflatten is that a
> dimensional specification must not be given that would require more
> elements in the source array than actually exist in order to produce a
> full-rank tensor result. That is, for Internal`Deflatten[lst, dims],
> Times @@ dims <= Length@Flatten[lst] must be fulfilled, otherwise the
> kernel will crash.

While I remember, I will add:

{Internal`$EqualTolerance, Internal`$SameQTolerance}:
As discussed recently in the thread archived here,
<http://www.mathkb.com/Uwe/Forum.aspx/mathematica/21194/Numerical-accuracy-precision-this-is-a-bug-or-a-feature>,
Equal and SameQ apply a certain tolerance when comparing real numbers.
From their respective documentation pages:

"Approximate numbers with machine precision or higher are considered equal
if they differ in at most their last seven binary digits (roughly their
last two decimal digits)." (Internal`$EqualTolerance = 2.10721)

and

"SameQ ... considers Real numbers equal if they differ in their last
binary digit." (Internal`$SameQTolerance = 0.30103)

One may or may not agree with the principle behind the application of such
a tolerance, but it turns out that this can be controlled by adjusting the
values given above. However, Alexey Popkov has correctly noted here
<http://stackoverflow.com/questions/4983885/is-there-a-normal-equalq-function-in-mathematica>
that setting these to zero does not necessarily guarantee that two
different numbers will not compare Equal. In fact it appears that the
units of these values are not exactly Log[2]/Log[10] ulps, but
Log[2]/Log[10] ulps _relative to those of a machine precision number_: in
other words, for arbitrary precision numbers, negative values may be
required in order to make the tolerance small enough. Fortunately, it is
possible to make it arbitrarily small because a value of -Infinity is
allowed, in which case Alexey's example from the link above works as
anticipated:

Block[{Internal`$EqualTolerance = -Infinity},
Cases[
Table[
a = SetPrecision[1., n]; b = a + 10^-n;
{n, a == b, RealDigits[a, 2] === RealDigits[b, 2], Order[a, b] == 0},
{n, 15, 300}
],
{_, True, False, _}
]
] // Length

0

While a tolerance of +Infinity is also allowable, since this means that
any two real numbers will compare Equal, I struggle to imagine any
realistic situation in which this would be useful.

Oleksandr Rasputinov

unread,
Oct 9, 2011, 3:52:53 AM10/9/11
to
On Sat, 08 Oct 2011 19:44:45 +0100, Bill Rowe <read...@sbcglobal.net>
wrote:

> On 10/6/11 at 4:23 AM, w...@snafu.de (Dr. Wolfgang Hintze) wrote:


>
>> What about setting up a regular column "esoteric of the week" naming
>> functions that are rarely used ?
>
> The difficulty is a determination of rarely used. Who decides?

> And how? ... For me at least, the operational definition of rarely


> used would be those functions I have to look up syntax to use correctly.
>

Along these lines, I would suggest a family of undocumented Internal`

Richard Fateman

unread,
Oct 10, 2011, 4:27:05 AM10/10/11
to
If something becomes widely known, it is no longer esoteric.
Is the point to eliminate esoterica, at least for people reading this
newsgroup indefinitely?

If something is esoteric, it may be because there is no need for it to
be widely known; I think it is a good thing that most people do not use
up their presumably limited stock of neuronal connections on esoterica
such as Mathematica internals. They have enough trouble dealing with the
real world; why must they consider one made up by Wolfram and company?

If the goal is to periodically (weekly?) describe some obscure feature
that someone finds useful, that's certainly plausible.

Or UN-useful, that too. (e.g. "this esoteric feature is wrong"?)

Rehashing (say) the discussion about Accuracy and Precision, Inequality,
SameQ, Significance arithmetic, physicists, mathematicians, and
numerical analysts is maybe not worthwhile in the absence of a
particular new misbehavior posted to the newsgroup, for which various
partisans can provide opinions.

Maybe a carefully indexed / edited "advanced tips for Mathematica
programmers", an on-line and growing collection, perhaps gleaned from
this newsgroup, would be good.

Reply all
Reply to author
Forward
0 new messages