### Mathematica Version 3 to Version 7 Conversion Notes

Perm url with updates: http://xahlee.org/comp/Mathematica_learning_notes.html

# Mathematica Version 3 to Version 7 Conversion Notes

Xah Lee, 2010-11-22, 2011-01

This page is misc personal notes of learning new features of Mathematica since version 3 in 1996.

In 1998, i was fairly a expert of Mathematica. I read the Mathematica Book from cover to cover systematically 3 times over different years. (See: Emacs Idolization: Have You Read the Emacs Manual From Cover to Cover?.) I've also read basically all popular Mathematica books in print of the 1990s. (See: A Survey of Mathematica Books 1997) A package i wrote Plane Tiling Mathematica Package, i consider more powerful, more flexible, more well documented, than a commercial one in a book written by one of the top Mathematica expert. I know almost all the programing constructs well, and know pretty much all the packages that exists, and have used lot of them. This is about 6 years of intensive Mathematica coding.

Though, that's over 10 years ago. I havn't done any math seriously since 1998, and i haven't coded Mathematica neither. The Mathematica i'm familiar with is Mathematica 3. It was the first major version, and the major feature was programable notebooks and automatic 2D typesetting and rendering. Mathematica has grown tremendously since. In particular, to areas outside math. Though, i still kept a eye on Stephen Wolfram and Wolfram Research's news and features. (See: Notes on A New Kind of Science.)

The following are some random, personal, technical, notes about Mathematica, when i convert/rewrite many of my packages from v3 to v7. These notes are on-going as i work more with Mathematica. (Thanks to Wolfram for giving me Mathematica version 7 as a gift.)

If you are interested in a comprehensive and detailed list of Mathematica thru the versions, there are official release notes in its documentation. See: http://www.wolfram.com/mathematica/quick-revision-history.html.

Some slightly more coherent Mathematica tutorials i've written are the following. Mostly for programers.

- The Concepts and Confusions of Prefix, Infix, Postfix and Fully Nested Notations
- How Mathematica does with Unicode?
- Short Intro of Mathematica For Lisp Programers (list processing example)
- A Mathematica Optimization Problem
- A Example of Mathematica's Expressiveness
- Introduction To Mathematica's 3D Graphics Format

## Obsolete Functions

• GraphicsArray is replaced by GraphicsRow and GraphicsGrid

• `<< Graphics`ImplicitPlot`;`

is obsolete. Use ContourPlot instead. Example:

<< Graphics`ImplicitPlot`; ImplicitPlot[{(x^2 + y^2)^2 == x^2 - y^2, (x^2 + y^2)^2 == 2 x y}, {x, -2, 2}, PlotStyle -> {GrayLevel[0], Dashing[{.03}]}]

ContourPlot[{(x^2 + y^2)^2 == x^2 - y^2, (x^2 + y^2)^2 == 2 x y}, {x, -1, 1}, {y, -1, 1}, ContourStyle -> {GrayLevel[0], Dashing[{.03}]}]

• `Needs["Utilities`FilterOptions`"];`

is obsolete. Replaced by FilterRules.

If you have:

opts = {a->b, c->d, Axes -> False}; BeginPackage["ParaPlot`","Utilities`FilterOptions`"] FilterOptions[Graphics,opts]

Now you should do this:

opts = {a->b, c->d, Axes -> False}; FilterRules[opt,Options@Graphics]

• «As of Version 6.0, Random has been superseded by the functions RandomReal and RandomInteger and others.»

• «As of Version 6.0, StyleForm has been superseded by Style.»

## Behavior Changes

• Evaluation behavior seems to have changed. Before, you need to put a “Evaluate” in.

ParametricPlot[Evaluate[Ellipse[.8][t]], {t, 0, 2 \[Pi]}, AspectRatio -> Automatic]

Now you don't.

• By default the input cell now uses StandardForm instead of InputForm. (if i recall correctly)

• definition of function's inline doc seems now needs to first check if it is defined, e.g.

If[ Not@ValueQ[Agglomerate::usage], Agglomerate::usage = "Agglomerate[list] ...."]

• Order of symbols in $Context seems to have changed. That is, when loading a package, the exported symbols now override your global ones (goes first in $Context). Before, when you call a function in a package such as ParaPlot, but you forgot to load the package. M gives a error. Then, you load the package, but that won't work, because “ParaPlot” is in the `Global``

context and that has precedence than the one in `Graph`ParaPlot`

. This used to be a big problem. Now, this seems fixed. Haven't thought about logical consequences yet.

## Graphics Display Behavior

• The semicolon now surpresses the side-effect of displaying graphics. Any
`Graphics[...]`

object (e.g. `Graphics[Line[{{0, 0}, {1, 1}}]]`

) is auto displayed as if with a `Show[Graphics[...]]`

but
the textual output is still surpressed.

The plot function's option the DisplayFunction's default value $DisplayFunction seems changed to Identity. Before, if set to Identity it will not display the graphics. Now, the display of graphics seems dependent on whether there's a semi-colon at the end of the whole expression.

It appears, the new logic is that any output of the form `Graphics[...]`

will be displayed visually. To surpress it, simply put a semi-colon.

• Graphics output inside of Do, For, and While loops is suppressed unless Print is used.

## Plotting Functions

• When plotting multiple curves with ParametricPlot, the curves automatically gets colored differently. e.g.

ParametricPlot[{{x, x^2}, {x, x^3}, {x, x^4}}, {x, -1.2, 1.2}]

You don't have to use set PlotStyle yourself now, e.g. `PlotStyle -> {Hue[0], Hue[.65], Hue[.34, 1, .7]}`

• “ParametricPlot” now uses Automatic as the default value for AspectRatio.

## New Functions

• Translate, Scale, Rotate, RotationMatrix, RotationTransform, TransformationFunction and a bunch others affine or otherwise transformation functions, that either work on graphics directly, or return the matrix formula, or a function that represent such operation. (v6) Nice!

• Norm returns the length of vector. (v5). Nice!

• Normalize returns the unit vector. (v6). Nice!

These are very nice. Without them, you have to define them like these:

normalize=Function[#/Sqrt@(Plus@@(#^2))]

(See also: A Example of Mathematica's Expressiveness)

Of course, it's slower than builtin. These are critical functions that are called tens of thousand times if you do graphics programing.

• Other new functions.

- ConstantArray (v5)
- SparseArray (v5)
- Tuples (v5.1)
- Riffle (v6)
- Subsets (v5.1)
- RandomChoice (v6)

- Dynamic (v6)
- Slider (v6)
- DynamicModule (v6)
- Animate (v6)
- Animator (v6)
- Manipulate (v6)

- Row (v6)

- Cone (7)

## Unanswered Questions

Is there a hotkey to switch windows?

Yes. 【`Ctrl`+`F6`】 also with `Shift`.
This is not document in v7.

• The real-time rotation of graphics feature does not seems to use GPU. Major disappointment. This means, when you have a graphics with tens of thousands of polygons (as opposed to toy example or classroom examples), the real time rotation is not usable. It has a frame-per-second like 0.1 (i.e. takes 10 secs to see a movement).

According to: http://www.wolfram.com/products/mathematica/newin6/content/RealTime3DGraphics/, it says «Seamless optimization with graphics hardware on all computer platforms.»?

i noticed that in many addon packages, they define the inline doc by first checking whether it is already defined, e.g. at ... Mathematica/7.0/AddOns/Packages/FourierSeries/FourierSeries.m like this: If[Not@ValueQ[SomeF::usage],SomeF::usage = "..." why does it need to check if it is already defined?