Spin`Algebra

Spin`Algebra — Magnetic Resonance with Mathematica
 

OptionsExplorer Guide

About

Mathematica has too many functions and it is not easy to remember all of their properties. OptionsExplorer provides an interactive tool to simplify the work with options of the functions. It opens a dialog window designed for getting information about functions, selecting their values and inserting the activated options into the editing expression. In addition to the Mathematica default set of options the package introduces alternative and preset options. Alternative options may include several values for a particular option thus any possible combination of alternatives can be selected. Preset options allow choosing extra sets of options.

© Yuri E. Kandrashkin, 2004-2006

Options explorer

Here we assume that the package OptionsExplorer` has been installed as it discribed in file Installation.nb and there is no loading needed.

Options frequently used to describe parameters of function. Lets look on next example:

[Graphics:img/guide_1.gif]

[Graphics:img/guide_2.gif]

Here the Mathematica function Simplify factorized trigonometric expression. But this expression often preferred to set in a reduced form. This goal can be achived by toggling the value of option Trig:

[Graphics:img/guide_3.gif]

[Graphics:img/guide_4.gif]

This task can be done more easely with OptionsExplorer. Select the expression (or put cursor just after it) and press [ALT]-[CTRL]-[o] to open its dialog window. (The command shortcut present here is for OS Windows, in other OS use Command key instead of [ALT]). Another way to start dialog is using menu command Input > Options Selector. The described actions open the window:

[Graphics:img/guide_5.gif]

All option names, rules and values here are active. Below listed the actions on click in the cells with options:

? – redirects to Help Browser reference quide (if the function defined in a separate package button refers to Add-Ons)
• Option name – activates (disactivates) the option.
• Rule sign – toggle between Rule, (→), and RuleDelayed, (:→).
• Option value – opens set of alternative options

The buttons above options act on all listed options. The button [All] activates and button [None] disactivate all shown options. Button [Last] sets the list of options applied the last time in the current Mathematica session. This is default set of Options Selector Dialog. It initially states all options disactivated and hence is equivalent to Mathematica default.

The buttons below close the dialog menu. Button [Cancel] cancels all actions. Button [Ok] accepts the changes and adds the activated options at the end of expression.

Thus there is direct access of information to the describtion of a function and to its options. Click on option Trig to activate it as it shown in the following picture. Because the value False is not defined yet it has to be inserted instead of True manually after the options set is accepted.

[Graphics:img/guide_6.gif]

Next time the activated options will be selected automatically.

Thus OptionSelector can be used for quick glance on the options of a function and for support in entering of their values. But more efficient to use OptionSelector with defined alternative and preset values of options.

Note that the described action will work only if the cursor will remain in the same position of the editing notebook while the dialog window is open.

Alternative options

If alternative options of a function func don't defined AlternativeOptions[func] uses the values of Options[func]. Compare the following result with options shown in the previous dialog window

[Graphics:img/guide_7.gif]

[Graphics:img/guide_8.gif]

In the following we will simplify the expression Re[Exp[I x]]:

[Graphics:img/guide_9.gif]

[Graphics:img/guide_10.gif]

We assume that all variables in simplified expression belong to domain of real positive numbers. Next expression is a definition of function positiveReals[] generating conditions for all symbols  evaluated in the current session which begin with lower-case character:

[Graphics:img/guide_11.gif]

This creates conditions for currently known symbols

[Graphics:img/guide_12.gif]

[Graphics:img/guide_13.gif]

Function AlternativeOptions describes the alternative values of an option. The values separated by sign | (that is they become agruments of function Altervatives):

[Graphics:img/guide_14.gif]

[Graphics:img/guide_15.gif]

The Options Selector Dialog window of function Simplify looks differently now. Only those options which were set during previous evaluation are present now:

[Graphics:img/guide_16.gif]

Note, that for the option Assumtions is set a different value because of its values in AlternativeOptions begin with positiveReals[]. But this rule doesn't work for option Trig inheriting the activated value from the prevous use.

The buttons [All] and [None] activate and disactivate the first values listed in the AlternativeOptions and thus click on [All] changes the value of Trig to False:

[Graphics:img/guide_17.gif]

Click on False diactivates the option and shows its available values:

[Graphics:img/guide_18.gif]

Click on any value closes other values and activates the option:

[Graphics:img/guide_19.gif]

The chosen set applied to expression Simplify[Exp[I x]//Re] in the input cell adds the options as it is shown in the following cell. The evaluation of derived expression gives:

[Graphics:img/guide_20.gif]

[Graphics:img/guide_21.gif]

Thus AlternativeOptions used to define the possible set of values which can be applied in an arbitrary order. In addition to Mathematica default set of options AlternativeOptions provides another set of options, the first elements of alternative values. Mathematica default set is applied if no option is activated (button [None]) and alternative set of options applied when all of them are activated (button [All]). Function PresetOptions used to expand preset options.

Preset options

PresetOptions[func]={{opts1},{opts2},...} sets preset options {opts1},{opts2},... of function func. First three preset options of a function will appear in its Options Selector Dialog window.

Next defines a function gammaToFactorial and creates one additional set of options:

[Graphics:img/guide_22.gif]

[Graphics:img/guide_23.gif]

We will use these settings to transform the expression:

[Graphics:img/guide_24.gif]

[Graphics:img/guide_25.gif]

The command [ALT]-[CTRL]-[o] applied to selected expression Simplify[...] opens window:

[Graphics:img/guide_26.gif]

The definition of PresetOptions adds extra line with option TransformationFunctions and new button [Set 1] appears in the top left of the dialog window. Click on this button activates preset options:

[Graphics:img/guide_27.gif]

The new value of Assumptions becomes also available from the list of alternative values:

[Graphics:img/guide_28.gif]

Click on buttons [Set 1] and [Ok] changes previous input cell to

Simplify[Abs[Gamma[n]],
    Assumptions:→{{k,l,m,n}∈Integers,k>0,l>0,m>0,n>0},
    TransformationFunctions:→{Automatic,gammaToFactorial}]

The evaluation of this expression gives

[Graphics:img/guide_29.gif]

[Graphics:img/guide_30.gif]

Saving sets in the package

Alternative and preset options may be saved in special package AlternativeAndPresetOptions` for autoloading with OptionsExplorer. Its package must be placed in the same directory as package OptionsExplorer`.

Removing alternative and preset values

To remove the defined values of AlternativeOptions[func] and PresetOptions[func] evaluate the expressions

AlternativeOptions[func] = Options[func]

PresetOptions[func] = {}

This clears the definitions of used symbols:

[Graphics:img/guide_33.gif]



   Last modified: August 11, 2006