Re: sum up

*To*: mathgroup at smc.vnet.net*Subject*: [mg69803] Re: [mg69716] sum up*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Sat, 23 Sep 2006 06:14:45 -0400 (EDT)*References*: <200609211130.HAA07793@smc.vnet.net>

The problem with the messages is that Block is returning its last expression and that NIntegrate returns itself unevaluated if it can't do anything. This results in the NIntegrate call being exposed to an environment where messages can be generated. You can easily block the messages by preventing NIntegrate from escaping Block. lst1={1/x,1/x^2}; Block[{Message},NIntegrate[lst1,{x,1,2}];] The semicolon before the end of the Block causes a Null to be the expression returned instead of NIntegrate[lst1,{x,1,2}], preventing the generation of messages outside the Block. On 9/21/06, dimmechan at yahoo.com <dimmechan at yahoo.com> wrote: > Hello. > > The last two-three days I posted some messages about some things that > they look strange (and not only to me). > > In case somebody was lost and in view of Chris Chiasson's suggestion I > sum up my queries/findings. > > Some of these questions have been answered a bit (actually it is these > answers that make me to deal more with) but I repost in case somebody > is interested. > > 1) Why built-in functions like Plot, Integrate and NIntegrate exhibit > listability although they do not have the Attribute Listable? > > lst = {1/x, 1/x^2}; > Integrate[lst, {x, 1, 2}] > {Log[2], 1/2} > NIntegrate[Evaluate[lst], {x, 1, 2}] > {0.693147180559947, 0.5000000000000211} > Plot[Evaluate@lst, {x, 1, 2}]; > ({#1, Attributes[#1]} & ) /@ {Integrate, NIntegrate, Plot} > {{Integrate, {Protected, ReadProtected}}, {NIntegrate, {HoldAll, > Protected}}, > {Plot, {HoldAll, Protected}}} > > To me (at least now) look more normal the behavior of > CauchyPrincipalValue. > > Needs["NumericalMath`"] > lst2= {1/x, 1/Sin[x]}; > > Both of these fail to produce Output (apart from the NIntegrate::inum > messages). > > CauchyPrincipalValue[lst, {x, -1, {0}, 2}] > CauchyPrincipalValue[Evaluate[lst], {x, -1, {0}, 2}] > > 2) Why do the following commands fail to prevent the appearance of > NIntegrate::inum? > > Block[{Message}, NIntegrate[lst1, {x, 1, 2}]] > Block[{$Messages = {}}, NIntegrate[lst1, {x, 1, 2}]] > > The relevant Plot::plnr message can be prevented from displaying. > > Block[{Message}, Plot[lst, {x, 1, 2}]]; > Block[{$Message = {}}, Plot[lst, {x, 1, 2}]]; > > 3) Why the first (second) command below fails (succeeds) to provide > Output? > > Block[{Message}, CauchyPrincipalValue[lst, {x, -1, {0}, 2}]] > Block[{$Messages = {}}, CauchyPrincipalValue[lst, {x, -1, {0}, 2}]] > > 4) From where all these "x" appear in the following list of sampled > points? > > Take[Reap[CauchyPrincipalValue[1/x, {x, -1, {0}, 2}, EvaluationMonitor > :> Sow[x], AccuracyGoal -> 20]][[2,1]], -12] > {1.7298614049356686, x, x, x, x, x, x, x, x, x, x, x} > > That's all (I guess for know!). > > I really appreciate any comments/insight. > > Thanks in advance. > > Regards > Dimitris Anagnostou > > P.S1. In case someone wonders, all these questions appear in my attempt > to get more insight of Mathematica thanks to this forum and some amazing people > ready to answer you everything. > (In fact even how you can command Mathematica to make your dinner...). > I do not mention anyone, because there are so many and I do not want to > forget someone. > > PS2. Nevertheless let me make just one exception and thank deeply > and from this position David Park. His comments/suggestions/advice > about the way I present my posts were invaluable. > > -- http://chris.chiasson.name/

**References**:**sum up***From:*dimmechan@yahoo.com