Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

Documentation  / Mathematica / Built-in Functions  / Advanced Documentation / Linear Algebra / Matrix Types /

 

Numbers in Mathematica

In order to understand the different types of matrices that Mathematica can work with, it will help to get an overview of the different types of numbers that are supported. This section will only give an overview of numbers in Mathematica, further information is found in The Mathematica Book.

Intrinsic types of numbers in Mathematica.

Mathematica provides an arithmetic system that unifies all these different types of number. For many purposes it is not necessary to know that there are two different types of integer because both types flow together. For example, the integer is represented by machine hardware. If this is raised to the tenth power, the result is represented by software.

In[1]:=

Out[1]=

In[2]:=

Out[2]=

Another example shows how a computation of the exponential of a machine-precision floating point number returns an arbitrary-precision number.

In[3]:=

Out[3]=

These examples demonstrate the general point that Mathematica arithmetic traps overflows and underflows so that it can switch from machine to software numbers. Despite this it tries to use machine hardware functionality whenever possible, so that Mathematica computations can be fast.

Exact versus Approximate Numbers

One important issue for Mathematica is that it makes a distinction between exact and approximate numbers. This is done to support the symbolic side of Mathematica. This example compares the computation of the Sin function for an integer and a real argument.

In[1]:=

Out[1]=

In[2]:=

Out[2]=

This demonstrates that mathematical functions, such as Sin, maintain the nature of their input. If they get an exact argument, the result will be exact. If they get an approximate argument the result is approximate. This feature of Mathematica is essential to maintain the system as a symbolic system, but it stands in contrast to the operation of a purely numerical environment. For example, in many languages such as C or Java the equivalent computation would coerce the integer to a double and the result would be an approximate number.

This distinction means that when you work with numbers you need to be more aware of their types than is the case in many other languages.

Mixed Mode Arithmetic

Another important issue concerns the operation of functions that take more than one argument. In this case Mathematica takes the lowest precision of the input. For example, the following mixed computations all return approximate results.

In[1]:=

Out[1]=

In[2]:=

Out[2]=

The same principle applies if the input includes an exact integer represented by software.

In[3]:=

Out[3]=



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information


 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: