Re: When does Mathematica display a message?
- To: mathgroup at smc.vnet.net
- Subject: [mg64038] Re: [mg64010] When does Mathematica display a message?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 28 Jan 2006 02:24:03 -0500 (EST)
- References: <200601271013.FAA19018@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 27 Jan 2006, at 10:13, ted.ersek at tqci.net wrote: > I did the following with Mathematica 4.0 under Windows 2000. > I wonder if Mathematica 5.2 does the same thing. > > > The first line posts a message as I expect. > > In[1]:= x=Sin[2,3] > > Sin::argx : Sin called with two arguments; 1 argument is expected. > > Out[1]= Sin[2,3] > > ---------------------------- > Why does the next line post the message twice? > > In[2]:= x+0.23 > > Sin::argx : Sin called with two arguments; 1 argument is expected. > > Sin::argx : Sin called with two arguments; 1 argument is expected. > > Out[2]= 0.23+Sin[2,3] This is because there are two attempts to evaluate Sin[2,3]. First of all because Plus evaluates its arguments there is an attempt to evaluate Sin[2,3] (however, see below) and the first message is issued. Then there is the second attempt to evaluate Plus[0.23,Sin [2,3]] itself (this is quite different form evaluating the arguments) and again the message is issued. > > > --------------------------- > Also why do the next two lines post no message? > > In[3]:= y=9/3+4+2^3*x > > Out[3]= 7+8*Sin[2,3] > > > > In[4]:= Expand[y^2] > > Out[4]= 49+112*Sin[2,3]+64*Sin[2,3]^2 This is because you are using exact values so Mathematica does not attempt to evaluate Sin[2,3] at all since everything is exact (just as it would not try to evaluate Sin[2]). However try y = 9/3 + 4. + 2^3*x and you will get two messages as before. Same with your other examples. You need to have at least one non-exact value and you will get the message twice. Note also that if you evaluate N[9/3 + 4 + 2^3*x] you will get the message only once. The reason is of course that the argument of N is exact so when the argument is evaluated there is no attempt to evaluate Sin[2,3]. You can also get the message three times by evaluating N[9/3 + 4. + 2^3*x] and so on. Andrzej Kozlowski
- References:
- When does Mathematica display a message?
- From: ted.ersek@tqci.net
- When does Mathematica display a message?