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

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

Search the Archive

Strange Answer

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Strange Answer
  • From: puglisi at settimo.italtel.it
  • Date: Thu, 11 Nov 93 15:25:24 MST

   ---------------------------------------------
Gigi Ventura (VENTURA at pd.infn.it) noticed the following
"strange behaviour" of MMA:

In[1]:=
        g1[x_]:=+x
In[2]:=
        g1[2,3,4]
Out[2]=
        9
In[3]:=
        g2[x_]:=-x
In[4]:=
        g2[2,3,4]
Out[4]=
        -24

He says: the answer, that may be unexpected, is explained
by the multiplication (by-1) implicitly required in the sign 
change. The priority of multiplication with respect to addition
makes the result.
To obtain the desired result parenthesis should be used:

In[5]:=
        g3[x_]:=-(+x)
In[6]:=
        g3[2,3,4]
Out[6]=
        -9

I forward this notice, since it might interest some other user.

Giacomo Torzo
   ---------------------------------------------

I think the behavior you observe is wrong and due to a faulty 
version of Mma.  

Here is what I get:

In[5]:= $Version

Out[5]= HP 9000 Series 300 (HP-UX) 1.2 (December 13, 1990)

In[6]:= g1[x_]:=+x

In[7]:= g1[2,3,4]

Out[7]= g1[2, 3, 4]

In[8]:= g2[x_]:=-x

In[9]:= g2[2,3,4]

Out[9]= g2[2, 3, 4]


Alberto Puglisi

ITALTEL
Central Research Laboratories, DRSC-IS CLTB
20019 Castelletto di Settimo Milanese (Milano)
Italy
phone:  (+39)(2)4388-8299
fax:    (+39)(2)4388-7989
e-mail: puglisi at settimo.italtel.it






  • Prev by Date: courses
  • Next by Date: Re: Naming the Mathematica language
  • Previous by thread: courses
  • Next by thread: Re: Strange answer