Debugging Programs
Here are some suggestions for debugging Mathematica programs.
- First, try to divide the program so that each command resides in a single cell. That way, you can evaluate each command and see the resulting output.
- If you use an iterative command, like Table,
you should try setting the iterative variable instead. For example, the command
Table[f[x],{x,1,5}]
becomes
f[1]
f[2]
f[3]
f[4]
f[5]
- The previous suggestion works well for function definitions using
Module
or Block.
- You can use the Print
command to look at values of variables inside nested commands.
| |