Re: question about Block
- To: mathgroup at smc.vnet.net
- Subject: [mg69685] Re: [mg69661] question about Block
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Thu, 21 Sep 2006 07:28:57 -0400 (EDT)
- References: <200609200644.CAA24396@smc.vnet.net>
I that the numerical functions like FindMinimum, NIntegrate, etc, do weird things with the message system, usually to suppress the messages (and no, I'm not talking about General::stop). If you don't mind, post a summary when you find something. On 9/20/06, dimmechan at yahoo.com <dimmechan at yahoo.com> wrote: > Hello to all. > > Block as it is well known to the members of this forum does have some > nice applications. > For example > > $Version > "5.2 for Microsoft Windows (June 20, 2005)" > > Block[{Message}, Integrate[1/x, {x, -1, 2}]] > Infinity > Block[{Message}, NIntegrate[Sin[x]/x, {x, 0, Infinity}]] > 2.6457805920701 > > (execute the commands without Block to see the messages) > > Let me now define a list of two functions. > > lst = {1/x, 1/x^2}; > > Then > > 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 > > Attributes[NIntegrate] > {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 > prevented. > > 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 \ > calculation. > > Attributes[Plot] > {HoldAll, Protected} > > Block[{Message}, Plot[lst, {x, 1, 2}, DisplayFunction -> Identity]]; > Block[{$Messages = {}}, Plot[lst, {x, 1, 2}, DisplayFunction -> > Identity]]; > > Of course someone can simply switch off the message. > > Off[NIntegrate::inum] > NIntegrate[lst, {x, 1, 2}] > NIntegrate[lst, {x, 1, 2}] > > On[NIntegrate::inum] > > but the question remains why exist this strange (at least for me) > situation. > > Any comments/suggestions? > > Dimitris > > -- http://chris.chiasson.name/
- References:
- question about Block
- From: dimmechan@yahoo.com
- question about Block