Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Re: Variables Within Homemade Functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69651] Re: [mg69598] Re: Variables Within Homemade Functions
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Tue, 19 Sep 2006 05:45:20 -0400 (EDT)
  • References: <eegb90$lm$1@smc.vnet.net> <200609171057.GAA28743@smc.vnet.net>

> [...]
> ***BTW, Block can have amazing results. For example
> 
> 
> Integrate[1/x, {x, -1, 2}]
>                              1
> Integrate::idiv: Integral of - does not converge on {-1, 2}. More...
>                              x
> 
> Integrate[x^(-1), {x, -1, 2}]
> 
> ***But
> 
> Block[{Message},Integrate[1/x,{x,-1,2}]]
> Infinity
> 
> [...]

There is a smallish bug in Integrate that is behind this. Clearly it 
should be unevaluated (that is, Infinity is quite incorrect).

That said, I view this example as user error. To see this we start with 
a mundane use of Check.

In[9]:= Check[ee=Simplify[aa,False],fubar,Simplify::fas]

Simplify::fas: Warning: One or more assumptions evaluated to False.

Out[9]= fubar

If you block Message then you effectively cripple Check. We see below 
that we do not get the Check'd result but rather the default.

In[10]:= Block[{Message},
	Check[ee=Simplify[aa,False],fubar,Simplify::fas]]

Out[10]= aa

Integrate and perhaps other functions will use things like Check, and 
expect them to work in their default manner.

By the way, if you want to be free of messages printing, this can be 
done in a way that does not at the same time trach Check:

In[11]:= Block[{$Messages},
	Check[ee=Simplify[aa,False],fubar,Simplify::fas]]

Out[11]= fubar

In[12]:= Block[{$Messages}, Integrate[1/x,{x,-1,2}]]

                    1
Out[12]= Integrate[-, {x, -1, 2}]
                    x

Here we get the correct results without messages. Moral: Don't Block[] 
built in functionality without a compelling reason to do so. (Put 
differently, be prepared to accept consequences of not knowing what you 
are doing.)


Daniel Lichtblau
Wolfram Research




  • Prev by Date: an equation containg radicals
  • Next by Date: Re: webMathematica, Packages, and hostSRV.com
  • Previous by thread: Re: Variables Within Homemade Functions
  • Next by thread: question about plot