Mathematica Pearls: Problems and Solutions

The editor discovers new problems and solutions while usingVersion 3.0's palettes to construct a notebook of probability simulations.

Edited by Don Piele

I have to agree palettes are cool, and the ones that come configured with Mathematica 3.0 are very useful. But when I tried to think how I would use them in my notebooks, I made many false starts. Sure, it is a snap to make a palette with the Input > Create > Table/Matrix/Palette command. But you need to have a good reason to build one. It is easy to do: Will it really add something to the notebook?  

	Recently I have been re-writing some simulations in introductory probability to go with the college-level manuscript  Introduction to Probability  by Snell and Grinstead, soon to be published by the American Mathematical Society. I wrote and tested the programs in Mathematica 2.2.2. When Version 3.0 became available, I converted them and began looking for ways to apply the new 3.0 features.

Outlining

The first feature I went after was outlining, found in the Option Inspector in its pull-down menu. Here the triangles that appear in the left margin let you close and open the items that are nested beneath it. To do this you open the Options Inspector under Format and select the Show option value for Notebook. Now select Cell Options > Display Options > ShowGroupOpenCloseIcon -> True. If you like, you can turn off the normal right hand cell brackets with  Cell Options > Display Options > ShowCellBracket -> False.

To remove the  cell "dingbats" (those black and gray squares at the beginning of each section and subsection) execute Cell Options > Display Options > CellDingbat -> False. You would probably need to set this option at the cell style level since, unfortunately, this option has no effect at the global or notebook level, which may be a bug.   You can see the resulting format of the notebook below. [Editor's note: You can run the actual notebook in the electronic version of this journal.]

Palettes

The application I had in mind was to automatically produce a palette containing the functions defined in the notebook. I wanted this palette to appear in the upper right hand corner as soon as the notebook was opened. This required that I know the path to the palette on the disk.  First I needed to make a palette which contains the seven functions defined in the chapter. This is done with the string of commands:  Input > Create/Table/ Matrix/Palette > Make Palette > 8 rows by 1 column. Select each button and enter the names of the functions. For the placeholder I used ESCAPE spl ESCAPE. For the heading, I typed Chapter 1. The result is shown under Palette in the notebook.

	Now to generate the palette, select the palette and under File > Generate Palette from  Selection.  Next I placed the palette in the upper right-hand corner of the screen. From this position I saved the palette.nb on the disk named Classes in the folder Chapter1 where I also saved the notebook.nb.

Initialization

In Mathematica 3.0, a notebook with initialized cells will not immediately ask if you want to run the initialization cells, unless you set this condition. This is done again with the Options Inspector, where you will want to set Show option values for the Notebook. Now make the selection under Notebook Options > Evaluate Options > InitializationCellLoading -> True.

	Finally, we need to write a notebook command which will immediately bring up the palette upon initialization of the notebook. This is done by writing  NotebookOpen["classes:chapter1:palette.nb"];  in a cell that is initialized. I put it in the area where I load the graphics functions.  Don't forget to add your own path name to the palette.nb when you set up your own notebook.
	
	Now save your notebook.nb, and you are ready to roll. When you open the notebook, you have a palette that is ready for use in any notebook. It is also a good idea to keep a copy of your palette within the notebook, in case you give it to someone and forget to give them the palette.

The completed notebook

See the other electronic submission included with
this article, completedNotebook.nb.

SUBMITTING PROBLEMS AND SOLUTIONS

The preferred way to submit problems or solutions is via email. They may also be sumbitted on paper or on a disk through the regular mail. When you submit your work, include a brief English description of your solution, or use comments in your program to help the reader follow your ideas. Of course, you should include your name, institution, category (high school, college undergraduate, other) and mail or email address.

CONTACTING THE EDITOR

Donald T. Piele
Mathematics Department
University of Wisconsin-Parkside
900 Wood Road
Kenosha, WI 53141

email: piele@cs.uwp.edu
phone: 414-595-2231
fax: 414-595-2056