Services & Resources / Wolfram Forums
MathGroup Archive
*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

question about Block

  • To: mathgroup at
  • Subject: [mg69661] question about Block
  • From: dimmechan at
  • Date: Wed, 20 Sep 2006 02:44:07 -0400 (EDT)

Hello to all.

Block as it is well known to the members of this forum does have some
nice applications.
For example

"5.2 for Microsoft Windows (June 20, 2005)"

Block[{Message}, Integrate[1/x, {x, -1, 2}]]
Block[{Message}, NIntegrate[Sin[x]/x, {x, 0, Infinity}]]

(execute the commands without Block to see the messages)

Let me now define a list of two functions.

lst = {1/x, 1/x^2};


NIntegrate[lst, {x, 1, 2}]
\!\(NIntegrate::"inum" : "Integrand \!\({1\/x,
     1\/x\^2}\) is not numerical at \!\({x}\) = {1.5`}."\)
NIntegrate[lst, {x, 1, 2}]

because NIntegrate has the attribute HoldAll

{HoldAll, Protected}

Of course

NIntegrate[Evaluate[lst], {x, 1, 2}]
{0.693147180559947, 0.5000000000000211}

Now to my surprise I discovered that the following commands fail to
prevent the appearance of  NIntegrate::inum  message.

Block[{Message}, NIntegrate[lst, {x, 1, 2}]]
\!\(NIntegrate::"inum" : "Integrand \!\({1\/x,
     1\/x\^2}\) is not numerical at \!\({x}\) = {1.5`}."\)
NIntegrate[lst, {x, 1, 2}]

Block[{$Messages = {}}, NIntegrate[lst, {x, 1, 2}]]
\!\(NIntegrate::"inum" : "Integrand \!\({1\/x,
     1\/x\^2}\) is not numerical at \!\({x}\) = {1.5`}."\)
NIntegrate[lst, {x, 1, 2}]

What is more strange is that the relevant Plot::plnr message can be

Plot[lst, {x, 1, 2}, DisplayFunction -> Identity];
Plot::plnr : lst is not a machine-size real number at x =
1.0000000416666666`. (...3 times...)
General::stop : Further output of Plot::plnr will be suppressed during
this \

{HoldAll, Protected}

Block[{Message}, Plot[lst, {x, 1, 2}, DisplayFunction -> Identity]];
Block[{$Messages = {}}, Plot[lst, {x, 1, 2}, DisplayFunction ->

Of course someone can simply switch off the message.

NIntegrate[lst, {x, 1, 2}]
NIntegrate[lst, {x, 1, 2}]


but the question remains why exist this strange (at least for me)

Any comments/suggestions?


  • Prev by Date: Re: attention 64 bit Mathematica users - would you please test a command for me?
  • Next by Date: Re: an equation containg radicals
  • Previous by thread: Re: Iterative constants and variables definitions
  • Next by thread: Re: question about Block