Mathematica Packages
One of the most important features of
Mathematica is that it is an extensible system. There is a certain amount of mathematical and other functionality that is built into
Mathematica. But by using the
Mathematica language, it is always possible to add more functionality.
For many kinds of calculations, what is built into the standard version of
Mathematica will be quite sufficient. However, if you work in a particular specialized area, you may find that you often need to use certain functions that are not built into
Mathematica.
In such cases, you may well be able to find a
Mathematica package that contains the functions you need.
Mathematica packages are files written in the
Mathematica language. They consist of collections of
Mathematica definitions which "teach"
Mathematica about particular application areas.
<<package | read in a Mathematica package |
Reading in Mathematica packages.
If you want to use functions from a particular package, you must first read the package into
Mathematica. The details of how to do this are discussed in
"External Programs". There are various conventions that govern the names you should use to refer to packages.
This command reads in a particular
Mathematica package.
Out[2]= | |
There are a number of subtleties associated with such issues as conflicts between names of functions in different packages. These are discussed in
"Contexts and Packages". One point to note, however, is that you should not refer to a function that you will read from a package before actually reading in the package. If you do this by mistake,
Mathematica will issue a message warning about the duplicate names and use the one last defined. This means that your version of the function will not be used; it will be the one from the package. You can execute the command
Remove to get rid of the package function.
Remove["name"] | remove a function that has been introduced in error |
Making sure that Mathematica uses correct definitions from packages.
The fact that
Mathematica can be extended using packages means that the boundary of exactly what is "part of
Mathematica" is quite blurred. As far as usage is concerned, there is actually no difference between functions defined in packages and functions that are fundamentally built into
Mathematica.
In fact, a fair number of the functions built into the core
Mathematica system are actually implemented as
Mathematica packages. However, on most
Mathematica systems, the necessary packages have been preloaded, so that the functions they define are always present.
To blur the boundary of what is part of
Mathematica even further,
"Automatic Loading of Packages" describes how you can tell
Mathematica automatically to load a particular package if you ever try to use a certain function. If you never use that function, then it will not be present. But as soon as you try to use it, its definition will be read in from a
Mathematica package.
As a practical matter, the functions that should be considered "part of
Mathematica" are probably those that are present in all
Mathematica systems. It is these functions that are primarily discussed in this documentation.
Nevertheless, most versions of
Mathematica come with a standard set of
Mathematica packages, which contain definitions for many more functions. To use these functions, you must usually read in the necessary packages explicitly.
You can use the Documentation Center to get information on
Mathematica 7 Standard Extra Packages.
It is possible to set your
Mathematica system up so that particular packages are preloaded, or are automatically loaded when needed. If you do this, then there may be many functions that appear as standard in your version of
Mathematica, but which are not documented in the
Mathematica system reference pages.
One point that should be mentioned is the relationship between packages and notebooks. Both are stored as files on your computer system, and both can be read into
Mathematica. However, a notebook is intended to be displayed, typically with a notebook interface, while a package is intended only to be used as
Mathematica input. Many notebooks in fact contain sections that can be considered as packages, and which contain sequences of definitions intended for input to
Mathematica. There are also capabilities that allow packages set up to correspond to notebooks to be maintained automatically.