In many kinds of calculations, you may find yourself typing the same input to Mathematica
over and over again. You can save yourself a lot of typing by defining a function
that contains your input commands.
The functions you define in Mathematica
are essentially procedures that execute the commands you give. You can have several steps in your procedures, separated by semicolons.
When you write procedures in Mathematica
, it is usually a good idea to make variables you use inside the procedures local
, so that they do not interfere with things outside the procedures. You can do this by setting up your procedures as modules
, in which you give a list of variables to be treated as local.