MathGroup Archive 2011

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

Search the Archive

Re: Why Mathematica does not issue a warning when the calculations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117821] Re: Why Mathematica does not issue a warning when the calculations
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Fri, 1 Apr 2011 02:31:24 -0500 (EST)
  • References: <in1n51$6sj$1@smc.vnet.net>

On 3/31/2011 4:05 AM, Andrzej Kozlowski wrote:
> On 31 Mar 2011, at 11:03, Richard Fateman wrote:
>
>> Here's a way around this issue, I think.  For every function of
>> interest, do something like this:
>> prec;
>> f[x_]:=Block[ {$MaxPrecision=prec,$MinPrecision=prec}, Whatever...]
>>
>> This is even less intuitive than your suggestion.
>>
>>
>> RJF
>
>
> An original and surprising suggestion, particularly in view of the following:
>
>
> On 29 Mar 2011, at 13:53, Andrzej Kozlowski wrote:
>
>> In addition (for some curious reason) Richard never bothers to point out that
>>
>> z = 1.0000000000000000000;
>> Block[{$MaxPrecision = 20, $MinPrecision = 20},
>> Table[(z = 2*z - z), {42}]]
>
> Andrzej Kozlowski
>

Certainly Andrzej was not the first to post this on mathgroup, nor was I.
My point, which Andrzej may have lost sight of, is that to make this 
setting effective, one must rephrase each and every function this way.

  It is not enough to just globally set $MaxPrecision and $MinPrecision.

(As DL points out, the current version of NSolve, etc, would break.)

If you wanted to break NSolve etc, it might be possible to do something 
to all primitive operators like Plus, Times, Power, ...  along the lines of

prec;

UnProtect[Times]

Stopit=False;

x_*y_ := Block[{Stopit = True}, SetPrecision[x*y, prec]] /;
   Stopit == False


Though this works:

f[zz_] := Block[{Stopit = True}, SetPrecision[f[zz], prec]] /;
   Stopit == False

if you set prec=10, then
f[1.2`100]  returns f[1.2`10].

So maybe there is something special about Times.










  • Prev by Date: Re: NonlinearFit for specific data
  • Next by Date: Re: Capture values that Min(imize)
  • Previous by thread: Re: Why Mathematica does not issue a warning when the calculations
  • Next by thread: Re: Off Topic: E-Mail Security in this Group