Mathematica 9 is now available
 Documentation / Mathematica / The Mathematica Book / Advanced Mathematics / Numbers  /

3.1.2 Numeric Quantities


Testing for numeric quantities.

  • Pi is a symbol, so Pi+3 is not explicitly a number.
  • In[1]:= NumberQ[Pi + 3]

    Out[1]=

  • It does however have a numerical value.
  • In[2]:= NumericQ[Pi + 3]

    Out[2]=

  • This finds the explicit numerical value of Pi+3.
  • In[3]:= N[Pi + 3]

    Out[3]=

    Mathematica knows that constants such as Pi are numeric quantities. It also knows that standard mathematical functions such as Log and Sin have numerical values when their arguments are numerical.

  • Log[2+x] contains x, and is therefore not a numeric quantity.
  • In[4]:= {NumericQ[Log[2]], NumericQ[Log[2 + x]]}

    Out[4]=

  • Many functions implicitly use the numerical values of numeric quantities.
  • In[5]:= Min[Exp[2], Log[2], Sqrt[2]]

    Out[5]=

    In general, Mathematica assumes that any function which has the attribute NumericFunction will yield numerical values when its arguments are numerical. All standard mathematical functions in Mathematica already have this attribute. But when you define your own functions, you can explicitly set the attribute to tell Mathematica to assume that these functions will have numerical values when their arguments are numerical.



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.